diff --git a/test/framework/easyblock.py b/test/framework/easyblock.py index c818dd7187..dc6daa1456 100644 --- a/test/framework/easyblock.py +++ b/test/framework/easyblock.py @@ -1571,6 +1571,7 @@ def test_extension_fake_modules(self): eb.builddir = config.build_path() eb.installdir = config.install_path() + update_build_option('trace', True) self.mock_stdout(True) eb.extensions_step(fetch=True) stdout = self.get_stdout() diff --git a/test/framework/filetools.py b/test/framework/filetools.py index dc781c1c7c..8eb5f452cf 100644 --- a/test/framework/filetools.py +++ b/test/framework/filetools.py @@ -2508,6 +2508,7 @@ def test_extract_file(self): build_options = { 'extended_dry_run': True, 'silent': False, + 'trace': True } init_config(build_options=build_options) @@ -3071,6 +3072,7 @@ def test_github_get_source_tarball_from_git(self): build_options = { 'extended_dry_run': True, 'silent': False, + 'trace': True, } init_config(build_options=build_options) diff --git a/test/framework/run.py b/test/framework/run.py index c7c4e0e66b..827d76b431 100644 --- a/test/framework/run.py +++ b/test/framework/run.py @@ -541,9 +541,6 @@ def test_run_shell_cmd_fail(self): def handler(signum, _): raise RuntimeError("Signal handler called with signal %s" % signum) - # disable trace output for this test (so stdout remains empty) - update_build_option('trace', False) - orig_sigalrm_handler = signal.getsignal(signal.SIGALRM) try: @@ -811,6 +808,8 @@ def test_run_shell_cmd_split_stderr(self): def test_run_cmd_trace(self): """Test run_cmd in trace mode, and with tracing disabled.""" + update_build_option('trace', True) + # use of run_cmd is deprecated, so we need to allow it here self.allow_deprecated_behaviour() @@ -837,8 +836,7 @@ def test_run_cmd_trace(self): regex = re.compile('\n'.join(pattern)) self.assertTrue(regex.search(stdout), "Pattern '%s' found in: %s" % (regex.pattern, stdout)) - init_config(build_options={'trace': False}) - + update_build_option('trace', False) self.mock_stdout(True) self.mock_stderr(True) (out, ec) = run_cmd("echo hello") @@ -851,9 +849,8 @@ def test_run_cmd_trace(self): self.assertTrue(stderr.strip().startswith("WARNING: Deprecated functionality")) self.assertEqual(stdout, '') - init_config(build_options={'trace': True}) - # also test with command that is fed input via stdin + update_build_option('trace', True) self.mock_stdout(True) self.mock_stderr(True) (out, ec) = run_cmd('cat', inp='hello') @@ -869,8 +866,7 @@ def test_run_cmd_trace(self): regex = re.compile('\n'.join(pattern)) self.assertTrue(regex.search(stdout), "Pattern '%s' found in: %s" % (regex.pattern, stdout)) - init_config(build_options={'trace': False}) - + update_build_option('trace', False) self.mock_stdout(True) self.mock_stderr(True) (out, ec) = run_cmd('cat', inp='hello') @@ -902,6 +898,8 @@ def test_run_cmd_trace(self): def test_run_shell_cmd_trace(self): """Test run_shell_cmd function in trace mode, and with tracing disabled.""" + update_build_option('trace', True) + pattern = [ r"^ >> running shell command:", r"\techo hello", @@ -911,7 +909,6 @@ def test_run_shell_cmd_trace(self): r" >> command completed: exit 0, ran in .*", ] - # trace output is enabled by default (since EasyBuild v5.0) self.mock_stdout(True) self.mock_stderr(True) res = run_shell_cmd("echo hello") @@ -926,7 +923,6 @@ def test_run_shell_cmd_trace(self): self.assertTrue(regex.search(stdout), "Pattern '%s' found in: %s" % (regex.pattern, stdout)) init_config(build_options={'trace': False}) - self.mock_stdout(True) self.mock_stderr(True) res = run_shell_cmd("echo hello") @@ -939,8 +935,6 @@ def test_run_shell_cmd_trace(self): self.assertEqual(stderr, '') self.assertEqual(stdout, '') - init_config(build_options={'trace': True}) - # trace output can be disabled on a per-command basis via 'hidden' option for trace in (True, False): init_config(build_options={'trace': trace}) @@ -1297,6 +1291,7 @@ def test_run_shell_cmd_qa_log(self): def test_run_cmd_qa_trace(self): """Test run_cmd under --trace""" + update_build_option('trace', True) # use of run_cmd/run_cmd_qa is deprecated, so we need to allow it here self.allow_deprecated_behaviour() @@ -1331,8 +1326,8 @@ def test_run_cmd_qa_trace(self): def test_run_shell_cmd_qa_trace(self): """Test run_shell_cmd with qa_patterns under --trace""" + update_build_option('trace', True) - # --trace is enabled by default self.mock_stdout(True) self.mock_stderr(True) run_shell_cmd("echo 'n: '; read n; seq 1 $n", qa_patterns=[('n: ', '5')]) @@ -1572,6 +1567,7 @@ def test_run_shell_cmd_dry_run(self): build_options = { 'extended_dry_run': True, 'silent': False, + 'trace': True, } init_config(build_options=build_options) @@ -1718,6 +1714,7 @@ def test_run_cmd_stream(self): def test_run_shell_cmd_stream(self): """Test use of run_shell_cmd with streaming output.""" + init_config(build_options={'trace': True}) self.mock_stdout(True) self.mock_stderr(True) cmd = '; '.join([ @@ -2059,9 +2056,6 @@ def post_run_shell_cmd_hook(cmd, *args, **kwargs): write_file(hooks_file, hooks_file_txt) update_build_option('hooks', hooks_file) - # disable trace output to make checking of generated output produced by hooks easier - update_build_option('trace', False) - with self.mocked_stdout_stderr(): run_cmd("make") stdout = self.get_stdout() @@ -2133,9 +2127,6 @@ def post_run_shell_cmd_hook(cmd, *args, **kwargs): write_file(hooks_file, hooks_file_txt) update_build_option('hooks', hooks_file) - # disable trace output to make checking of generated output produced by hooks easier - update_build_option('trace', False) - with self.mocked_stdout_stderr(): run_shell_cmd("make") stdout = self.get_stdout() diff --git a/test/framework/toolchain.py b/test/framework/toolchain.py index 11f5b5b0e3..7217b1bb14 100644 --- a/test/framework/toolchain.py +++ b/test/framework/toolchain.py @@ -2023,8 +2023,7 @@ def test_old_new_iccifort(self): scalapack_mt_shared_libs_fosscuda = scalapack_mt_static_libs_fosscuda.replace('.a', '.' + shlib_ext) tc = self.get_toolchain('fosscuda', version='2018a') - with self.mocked_stdout_stderr(): - tc.prepare() + tc.prepare() self.assertEqual(os.environ['BLAS_SHARED_LIBS'], blas_shared_libs_fosscuda) self.assertEqual(os.environ['BLAS_STATIC_LIBS'], blas_static_libs_fosscuda) self.assertEqual(os.environ['BLAS_MT_SHARED_LIBS'], blas_mt_shared_libs_fosscuda) @@ -2116,8 +2115,7 @@ def test_old_new_iccifort(self): self.modtool.purge() tc = self.get_toolchain('intel', version='2018a') - with self.mocked_stdout_stderr(): - tc.prepare() + tc.prepare() self.assertEqual(os.environ.get('BLAS_SHARED_LIBS', "(not set)"), blas_shared_libs_intel4) self.assertEqual(os.environ.get('BLAS_STATIC_LIBS', "(not set)"), blas_static_libs_intel4) self.assertEqual(os.environ.get('LAPACK_SHARED_LIBS', "(not set)"), blas_shared_libs_intel4) @@ -2130,22 +2128,19 @@ def test_old_new_iccifort(self): self.modtool.purge() tc = self.get_toolchain('intel', version='2012a') - with self.mocked_stdout_stderr(): - tc.prepare() + tc.prepare() self.assertEqual(os.environ.get('LIBBLAS_MT', "(not set)"), libblas_mt_intel3) self.assertIn(libscalack_intel3, os.environ['LIBSCALAPACK']) self.modtool.purge() tc = self.get_toolchain('intel', version='2018a') - with self.mocked_stdout_stderr(): - tc.prepare() + tc.prepare() self.assertEqual(os.environ.get('LIBBLAS_MT', "(not set)"), libblas_mt_intel4) self.assertIn(libscalack_intel4, os.environ['LIBSCALAPACK']) self.modtool.purge() tc = self.get_toolchain('intel', version='2012a') - with self.mocked_stdout_stderr(): - tc.prepare() + tc.prepare() self.assertEqual(os.environ.get('LIBBLAS_MT', "(not set)"), libblas_mt_intel3) self.assertIn(libscalack_intel3, os.environ['LIBSCALAPACK']) self.modtool.purge() @@ -2154,15 +2149,13 @@ def test_old_new_iccifort(self): tc = self.get_toolchain('intel', version='2018a') opts = {'i8': True} tc.set_options(opts) - with self.mocked_stdout_stderr(): - tc.prepare() + tc.prepare() self.assertIn(libscalack_intel4, os.environ['LIBSCALAPACK']) self.modtool.purge() tc = self.get_toolchain('fosscuda', version='2018a') tc.set_options({'openmp': True}) - with self.mocked_stdout_stderr(): - tc.prepare() + tc.prepare() self.assertEqual(os.environ['BLAS_SHARED_LIBS'], blas_shared_libs_fosscuda) self.assertEqual(os.environ['BLAS_STATIC_LIBS'], blas_static_libs_fosscuda) self.assertEqual(os.environ['BLAS_MT_SHARED_LIBS'], blas_mt_shared_libs_fosscuda) diff --git a/test/framework/toy_build.py b/test/framework/toy_build.py index 9e110ba09b..973f76ac03 100644 --- a/test/framework/toy_build.py +++ b/test/framework/toy_build.py @@ -52,7 +52,7 @@ from easybuild.framework.easyconfig.parser import EasyConfigParser from easybuild.main import main_with_hooks from easybuild.tools.build_log import EasyBuildError -from easybuild.tools.config import get_module_syntax, get_repositorypath +from easybuild.tools.config import get_module_syntax, get_repositorypath, update_build_option from easybuild.tools.environment import setvar from easybuild.tools.filetools import adjust_permissions, change_dir, copy_file, mkdir, move_file from easybuild.tools.filetools import read_file, remove_dir, remove_file, which, write_file @@ -159,7 +159,7 @@ def check_toy(self, installpath, outtxt, name='toy', version='0.0', versionprefi def _test_toy_build(self, extra_args=None, ec_file=None, tmpdir=None, verify=True, fails=False, verbose=True, raise_error=False, test_report=None, name='toy', versionsuffix='', testing=True, - raise_systemexit=False, force=True, test_report_regexs=None, debug=True): + raise_systemexit=False, force=True, test_report_regexs=None, debug=True, trace=True): """Perform a toy build.""" if extra_args is None: extra_args = [] @@ -175,6 +175,8 @@ def _test_toy_build(self, extra_args=None, ec_file=None, tmpdir=None, verify=Tru ] if debug: args.append('--debug') + if trace: + args.append('--trace') if force: args.append('--force') if tmpdir is not None: @@ -3142,6 +3144,7 @@ def test_toy_filter_rpath_sanity_libs(self): def test_toy_cuda_sanity_check(self): """Test the CUDA sanity check""" + update_build_option('trace', True) # Define the toy_ec file we want to use topdir = os.path.dirname(os.path.abspath(__file__)) toy_ec = os.path.join(topdir, 'easyconfigs', 'test_ecs', 't', 'toy', 'toy-0.0.eb') diff --git a/test/framework/utilities.py b/test/framework/utilities.py index 16a441f655..d17ef2da29 100644 --- a/test/framework/utilities.py +++ b/test/framework/utilities.py @@ -137,6 +137,8 @@ def setUp(self): # disable progress bars when running the tests, # since it messes with test suite progress output when test installations are performed os.environ['EASYBUILD_DISABLE_SHOW_PROGRESS_BAR'] = '1' + # Also disable trace output to keep stdout clean during tests + os.environ['EASYBUILD_DISABLE_TRACE'] = '1' # Store the environment as setup (including the above paths) for tests to restore self.orig_environ = copy.deepcopy(os.environ) @@ -487,25 +489,24 @@ def init_config(args=None, build_options=None, with_include=True, clear_caches=T eb_go = eboptions.parse_options(args=args, with_include=with_include) config.init(eb_go.options, eb_go.get_options_by_section('config')) - # initialize build options - if build_options is None: - build_options = {} - - default_build_options = { + # initialize default build options + options = { 'extended_dry_run': False, 'external_modules_metadata': ConfigObj(), 'local_var_naming_check': 'error', + 'show_progress_bar': False, 'silence_deprecation_warnings': eb_go.options.silence_deprecation_warnings, 'suffix_modules_path': GENERAL_CLASS, + 'trace': False, 'unit_testing_mode': True, 'valid_module_classes': module_classes(), 'valid_stops': [x[0] for x in EasyBlock.get_steps()], } - for key, def_option in default_build_options.items(): - if key not in build_options: - build_options[key] = def_option - config.init_build_options(build_options=build_options) + if build_options is not None: + options.update(build_options) + + config.init_build_options(build_options=options) return eb_go.options