diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2018-08-11 18:12:16 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2018-08-11 09:15:05 -0700 |
commit | fc90c4a331fe878373b8f2e571b2bf031840c0bb (patch) | |
tree | 912bf64cc3478643edbc0c074a990b8858663d5a /mesonbuild/mtest.py | |
parent | 43ececb036a6ca1911862d6fef1e49e822784f59 (diff) | |
download | meson-fc90c4a331fe878373b8f2e571b2bf031840c0bb.zip meson-fc90c4a331fe878373b8f2e571b2bf031840c0bb.tar.gz meson-fc90c4a331fe878373b8f2e571b2bf031840c0bb.tar.bz2 |
Print only custom env vars in the test log for each test
We still print the inherited env at the top of the test log because it
is useful when inspecting test results from a CI.
Fixes https://github.com/mesonbuild/meson/issues/3924
Diffstat (limited to 'mesonbuild/mtest.py')
-rw-r--r-- | mesonbuild/mtest.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index 8ebef04..3d3d2f5 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -20,7 +20,7 @@ import pickle from mesonbuild import build from mesonbuild import environment from mesonbuild.dependencies import ExternalProgram -from mesonbuild import mesonlib +from mesonbuild.mesonlib import substring_is_in_list, MesonException from mesonbuild import mlog import time, datetime, multiprocessing, json @@ -130,8 +130,11 @@ def returncode_to_status(retcode): signame = 'SIGinvalid' return '(exit status %d or signal %d %s)' % (retcode, signum, signame) +def env_tuple_to_str(env): + return ''.join(["%s='%s' " % (k, v) for k, v in env]) -class TestException(mesonlib.MesonException): + +class TestException(MesonException): pass @@ -162,7 +165,8 @@ class TestRun: if self.cmd is None: res += 'NONE\n' else: - res += '%s%s\n' % (''.join(["%s='%s' " % (k, v) for k, v in self.env.items()]), ' ' .join(self.cmd)) + test_only_env = set(self.env.items()) - set(os.environ.items()) + res += '{}{}\n'.format(env_tuple_to_str(test_only_env), ' '.join(self.cmd)) if self.stdo: res += '--- stdout ---\n' res += self.stdo @@ -266,7 +270,7 @@ class SingleTestRunner: if len(self.test.extra_paths) > 0: self.env['PATH'] = os.pathsep.join(self.test.extra_paths + ['']) + self.env['PATH'] - if mesonlib.substring_is_in_list('wine', cmd): + if substring_is_in_list('wine', cmd): wine_paths = ['Z:' + p for p in self.test.extra_paths] wine_path = ';'.join(wine_paths) # Don't accidentally end with an `;` because that will add the @@ -605,6 +609,8 @@ TIMEOUT: %4d self.logfile.write('Log of Meson test suite run on %s\n\n' % datetime.datetime.now().isoformat()) + inherit_env = env_tuple_to_str(os.environ.items()) + self.logfile.write('Inherited environment: {}\n\n'.format(inherit_env)) @staticmethod def get_wrapper(options): |