diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-10-11 13:13:04 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-10-14 19:13:38 +0530 |
commit | 9ac98040ae06ec4c0da059a3cd8c729626d6099c (patch) | |
tree | 64a36827e35da2b413f7c63139ccd3ada4626e43 | |
parent | 354c4bcaeb093e1b8ef161985901b23957314bc0 (diff) | |
download | meson-9ac98040ae06ec4c0da059a3cd8c729626d6099c.zip meson-9ac98040ae06ec4c0da059a3cd8c729626d6099c.tar.gz meson-9ac98040ae06ec4c0da059a3cd8c729626d6099c.tar.bz2 |
Add a unittest using the Vala and C warnings test
This actually tests that -Wall, -Werror, and -w are set in the right
targets.
-rwxr-xr-x | run_unittests.py | 28 | ||||
-rw-r--r-- | test cases/vala/5 target glib/GLib.Thread.vala | 4 | ||||
-rw-r--r-- | test cases/vala/5 target glib/meson.build | 2 | ||||
-rw-r--r-- | test cases/vala/5 target glib/retcode.c | 5 |
4 files changed, 37 insertions, 2 deletions
diff --git a/run_unittests.py b/run_unittests.py index 79cdae0..b9c1397 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -45,6 +45,7 @@ class LinuxlikeTests(unittest.TestCase): self.mconf_command = [sys.executable, os.path.join(src_root, 'mesonconf.py')] self.ninja_command = [detect_ninja(), '-C', self.builddir] self.common_test_dir = os.path.join(src_root, 'test cases/common') + self.vala_test_dir = os.path.join(src_root, 'test cases/vala') self.output = b'' self.orig_env = os.environ.copy() @@ -108,5 +109,32 @@ class LinuxlikeTests(unittest.TestCase): self.assertEqual(simple_dep.get_version(), '1.0') self.assertTrue('-lfoo' in simple_dep.get_link_args()) + def test_vala_c_warnings(self): + testdir = os.path.join(self.vala_test_dir, '5 target glib') + self.init(testdir) + compdb = self.get_compdb() + vala_command = None + c_command = None + for each in compdb: + if each['file'].endswith('GLib.Thread.c'): + vala_command = each['command'] + elif each['file'].endswith('retcode.c'): + c_command = each['command'] + else: + m = 'Unknown file {!r} in vala_c_warnings test'.format(each['file']) + raise AssertionError(m) + self.assertIsNotNone(vala_command) + self.assertIsNotNone(c_command) + # -w suppresses all warnings, should be there in Vala but not in C + self.assertTrue('-w' in vala_command) + self.assertFalse('-w' in c_command) + # -Wall enables all warnings, should be there in C but not in Vala + self.assertFalse('-Wall' in vala_command) + self.assertTrue('-Wall' in c_command) + # -Werror converts warnings to errors, should always be there since it's + # injected by an unrelated piece of code and the project has werror=true + self.assertTrue('-Werror' in vala_command) + self.assertTrue('-Werror' in c_command) + if __name__ == '__main__': unittest.main() diff --git a/test cases/vala/5 target glib/GLib.Thread.vala b/test cases/vala/5 target glib/GLib.Thread.vala index 27c0fca..a1a0414 100644 --- a/test cases/vala/5 target glib/GLib.Thread.vala +++ b/test cases/vala/5 target glib/GLib.Thread.vala @@ -1,3 +1,5 @@ +extern int get_ret_code (); + public class MyThread : Object { public int x_times { get; private set; } @@ -12,7 +14,7 @@ public class MyThread : Object { } // return & exit have the same effect - Thread.exit (42); + Thread.exit (get_ret_code ()); return 43; } } diff --git a/test cases/vala/5 target glib/meson.build b/test cases/vala/5 target glib/meson.build index 679e908..3f0d01e 100644 --- a/test cases/vala/5 target glib/meson.build +++ b/test cases/vala/5 target glib/meson.build @@ -2,5 +2,5 @@ project('valatest', 'vala', 'c', default_options : ['werror=true']) valadeps = [dependency('glib-2.0', version : '>=2.32'), dependency('gobject-2.0')] -e = executable('valaprog', 'GLib.Thread.vala', dependencies : valadeps) +e = executable('valaprog', 'GLib.Thread.vala', 'retcode.c', dependencies : valadeps) test('valatest', e) diff --git a/test cases/vala/5 target glib/retcode.c b/test cases/vala/5 target glib/retcode.c new file mode 100644 index 0000000..abca9bf --- /dev/null +++ b/test cases/vala/5 target glib/retcode.c @@ -0,0 +1,5 @@ +int +get_ret_code (void) +{ + return 42; +} |