diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-03-23 08:32:01 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-03-23 10:26:29 +0530 |
commit | 7f80f81ac9c00ed328566d9aec5140b4f9d1d21d (patch) | |
tree | bd5efaf8b6cde4683a1852f3f3759fbc46a727dc /run_unittests.py | |
parent | 8482286236f6d91dfaa02e4254e0e15430e67eb2 (diff) | |
download | meson-7f80f81ac9c00ed328566d9aec5140b4f9d1d21d.zip meson-7f80f81ac9c00ed328566d9aec5140b4f9d1d21d.tar.gz meson-7f80f81ac9c00ed328566d9aec5140b4f9d1d21d.tar.bz2 |
Preserve the order of internal deps in a target
We were adding them to the CompilerArgs instance in the order in which
they are specified, which is wrong because later dependencies would
override previous ones. Add them in the reverse order instead.
Closes https://github.com/mesonbuild/meson/issues/1495
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-x | run_unittests.py | 60 |
1 files changed, 46 insertions, 14 deletions
diff --git a/run_unittests.py b/run_unittests.py index 9945057..bba5bb8 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -432,7 +432,20 @@ class BasePlatformTests(unittest.TestCase): def get_compdb(self): with open(os.path.join(self.builddir, 'compile_commands.json')) as ifile: - return json.load(ifile) + contents = json.load(ifile) + # If Ninja is using .rsp files, generate them, read their contents, and + # replace it as the command for all compile commands in the parsed json. + if len(contents) > 0 and contents[0]['command'].endswith('.rsp'): + # Pretend to build so that the rsp files are generated + self.build(['-d', 'keeprsp', '-n']) + for each in contents: + # Extract the actual command from the rsp file + compiler, rsp = each['command'].split(' @') + rsp = os.path.join(self.builddir, rsp) + # Replace the command with its contents + with open(rsp, 'r', encoding='utf-8') as f: + each['command'] = compiler + ' ' + f.read() + return contents def get_meson_log(self): with open(os.path.join(self.builddir, 'meson-logs', 'meson-log.txt')) as f: @@ -712,20 +725,18 @@ class AllPlatformTests(BasePlatformTests): def test_internal_include_order(self): testdir = os.path.join(self.common_test_dir, '138 include order') self.init(testdir) + execmd = fxecmd = None for cmd in self.get_compdb(): - if cmd['file'].endswith('/main.c'): - cmd = cmd['command'] - break - else: - raise Exception('Could not find main.c command') - if cmd.endswith('.rsp'): - # Pretend to build so that the rsp files are generated - self.build(['-d', 'keeprsp', '-n']) - # Extract the actual command from the rsp file - rsp = os.path.join(self.builddir, cmd.split('cl @')[1]) - with open(rsp, 'r', encoding='utf-8') as f: - cmd = f.read() - incs = [a for a in shlex.split(cmd) if a.startswith("-I")] + if 'someexe' in cmd['command']: + execmd = cmd['command'] + continue + if 'somefxe' in cmd['command']: + fxecmd = cmd['command'] + continue + if not execmd or not fxecmd: + raise Exception('Could not find someexe and somfxe commands') + # Check include order for 'someexe' + incs = [a for a in shlex.split(execmd) if a.startswith("-I")] self.assertEqual(len(incs), 8) # target private dir self.assertPathEqual(incs[0], "-Isub4/someexe@exe") @@ -743,6 +754,27 @@ class AllPlatformTests(BasePlatformTests): self.assertPathEqual(incs[6], "-Isub1") # target internal dependency include_directories: source dir self.assertPathBasenameEqual(incs[7], 'sub1') + # Check include order for 'somefxe' + incs = [a for a in shlex.split(fxecmd) if a.startswith('-I')] + self.assertEqual(len(incs), 9) + # target private dir + self.assertPathEqual(incs[0], '-Isomefxe@exe') + # target build dir + self.assertPathEqual(incs[1], '-I.') + # target source dir + self.assertPathBasenameEqual(incs[2], os.path.basename(testdir)) + # target internal dependency correct include_directories: build dir + self.assertPathEqual(incs[3], "-Isub4") + # target internal dependency correct include_directories: source dir + self.assertPathBasenameEqual(incs[4], 'sub4') + # target internal dependency dep include_directories: build dir + self.assertPathEqual(incs[5], "-Isub1") + # target internal dependency dep include_directories: source dir + self.assertPathBasenameEqual(incs[6], 'sub1') + # target internal dependency wrong include_directories: build dir + self.assertPathEqual(incs[7], "-Isub2") + # target internal dependency wrong include_directories: source dir + self.assertPathBasenameEqual(incs[8], 'sub2') def test_compiler_detection(self): ''' |