aboutsummaryrefslogtreecommitdiff
path: root/run_unittests.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2017-01-21 12:05:38 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2017-01-28 05:09:51 +0530
commit2bb58c909fd80cc8ce053b5f1b6565bd28a416d2 (patch)
treeb6510bc5f6585087e18f90f23b0c2fd1d4ac1150 /run_unittests.py
parentdbcbf19ecea9d07d264dbbc1cd87ab22393be8a7 (diff)
downloadmeson-2bb58c909fd80cc8ce053b5f1b6565bd28a416d2.zip
meson-2bb58c909fd80cc8ce053b5f1b6565bd28a416d2.tar.gz
meson-2bb58c909fd80cc8ce053b5f1b6565bd28a416d2.tar.bz2
Use CompilerArgs for generation of compile commands
At the same time, also fix the order in which compile arguments are added. Detailed comments have been added concerning the priority and order of the arguments. Also adds a unit test and an integration test for the same.
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-xrun_unittests.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/run_unittests.py b/run_unittests.py
index a90e46b..b6ea073 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -14,6 +14,7 @@
# limitations under the License.
import stat
+import shlex
import unittest, os, sys, shutil, time
import subprocess
import re, json
@@ -698,6 +699,38 @@ class LinuxlikeTests(unittest.TestCase):
# The chown failed nonfatally if we're not root
self.assertEqual(0, statf.st_uid)
+ def test_internal_include_order(self):
+ testdir = os.path.join(self.common_test_dir, '138 include order')
+ self.init(testdir)
+ 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')
+ incs = [a for a in shlex.split(cmd) if a.startswith("-I")]
+ self.assertEqual(len(incs), 8)
+ # target private dir
+ self.assertEqual(incs[0], "-Isub4/someexe@exe")
+ # target build subdir
+ self.assertEqual(incs[1], "-Isub4")
+ # target source subdir
+ msg = "{!r} does not end with '/sub4'".format(incs[2])
+ self.assertTrue(incs[2].endswith("/sub4"), msg)
+ # include paths added via per-target c_args: ['-I'...]
+ msg = "{!r} does not end with '/sub3'".format(incs[3])
+ self.assertTrue(incs[3].endswith("/sub3"), msg)
+ # target include_directories: build dir
+ self.assertEqual(incs[4], "-Isub2")
+ # target include_directories: source dir
+ msg = "{!r} does not end with '/sub2'".format(incs[5])
+ self.assertTrue(incs[5].endswith("/sub2"), msg)
+ # target internal dependency include_directories: build dir
+ self.assertEqual(incs[6], "-Isub1")
+ # target internal dependency include_directories: source dir
+ msg = "{!r} does not end with '/sub1'".format(incs[7])
+ self.assertTrue(incs[7].endswith("/sub1"), msg)
+
class RewriterTests(unittest.TestCase):