unittests: expect mtest logs to be utf-8

pull/8332/head
Paolo Bonzini 4 years ago committed by Jussi Pakkanen
parent 2b48d75c7e
commit 92134bac8d
  1. 14
      run_unittests.py

@ -2531,12 +2531,12 @@ class AllPlatformTests(BasePlatformTests):
self.build() self.build()
# Run tests without setup # Run tests without setup
self.run_tests() self.run_tests()
with open(os.path.join(self.logdir, 'testlog.txt')) as f: with open(os.path.join(self.logdir, 'testlog.txt'), encoding='utf-8') as f:
basic_log = f.read() basic_log = f.read()
# Run buggy test with setup that has env that will make it fail # Run buggy test with setup that has env that will make it fail
self.assertRaises(subprocess.CalledProcessError, self.assertRaises(subprocess.CalledProcessError,
self._run, self.mtest_command + ['--setup=valgrind']) self._run, self.mtest_command + ['--setup=valgrind'])
with open(os.path.join(self.logdir, 'testlog-valgrind.txt')) as f: with open(os.path.join(self.logdir, 'testlog-valgrind.txt'), encoding='utf-8') as f:
vg_log = f.read() vg_log = f.read()
self.assertFalse('TEST_ENV is set' in basic_log) self.assertFalse('TEST_ENV is set' in basic_log)
self.assertFalse('Memcheck' in basic_log) self.assertFalse('Memcheck' in basic_log)
@ -2556,12 +2556,12 @@ class AllPlatformTests(BasePlatformTests):
self._run(self.mtest_command + ['--setup=timeout', '--wrapper', shutil.which('valgrind')]) self._run(self.mtest_command + ['--setup=timeout', '--wrapper', shutil.which('valgrind')])
# Setup that skips test works # Setup that skips test works
self._run(self.mtest_command + ['--setup=good']) self._run(self.mtest_command + ['--setup=good'])
with open(os.path.join(self.logdir, 'testlog-good.txt')) as f: with open(os.path.join(self.logdir, 'testlog-good.txt'), encoding='utf-8') as f:
exclude_suites_log = f.read() exclude_suites_log = f.read()
self.assertFalse('buggy' in exclude_suites_log) self.assertFalse('buggy' in exclude_suites_log)
# --suite overrides add_test_setup(xclude_suites) # --suite overrides add_test_setup(xclude_suites)
self._run(self.mtest_command + ['--setup=good', '--suite', 'buggy']) self._run(self.mtest_command + ['--setup=good', '--suite', 'buggy'])
with open(os.path.join(self.logdir, 'testlog-good.txt')) as f: with open(os.path.join(self.logdir, 'testlog-good.txt'), encoding='utf-8') as f:
include_suites_log = f.read() include_suites_log = f.read()
self.assertTrue('buggy' in include_suites_log) self.assertTrue('buggy' in include_suites_log)
@ -2597,17 +2597,17 @@ class AllPlatformTests(BasePlatformTests):
# Run tests without --setup will cause the default setup to be used # Run tests without --setup will cause the default setup to be used
self.run_tests() self.run_tests()
with open(os.path.join(self.logdir, 'testlog.txt')) as f: with open(os.path.join(self.logdir, 'testlog.txt'), encoding='utf-8') as f:
default_log = f.read() default_log = f.read()
# Run tests with explicitly using the same setup that is set as default # Run tests with explicitly using the same setup that is set as default
self._run(self.mtest_command + ['--setup=mydefault']) self._run(self.mtest_command + ['--setup=mydefault'])
with open(os.path.join(self.logdir, 'testlog-mydefault.txt')) as f: with open(os.path.join(self.logdir, 'testlog-mydefault.txt'), encoding='utf-8') as f:
mydefault_log = f.read() mydefault_log = f.read()
# Run tests with another setup # Run tests with another setup
self._run(self.mtest_command + ['--setup=other']) self._run(self.mtest_command + ['--setup=other'])
with open(os.path.join(self.logdir, 'testlog-other.txt')) as f: with open(os.path.join(self.logdir, 'testlog-other.txt'), encoding='utf-8') as f:
other_log = f.read() other_log = f.read()
self.assertTrue('ENV_A is 1' in default_log) self.assertTrue('ENV_A is 1' in default_log)

Loading…
Cancel
Save