Commit 3b780471 authored by Mike Hommey's avatar Mike Hommey
Browse files

Bug 1253203 - Normalize path separators in MozbuildObject. r=gps

The upcoming move of the configure.py initialization to sandboxed
moz.configure changes the path separators for topsrcdir and topobjdir
from native to always use forward-slashes, which confuses the hell out
of the test_base.py test. Settle the issue by declaring that
MozbuildObject will always use forward-slashed paths for topsrcdir
and topobjdir.
parent b505dba9
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -80,14 +80,14 @@ class MozbuildObject(ProcessExecutionMixin):
        and a LogManager instance. The topobjdir may be passed in as well. If
        it isn't, it will be calculated from the active mozconfig.
        """
        self.topsrcdir = topsrcdir
        self.topsrcdir = mozpath.normsep(topsrcdir)
        self.settings = settings

        self.populate_logger()
        self.log_manager = log_manager

        self._make = None
        self._topobjdir = topobjdir
        self._topobjdir = mozpath.normsep(topobjdir) if topobjdir else topobjdir
        self._mozconfig = None
        self._config_guess_output = None
        self._config_environment = None
@@ -184,9 +184,10 @@ class MozbuildObject(ProcessExecutionMixin):
            if not samepath(topobjdir, _config_topobjdir):
                raise ObjdirMismatchException(topobjdir, _config_topobjdir)

        topsrcdir = mozpath.normsep(topsrcdir)
        topobjdir = topobjdir or config_topobjdir
        if topobjdir:
            topobjdir = os.path.normpath(topobjdir)
            topobjdir = mozpath.normsep(os.path.normpath(topobjdir))

            if topsrcdir == topobjdir:
                raise BadEnvironmentException('The object directory appears '
@@ -210,7 +211,7 @@ class MozbuildObject(ProcessExecutionMixin):
        if not os.path.isabs(topobjdir):
            topobjdir = os.path.abspath(os.path.join(topsrcdir, topobjdir))

        return os.path.normpath(topobjdir)
        return mozpath.normsep(os.path.normpath(topobjdir))

    @property
    def topobjdir(self):
+7 −6
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ from mozbuild.base import (

from mozbuild.backend.configenvironment import ConfigEnvironment
from buildconfig import topsrcdir, topobjdir
import mozpack.path as mozpath


curdir = os.path.dirname(__file__)
@@ -59,7 +60,7 @@ class TestMozbuildObject(unittest.TestCase):
            self.assertEqual(len(base.topobjdir.split()), 1)
            self.assertTrue(base.topobjdir.endswith(base._config_guess))
            self.assertTrue(os.path.isabs(base.topobjdir))
            self.assertTrue(base.topobjdir.startswith(topsrcdir))
            self.assertTrue(base.topobjdir.startswith(base.topsrcdir))

    def test_objdir_trailing_slash(self):
        """Trailing slashes in topobjdir should be removed."""
@@ -70,7 +71,7 @@ class TestMozbuildObject(unittest.TestCase):
            mozconfig.flush()
            os.environ[b'MOZCONFIG'] = mozconfig.name

            self.assertEqual(base.topobjdir, os.path.join(base.topsrcdir,
            self.assertEqual(base.topobjdir, mozpath.join(base.topsrcdir,
                'foo'))
            self.assertTrue(base.topobjdir.endswith('foo'))

@@ -113,7 +114,7 @@ class TestMozbuildObject(unittest.TestCase):
            obj = MozbuildObject.from_environment(
                detect_virtualenv_mozinfo=False)

            self.assertEqual(obj.topobjdir, topobjdir)
            self.assertEqual(obj.topobjdir, mozpath.normsep(topobjdir))
        finally:
            os.chdir(self._old_cwd)
            shutil.rmtree(d)
@@ -126,7 +127,7 @@ class TestMozbuildObject(unittest.TestCase):
            with open(mozconfig, 'wt') as fh:
                fh.write('mk_add_options MOZ_OBJDIR=./objdir')

            topobjdir = os.path.join(d, 'objdir')
            topobjdir = mozpath.join(d, 'objdir')
            os.mkdir(topobjdir)

            mozinfo = os.path.join(topobjdir, 'mozinfo.json')
@@ -216,8 +217,8 @@ class TestMozbuildObject(unittest.TestCase):

            o = MachCommandBase(context)

            self.assertEqual(o.topobjdir, topobjdir)
            self.assertEqual(o.topsrcdir, topsrcdir)
            self.assertEqual(o.topobjdir, mozpath.normsep(topobjdir))
            self.assertEqual(o.topsrcdir, mozpath.normsep(topsrcdir))

        finally:
            os.chdir(self._old_cwd)