Skip to content

Commit 2ffaa39

Browse files
authored
Merge pull request #5053 from Flamefire/disable-test-trace
Disable trace output by default in tests
2 parents 345d231 + 6ea3564 commit 2ffaa39

File tree

6 files changed

+36
-45
lines changed

6 files changed

+36
-45
lines changed

test/framework/easyblock.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,6 +1570,7 @@ def test_extension_fake_modules(self):
15701570
eb.builddir = config.build_path()
15711571
eb.installdir = config.install_path()
15721572

1573+
update_build_option('trace', True)
15731574
self.mock_stdout(True)
15741575
eb.extensions_step(fetch=True)
15751576
stdout = self.get_stdout()

test/framework/filetools.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2508,6 +2508,7 @@ def test_extract_file(self):
25082508
build_options = {
25092509
'extended_dry_run': True,
25102510
'silent': False,
2511+
'trace': True
25112512
}
25122513
init_config(build_options=build_options)
25132514

@@ -3071,6 +3072,7 @@ def test_github_get_source_tarball_from_git(self):
30713072
build_options = {
30723073
'extended_dry_run': True,
30733074
'silent': False,
3075+
'trace': True,
30743076
}
30753077
init_config(build_options=build_options)
30763078

test/framework/run.py

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -541,9 +541,6 @@ def test_run_shell_cmd_fail(self):
541541
def handler(signum, _):
542542
raise RuntimeError("Signal handler called with signal %s" % signum)
543543

544-
# disable trace output for this test (so stdout remains empty)
545-
update_build_option('trace', False)
546-
547544
orig_sigalrm_handler = signal.getsignal(signal.SIGALRM)
548545

549546
try:
@@ -811,6 +808,8 @@ def test_run_shell_cmd_split_stderr(self):
811808
def test_run_cmd_trace(self):
812809
"""Test run_cmd in trace mode, and with tracing disabled."""
813810

811+
update_build_option('trace', True)
812+
814813
# use of run_cmd is deprecated, so we need to allow it here
815814
self.allow_deprecated_behaviour()
816815

@@ -837,8 +836,7 @@ def test_run_cmd_trace(self):
837836
regex = re.compile('\n'.join(pattern))
838837
self.assertTrue(regex.search(stdout), "Pattern '%s' found in: %s" % (regex.pattern, stdout))
839838

840-
init_config(build_options={'trace': False})
841-
839+
update_build_option('trace', False)
842840
self.mock_stdout(True)
843841
self.mock_stderr(True)
844842
(out, ec) = run_cmd("echo hello")
@@ -851,9 +849,8 @@ def test_run_cmd_trace(self):
851849
self.assertTrue(stderr.strip().startswith("WARNING: Deprecated functionality"))
852850
self.assertEqual(stdout, '')
853851

854-
init_config(build_options={'trace': True})
855-
856852
# also test with command that is fed input via stdin
853+
update_build_option('trace', True)
857854
self.mock_stdout(True)
858855
self.mock_stderr(True)
859856
(out, ec) = run_cmd('cat', inp='hello')
@@ -869,8 +866,7 @@ def test_run_cmd_trace(self):
869866
regex = re.compile('\n'.join(pattern))
870867
self.assertTrue(regex.search(stdout), "Pattern '%s' found in: %s" % (regex.pattern, stdout))
871868

872-
init_config(build_options={'trace': False})
873-
869+
update_build_option('trace', False)
874870
self.mock_stdout(True)
875871
self.mock_stderr(True)
876872
(out, ec) = run_cmd('cat', inp='hello')
@@ -902,6 +898,8 @@ def test_run_cmd_trace(self):
902898
def test_run_shell_cmd_trace(self):
903899
"""Test run_shell_cmd function in trace mode, and with tracing disabled."""
904900

901+
update_build_option('trace', True)
902+
905903
pattern = [
906904
r"^ >> running shell command:",
907905
r"\techo hello",
@@ -911,7 +909,6 @@ def test_run_shell_cmd_trace(self):
911909
r" >> command completed: exit 0, ran in .*",
912910
]
913911

914-
# trace output is enabled by default (since EasyBuild v5.0)
915912
self.mock_stdout(True)
916913
self.mock_stderr(True)
917914
res = run_shell_cmd("echo hello")
@@ -926,7 +923,6 @@ def test_run_shell_cmd_trace(self):
926923
self.assertTrue(regex.search(stdout), "Pattern '%s' found in: %s" % (regex.pattern, stdout))
927924

928925
init_config(build_options={'trace': False})
929-
930926
self.mock_stdout(True)
931927
self.mock_stderr(True)
932928
res = run_shell_cmd("echo hello")
@@ -939,8 +935,6 @@ def test_run_shell_cmd_trace(self):
939935
self.assertEqual(stderr, '')
940936
self.assertEqual(stdout, '')
941937

942-
init_config(build_options={'trace': True})
943-
944938
# trace output can be disabled on a per-command basis via 'hidden' option
945939
for trace in (True, False):
946940
init_config(build_options={'trace': trace})
@@ -1297,6 +1291,7 @@ def test_run_shell_cmd_qa_log(self):
12971291

12981292
def test_run_cmd_qa_trace(self):
12991293
"""Test run_cmd under --trace"""
1294+
update_build_option('trace', True)
13001295

13011296
# use of run_cmd/run_cmd_qa is deprecated, so we need to allow it here
13021297
self.allow_deprecated_behaviour()
@@ -1331,8 +1326,8 @@ def test_run_cmd_qa_trace(self):
13311326

13321327
def test_run_shell_cmd_qa_trace(self):
13331328
"""Test run_shell_cmd with qa_patterns under --trace"""
1329+
update_build_option('trace', True)
13341330

1335-
# --trace is enabled by default
13361331
self.mock_stdout(True)
13371332
self.mock_stderr(True)
13381333
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):
15721567
build_options = {
15731568
'extended_dry_run': True,
15741569
'silent': False,
1570+
'trace': True,
15751571
}
15761572
init_config(build_options=build_options)
15771573

@@ -1718,6 +1714,7 @@ def test_run_cmd_stream(self):
17181714

17191715
def test_run_shell_cmd_stream(self):
17201716
"""Test use of run_shell_cmd with streaming output."""
1717+
init_config(build_options={'trace': True})
17211718
self.mock_stdout(True)
17221719
self.mock_stderr(True)
17231720
cmd = '; '.join([
@@ -2059,9 +2056,6 @@ def post_run_shell_cmd_hook(cmd, *args, **kwargs):
20592056
write_file(hooks_file, hooks_file_txt)
20602057
update_build_option('hooks', hooks_file)
20612058

2062-
# disable trace output to make checking of generated output produced by hooks easier
2063-
update_build_option('trace', False)
2064-
20652059
with self.mocked_stdout_stderr():
20662060
run_cmd("make")
20672061
stdout = self.get_stdout()
@@ -2133,9 +2127,6 @@ def post_run_shell_cmd_hook(cmd, *args, **kwargs):
21332127
write_file(hooks_file, hooks_file_txt)
21342128
update_build_option('hooks', hooks_file)
21352129

2136-
# disable trace output to make checking of generated output produced by hooks easier
2137-
update_build_option('trace', False)
2138-
21392130
with self.mocked_stdout_stderr():
21402131
run_shell_cmd("make")
21412132
stdout = self.get_stdout()

test/framework/toolchain.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,8 +2023,7 @@ def test_old_new_iccifort(self):
20232023
scalapack_mt_shared_libs_fosscuda = scalapack_mt_static_libs_fosscuda.replace('.a', '.' + shlib_ext)
20242024

20252025
tc = self.get_toolchain('fosscuda', version='2018a')
2026-
with self.mocked_stdout_stderr():
2027-
tc.prepare()
2026+
tc.prepare()
20282027
self.assertEqual(os.environ['BLAS_SHARED_LIBS'], blas_shared_libs_fosscuda)
20292028
self.assertEqual(os.environ['BLAS_STATIC_LIBS'], blas_static_libs_fosscuda)
20302029
self.assertEqual(os.environ['BLAS_MT_SHARED_LIBS'], blas_mt_shared_libs_fosscuda)
@@ -2116,8 +2115,7 @@ def test_old_new_iccifort(self):
21162115
self.modtool.purge()
21172116

21182117
tc = self.get_toolchain('intel', version='2018a')
2119-
with self.mocked_stdout_stderr():
2120-
tc.prepare()
2118+
tc.prepare()
21212119
self.assertEqual(os.environ.get('BLAS_SHARED_LIBS', "(not set)"), blas_shared_libs_intel4)
21222120
self.assertEqual(os.environ.get('BLAS_STATIC_LIBS', "(not set)"), blas_static_libs_intel4)
21232121
self.assertEqual(os.environ.get('LAPACK_SHARED_LIBS', "(not set)"), blas_shared_libs_intel4)
@@ -2130,22 +2128,19 @@ def test_old_new_iccifort(self):
21302128
self.modtool.purge()
21312129

21322130
tc = self.get_toolchain('intel', version='2012a')
2133-
with self.mocked_stdout_stderr():
2134-
tc.prepare()
2131+
tc.prepare()
21352132
self.assertEqual(os.environ.get('LIBBLAS_MT', "(not set)"), libblas_mt_intel3)
21362133
self.assertIn(libscalack_intel3, os.environ['LIBSCALAPACK'])
21372134
self.modtool.purge()
21382135

21392136
tc = self.get_toolchain('intel', version='2018a')
2140-
with self.mocked_stdout_stderr():
2141-
tc.prepare()
2137+
tc.prepare()
21422138
self.assertEqual(os.environ.get('LIBBLAS_MT', "(not set)"), libblas_mt_intel4)
21432139
self.assertIn(libscalack_intel4, os.environ['LIBSCALAPACK'])
21442140
self.modtool.purge()
21452141

21462142
tc = self.get_toolchain('intel', version='2012a')
2147-
with self.mocked_stdout_stderr():
2148-
tc.prepare()
2143+
tc.prepare()
21492144
self.assertEqual(os.environ.get('LIBBLAS_MT', "(not set)"), libblas_mt_intel3)
21502145
self.assertIn(libscalack_intel3, os.environ['LIBSCALAPACK'])
21512146
self.modtool.purge()
@@ -2154,15 +2149,13 @@ def test_old_new_iccifort(self):
21542149
tc = self.get_toolchain('intel', version='2018a')
21552150
opts = {'i8': True}
21562151
tc.set_options(opts)
2157-
with self.mocked_stdout_stderr():
2158-
tc.prepare()
2152+
tc.prepare()
21592153
self.assertIn(libscalack_intel4, os.environ['LIBSCALAPACK'])
21602154
self.modtool.purge()
21612155

21622156
tc = self.get_toolchain('fosscuda', version='2018a')
21632157
tc.set_options({'openmp': True})
2164-
with self.mocked_stdout_stderr():
2165-
tc.prepare()
2158+
tc.prepare()
21662159
self.assertEqual(os.environ['BLAS_SHARED_LIBS'], blas_shared_libs_fosscuda)
21672160
self.assertEqual(os.environ['BLAS_STATIC_LIBS'], blas_static_libs_fosscuda)
21682161
self.assertEqual(os.environ['BLAS_MT_SHARED_LIBS'], blas_mt_shared_libs_fosscuda)

test/framework/toy_build.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
from easybuild.framework.easyconfig.parser import EasyConfigParser
5353
from easybuild.main import main_with_hooks
5454
from easybuild.tools.build_log import EasyBuildError
55-
from easybuild.tools.config import get_module_syntax, get_repositorypath
55+
from easybuild.tools.config import get_module_syntax, get_repositorypath, update_build_option
5656
from easybuild.tools.environment import setvar
5757
from easybuild.tools.filetools import adjust_permissions, change_dir, copy_file, mkdir, move_file
5858
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
159159

160160
def _test_toy_build(self, extra_args=None, ec_file=None, tmpdir=None, verify=True, fails=False, verbose=True,
161161
raise_error=False, test_report=None, name='toy', versionsuffix='', testing=True,
162-
raise_systemexit=False, force=True, test_report_regexs=None, debug=True):
162+
raise_systemexit=False, force=True, test_report_regexs=None, debug=True, trace=True):
163163
"""Perform a toy build."""
164164
if extra_args is None:
165165
extra_args = []
@@ -175,6 +175,8 @@ def _test_toy_build(self, extra_args=None, ec_file=None, tmpdir=None, verify=Tru
175175
]
176176
if debug:
177177
args.append('--debug')
178+
if trace:
179+
args.append('--trace')
178180
if force:
179181
args.append('--force')
180182
if tmpdir is not None:
@@ -3142,6 +3144,7 @@ def test_toy_filter_rpath_sanity_libs(self):
31423144

31433145
def test_toy_cuda_sanity_check(self):
31443146
"""Test the CUDA sanity check"""
3147+
update_build_option('trace', True)
31453148
# Define the toy_ec file we want to use
31463149
topdir = os.path.dirname(os.path.abspath(__file__))
31473150
toy_ec = os.path.join(topdir, 'easyconfigs', 'test_ecs', 't', 'toy', 'toy-0.0.eb')

test/framework/utilities.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ def setUp(self):
137137
# disable progress bars when running the tests,
138138
# since it messes with test suite progress output when test installations are performed
139139
os.environ['EASYBUILD_DISABLE_SHOW_PROGRESS_BAR'] = '1'
140+
# Also disable trace output to keep stdout clean during tests
141+
os.environ['EASYBUILD_DISABLE_TRACE'] = '1'
140142

141143
# Store the environment as setup (including the above paths) for tests to restore
142144
self.orig_environ = copy.deepcopy(os.environ)
@@ -496,25 +498,24 @@ def init_config(args=None, build_options=None, with_include=True, clear_caches=T
496498
eb_go = eboptions.parse_options(args=args, with_include=with_include)
497499
config.init(eb_go.options, eb_go.get_options_by_section('config'))
498500

499-
# initialize build options
500-
if build_options is None:
501-
build_options = {}
502-
503-
default_build_options = {
501+
# initialize default build options
502+
options = {
504503
'extended_dry_run': False,
505504
'external_modules_metadata': ConfigObj(),
506505
'local_var_naming_check': 'error',
506+
'show_progress_bar': False,
507507
'silence_deprecation_warnings': eb_go.options.silence_deprecation_warnings,
508508
'suffix_modules_path': GENERAL_CLASS,
509+
'trace': False,
509510
'unit_testing_mode': True,
510511
'valid_module_classes': module_classes(),
511512
'valid_stops': [x[0] for x in EasyBlock.get_steps()],
512513
}
513-
for key, def_option in default_build_options.items():
514-
if key not in build_options:
515-
build_options[key] = def_option
516514

517-
config.init_build_options(build_options=build_options)
515+
if build_options is not None:
516+
options.update(build_options)
517+
518+
config.init_build_options(build_options=options)
518519

519520
return eb_go.options
520521

0 commit comments

Comments
 (0)