Skip to content

Commit

Permalink
Add some test setup selection tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
trhd committed Feb 25, 2018
1 parent 060560b commit 473dc80
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 0 deletions.
25 changes: 25 additions & 0 deletions run_unittests.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,31 @@ def test_testsetups(self):
# Setup with only a timeout works
self._run(self.mtest_command + ['--setup=timeout'])

def test_testsetup_selection(self):
testdir = os.path.join(self.unit_test_dir, '13 testsetup selection')
self.init(testdir)
self.build()

# Run tests without setup
self.run_tests()

self.assertRaises(subprocess.CalledProcessError, self._run, self.mtest_command + ['--setup=missingfromfoo'])
self._run(self.mtest_command + ['--setup=missingfromfoo', '--no-suite=foo:'])

self._run(self.mtest_command + ['--setup=worksforall'])
self._run(self.mtest_command + ['--setup=main:worksforall'])

self.assertRaises(subprocess.CalledProcessError, self._run,
self.mtest_command + ['--setup=onlyinbar'])
self.assertRaises(subprocess.CalledProcessError, self._run,
self.mtest_command + ['--setup=onlyinbar', '--no-suite=main:'])
self._run(self.mtest_command + ['--setup=onlyinbar', '--no-suite=main:', '--no-suite=foo:'])
self._run(self.mtest_command + ['--setup=bar:onlyinbar'])
self.assertRaises(subprocess.CalledProcessError, self._run,
self.mtest_command + ['--setup=foo:onlyinbar'])
self.assertRaises(subprocess.CalledProcessError, self._run,
self.mtest_command + ['--setup=main:onlyinbar'])

def assertFailedTestCount(self, failure_count, command):
try:
self._run(command)
Expand Down
3 changes: 3 additions & 0 deletions test cases/unit/13 testsetup selection/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int main() {
return 0;
}
10 changes: 10 additions & 0 deletions test cases/unit/13 testsetup selection/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
project('main', 'c')

main = executable('main', 'main.c')
test('Test main', main)

add_test_setup('worksforall')
add_test_setup('missingfromfoo')

subproject('foo')
subproject('bar')
3 changes: 3 additions & 0 deletions test cases/unit/13 testsetup selection/subprojects/bar/bar.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int main() {
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
project('bar', 'c')
bar = executable('bar', 'bar.c')
test('Test bar', bar)
add_test_setup('onlyinbar')
add_test_setup('worksforall')
add_test_setup('missingfromfoo')
3 changes: 3 additions & 0 deletions test cases/unit/13 testsetup selection/subprojects/foo/foo.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int main() {
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
project('foo', 'c')
foo = executable('foo', 'foo.c')
test('Test foo', foo)
add_test_setup('worksforall')

0 comments on commit 473dc80

Please sign in to comment.