tests: Add a test for new test suite selection.

pull/1279/head
Hemmo Nieminen 8 years ago
parent b90956c2f2
commit 5833bd6735
  1. 55
      run_unittests.py
  2. 1
      test cases/unit/4 suite selection/failing_test.c
  3. 13
      test cases/unit/4 suite selection/meson.build
  4. 1
      test cases/unit/4 suite selection/subprojects/subprjfail/failing_test.c
  5. 5
      test cases/unit/4 suite selection/subprojects/subprjfail/meson.build
  6. 1
      test cases/unit/4 suite selection/subprojects/subprjmix/failing_test.c
  7. 9
      test cases/unit/4 suite selection/subprojects/subprjmix/meson.build
  8. 1
      test cases/unit/4 suite selection/subprojects/subprjmix/successful_test.c
  9. 5
      test cases/unit/4 suite selection/subprojects/subprjsucc/meson.build
  10. 1
      test cases/unit/4 suite selection/subprojects/subprjsucc/successful_test.c
  11. 1
      test cases/unit/4 suite selection/successful_test.c

@ -418,6 +418,61 @@ class LinuxlikeTests(unittest.TestCase):
self.assertTrue('TEST_ENV is set' in vg_log)
self.assertTrue('Memcheck' in vg_log)
def assertFailedTestCount(self, failure_count, command):
try:
self._run(command)
self.assertEqual(0, failure_count, 'Expected %d tests to fail.' % failure_count)
except subprocess.CalledProcessError as e:
self.assertEqual(e.returncode, failure_count)
def test_suite_selection(self):
testdir = os.path.join(self.unit_test_dir, '4 suite selection')
self.init(testdir)
self.build()
self.assertFailedTestCount(3, self.mtest_command)
self.assertFailedTestCount(0, self.mtest_command + ['--suite', ':success'])
self.assertFailedTestCount(3, self.mtest_command + ['--suite', ':fail'])
self.assertFailedTestCount(3, self.mtest_command + ['--no-suite', ':success'])
self.assertFailedTestCount(0, self.mtest_command + ['--no-suite', ':fail'])
self.assertFailedTestCount(1, self.mtest_command + ['--suite', 'mainprj'])
self.assertFailedTestCount(0, self.mtest_command + ['--suite', 'subprjsucc'])
self.assertFailedTestCount(1, self.mtest_command + ['--suite', 'subprjfail'])
self.assertFailedTestCount(1, self.mtest_command + ['--suite', 'subprjmix'])
self.assertFailedTestCount(2, self.mtest_command + ['--no-suite', 'mainprj'])
self.assertFailedTestCount(3, self.mtest_command + ['--no-suite', 'subprjsucc'])
self.assertFailedTestCount(2, self.mtest_command + ['--no-suite', 'subprjfail'])
self.assertFailedTestCount(2, self.mtest_command + ['--no-suite', 'subprjmix'])
self.assertFailedTestCount(1, self.mtest_command + ['--suite', 'mainprj:fail'])
self.assertFailedTestCount(0, self.mtest_command + ['--suite', 'mainprj:success'])
self.assertFailedTestCount(2, self.mtest_command + ['--no-suite', 'mainprj:fail'])
self.assertFailedTestCount(3, self.mtest_command + ['--no-suite', 'mainprj:success'])
self.assertFailedTestCount(1, self.mtest_command + ['--suite', 'subprjfail:fail'])
self.assertFailedTestCount(0, self.mtest_command + ['--suite', 'subprjfail:success'])
self.assertFailedTestCount(2, self.mtest_command + ['--no-suite', 'subprjfail:fail'])
self.assertFailedTestCount(3, self.mtest_command + ['--no-suite', 'subprjfail:success'])
self.assertFailedTestCount(0, self.mtest_command + ['--suite', 'subprjsucc:fail'])
self.assertFailedTestCount(0, self.mtest_command + ['--suite', 'subprjsucc:success'])
self.assertFailedTestCount(3, self.mtest_command + ['--no-suite', 'subprjsucc:fail'])
self.assertFailedTestCount(3, self.mtest_command + ['--no-suite', 'subprjsucc:success'])
self.assertFailedTestCount(1, self.mtest_command + ['--suite', 'subprjmix:fail'])
self.assertFailedTestCount(0, self.mtest_command + ['--suite', 'subprjmix:success'])
self.assertFailedTestCount(2, self.mtest_command + ['--no-suite', 'subprjmix:fail'])
self.assertFailedTestCount(3, self.mtest_command + ['--no-suite', 'subprjmix:success'])
self.assertFailedTestCount(2, self.mtest_command + ['--suite', 'subprjfail', '--suite', 'subprjmix:fail'])
self.assertFailedTestCount(3, self.mtest_command + ['--suite', 'subprjfail', '--suite', 'subprjmix', '--suite', 'mainprj'])
self.assertFailedTestCount(2, self.mtest_command + ['--suite', 'subprjfail', '--suite', 'subprjmix', '--suite', 'mainprj', '--no-suite', 'subprjmix:fail'])
self.assertFailedTestCount(1, self.mtest_command + ['--suite', 'subprjfail', '--suite', 'subprjmix', '--suite', 'mainprj', '--no-suite', 'subprjmix:fail', 'mainprj-failing_test'])
self.assertFailedTestCount(1, self.mtest_command + ['--no-suite', 'subprjfail:fail', '--no-suite', 'subprjmix:fail'])
def _test_stds_impl(self, testdir, compiler, p):
lang_std = p + '_std'
# Check that all the listed -std=xxx options for this compiler work

@ -0,0 +1,13 @@
project('mainprj', 'c')
subproject('subprjfail')
subproject('subprjsucc')
subproject('subprjmix')
test('mainprj-failing_test',
executable('failing_test', 'failing_test.c'),
suite : 'fail')
test('mainprj-successful_test',
executable('successful_test', 'successful_test.c'),
suite : 'success')

@ -0,0 +1,5 @@
project('subprjfail', 'c')
test('subprjfail-failing_test',
executable('failing_test', 'failing_test.c'),
suite : 'fail')

@ -0,0 +1,9 @@
project('subprjmix', 'c')
test('subprjmix-failing_test',
executable('failing_test', 'failing_test.c'),
suite : 'fail')
test('subprjmix-successful_test',
executable('successful_test', 'successful_test.c'),
suite : 'success')

@ -0,0 +1,5 @@
project('subprjsucc', 'c')
test('subprjsucc-successful_test',
executable('successful_test', 'successful_test.c'),
suite : 'success')
Loading…
Cancel
Save