diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2020-11-30 12:08:57 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2021-01-04 12:15:41 -0800 |
commit | 0574134bf884858632678b1d84db7e4ca483f603 (patch) | |
tree | 5c6de8f08b844a037adc236e64da1441c7efad65 /run_unittests.py | |
parent | 67ee65f47ed0872040fcce3db68a34005af9a03d (diff) | |
download | meson-0574134bf884858632678b1d84db7e4ca483f603.zip meson-0574134bf884858632678b1d84db7e4ca483f603.tar.gz meson-0574134bf884858632678b1d84db7e4ca483f603.tar.bz2 |
run_unittests: Make test_command_line safe witn inprocess
This is pretty important to be able to debug the test, as it's huge and
really should be a test split into subtests.
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-x | run_unittests.py | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/run_unittests.py b/run_unittests.py index 4b14a87..2219ded 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -3632,10 +3632,10 @@ class AllPlatformTests(BasePlatformTests): def test_conflicting_d_dash_option(self): testdir = os.path.join(self.unit_test_dir, '37 mixed command line args') - with self.assertRaises(subprocess.CalledProcessError) as e: + with self.assertRaises((subprocess.CalledProcessError, RuntimeError)) as e: self.init(testdir, extra_args=['-Dbindir=foo', '--bindir=bar']) # Just to ensure that we caught the correct error - self.assertIn('passed as both', e.stderr) + self.assertIn('as both', e.stderr) def _test_same_option_twice(self, arg, args): testdir = os.path.join(self.unit_test_dir, '37 mixed command line args') @@ -3712,15 +3712,21 @@ class AllPlatformTests(BasePlatformTests): self.wipe() # Mixing --option and -Doption is forbidden - with self.assertRaises(subprocess.CalledProcessError) as cm: + with self.assertRaises((subprocess.CalledProcessError, RuntimeError)) as cm: self.init(testdir, extra_args=['--warnlevel=1', '-Dwarning_level=3']) - self.assertNotEqual(0, cm.exception.returncode) - self.assertIn('as both', cm.exception.output) + if isinstance(cm.exception, subprocess.CalledProcessError): + self.assertNotEqual(0, cm.exception.returncode) + self.assertIn('as both', cm.exception.output) + else: + self.assertIn('as both', str(cm.exception)) self.init(testdir) - with self.assertRaises(subprocess.CalledProcessError) as cm: + with self.assertRaises((subprocess.CalledProcessError, RuntimeError)) as cm: self.setconf(['--warnlevel=1', '-Dwarning_level=3']) - self.assertNotEqual(0, cm.exception.returncode) - self.assertIn('as both', cm.exception.output) + if isinstance(cm.exception, subprocess.CalledProcessError): + self.assertNotEqual(0, cm.exception.returncode) + self.assertIn('as both', cm.exception.output) + else: + self.assertIn('as both', str(cm.exception)) self.wipe() # --default-library should override default value from project() @@ -3743,15 +3749,22 @@ class AllPlatformTests(BasePlatformTests): self.wipe() # Should fail on malformed option - with self.assertRaises(subprocess.CalledProcessError) as cm: + msg = "Option 'foo' must have a value separated by equals sign." + with self.assertRaises((subprocess.CalledProcessError, RuntimeError)) as cm: self.init(testdir, extra_args=['-Dfoo']) - self.assertNotEqual(0, cm.exception.returncode) - self.assertIn('Option \'foo\' must have a value separated by equals sign.', cm.exception.output) + if isinstance(cm.exception, subprocess.CalledProcessError): + self.assertNotEqual(0, cm.exception.returncode) + self.assertIn(msg, cm.exception.output) + else: + self.assertIn(msg, str(cm.exception)) self.init(testdir) - with self.assertRaises(subprocess.CalledProcessError) as cm: + with self.assertRaises((subprocess.CalledProcessError, RuntimeError)) as cm: self.setconf('-Dfoo') - self.assertNotEqual(0, cm.exception.returncode) - self.assertIn('Option \'foo\' must have a value separated by equals sign.', cm.exception.output) + if isinstance(cm.exception, subprocess.CalledProcessError): + self.assertNotEqual(0, cm.exception.returncode) + self.assertIn(msg, cm.exception.output) + else: + self.assertIn(msg, str(cm.exception)) self.wipe() # It is not an error to set wrong option for unknown subprojects or |