Add a unittest using the Vala and C warnings test

This actually tests that -Wall, -Werror, and -w are set in the right
targets.
pull/866/head
Nirbheek Chauhan 8 years ago
parent 354c4bcaeb
commit 9ac98040ae
  1. 28
      run_unittests.py
  2. 4
      test cases/vala/5 target glib/GLib.Thread.vala
  3. 2
      test cases/vala/5 target glib/meson.build
  4. 5
      test cases/vala/5 target glib/retcode.c

@ -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()

@ -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;
}
}

@ -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)

@ -0,0 +1,5 @@
int
get_ret_code (void)
{
return 42;
}
Loading…
Cancel
Save