aboutsummaryrefslogtreecommitdiff
path: root/run_unittests.py
diff options
context:
space:
mode:
authorStian Selnes <stian@pexip.com>2018-11-12 10:33:49 +0100
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2018-11-12 16:23:59 +0530
commit0821462ce382541e120d8d6cfc1a3224a492b275 (patch)
tree67ca584e5f619ab6beabdc67c930f83ceb7df658 /run_unittests.py
parent50b2ef7354b503ae62abd504cdce938c390b358f (diff)
downloadmeson-0821462ce382541e120d8d6cfc1a3224a492b275.zip
meson-0821462ce382541e120d8d6cfc1a3224a492b275.tar.gz
meson-0821462ce382541e120d8d6cfc1a3224a492b275.tar.bz2
Add kwarg is_default to add_test_setup()
is_default may be used to set the name of the test setup that will be used by default whenever the option --setup is not given. Fixes #4430
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-xrun_unittests.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/run_unittests.py b/run_unittests.py
index 298e249..d3545db 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -1464,6 +1464,38 @@ class AllPlatformTests(BasePlatformTests):
self.assertRaises(subprocess.CalledProcessError, self._run,
self.mtest_command + ['--setup=main:onlyinbar'])
+ def test_testsetup_default(self):
+ testdir = os.path.join(self.unit_test_dir, '47 testsetup default')
+ self.init(testdir)
+ self.build()
+
+ # Run tests without --setup will cause the default setup to be used
+ self.run_tests()
+ with open(os.path.join(self.logdir, 'testlog.txt')) as f:
+ default_log = f.read()
+
+ # Run tests with explicitly using the same setup that is set as default
+ self._run(self.mtest_command + ['--setup=mydefault'])
+ with open(os.path.join(self.logdir, 'testlog-mydefault.txt')) as f:
+ mydefault_log = f.read()
+
+ # Run tests with another setup
+ self._run(self.mtest_command + ['--setup=other'])
+ with open(os.path.join(self.logdir, 'testlog-other.txt')) as f:
+ other_log = f.read()
+
+ self.assertTrue('ENV_A is 1' in default_log)
+ self.assertTrue('ENV_B is 2' in default_log)
+ self.assertTrue('ENV_C is 2' in default_log)
+
+ self.assertTrue('ENV_A is 1' in mydefault_log)
+ self.assertTrue('ENV_B is 2' in mydefault_log)
+ self.assertTrue('ENV_C is 2' in mydefault_log)
+
+ self.assertTrue('ENV_A is 1' in other_log)
+ self.assertTrue('ENV_B is 3' in other_log)
+ self.assertTrue('ENV_C is 2' in other_log)
+
def assertFailedTestCount(self, failure_count, command):
try:
self._run(command)