diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2018-08-11 18:12:16 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2018-08-24 03:22:27 +0530 |
commit | bea2b3a3d13fe43397caef8437344ae89b624769 (patch) | |
tree | 65a5af2ac6a37e62b40e993bf7bd3a116c3de6a8 | |
parent | 269439a2fff55ec7a7989ef67d10f22c77f68e2c (diff) | |
download | meson-bea2b3a3d13fe43397caef8437344ae89b624769.zip meson-bea2b3a3d13fe43397caef8437344ae89b624769.tar.gz meson-bea2b3a3d13fe43397caef8437344ae89b624769.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
-rw-r--r-- | mesonbuild/mtest.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index 855154f..2f2daad 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 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 @@ -608,6 +612,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): |