Bug 902389 - Normalize topobjdir; r=mshal

This commit is contained in:
Gregory Szorc 2013-08-09 12:04:15 -07:00
parent 0a4275cc10
commit 2be348ac4c
2 changed files with 18 additions and 2 deletions

View File

@ -176,8 +176,9 @@ class MozbuildObject(ProcessExecutionMixin):
topobj = self.mozconfig['topobjdir'] or 'obj-@CONFIG_GUESS@'
if not os.path.isabs(topobj):
topobj = os.path.abspath(os.path.join(self.topsrcdir, topobj))
self._topobjdir = topobj.replace("@CONFIG_GUESS@",
self._config_guess)
topobj = topobj.replace("@CONFIG_GUESS@", self._config_guess)
self._topobjdir = os.path.normpath(topobj)
return self._topobjdir
@property

View File

@ -47,6 +47,21 @@ class TestMozbuildObject(unittest.TestCase):
del os.environ[b'MOZCONFIG']
def test_objdir_trailing_slash(self):
"""Trailing slashes in topobjdir should be removed."""
base = self.get_base()
with NamedTemporaryFile() as mozconfig:
mozconfig.write('mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/foo/')
mozconfig.flush()
os.environ[b'MOZCONFIG'] = mozconfig.name
self.assertEqual(base.topobjdir, os.path.join(base.topsrcdir,
'foo'))
self.assertTrue(base.topobjdir.endswith('foo'))
del os.environ[b'MOZCONFIG']
def test_config_guess(self):
# It's difficult to test for exact values from the output of
# config.guess because they vary depending on platform.