Skip to content

Commit 0429b6b

Browse files
author
ocaisa
authored
Merge pull request #3524 from Flamefire/skip_test_step
Add option to skip the unit tests (test_step)
2 parents f07fbde + bcafacd commit 0429b6b

File tree

7 files changed

+82
-6
lines changed

7 files changed

+82
-6
lines changed

easybuild/framework/easyblock.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,10 +2139,11 @@ def build_step(self):
21392139

21402140
def test_step(self):
21412141
"""Run unit tests provided by software (if any)."""
2142-
if self.cfg['runtest']:
2142+
unit_test_cmd = self.cfg['runtest']
2143+
if unit_test_cmd:
21432144

2144-
self.log.debug("Trying to execute %s as a command for running unit tests...")
2145-
(out, _) = run_cmd(self.cfg['runtest'], log_all=True, simple=False)
2145+
self.log.debug("Trying to execute %s as a command for running unit tests...", unit_test_cmd)
2146+
(out, _) = run_cmd(unit_test_cmd, log_all=True, simple=False)
21462147

21472148
return out
21482149

@@ -3310,6 +3311,10 @@ def build_and_install_one(ecdict, init_env):
33103311
_log.debug("Skip set to %s" % skip)
33113312
app.cfg['skip'] = skip
33123313

3314+
if build_option('skip_test_step'):
3315+
_log.debug('Adding test_step to skipped steps')
3316+
app.cfg.update('skipsteps', TEST_STEP, allow_duplicate=False)
3317+
33133318
# build easyconfig
33143319
errormsg = '(no error)'
33153320
# timing info

easybuild/tools/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ def mk_full_default_path(name, prefix=DEFAULT_PREFIX):
253253
'sequential',
254254
'set_gid_bit',
255255
'skip_test_cases',
256+
'skip_test_step',
256257
'generate_devel_module',
257258
'sticky_bit',
258259
'trace',

easybuild/tools/options.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ def override_options(self):
439439
'silence-deprecation-warnings': ("Silence specified deprecation warnings", 'strlist', 'extend', None),
440440
'sticky-bit': ("Set sticky bit on newly created directories", None, 'store_true', False),
441441
'skip-test-cases': ("Skip running test cases", None, 'store_true', False, 't'),
442+
'skip-test-step': ("Skip running the test step (e.g. unit tests)", None, 'store_true', False),
442443
'generate-devel-module': ("Generate a develop module file, implies --force if disabled",
443444
None, 'store_true', True),
444445
'sysroot': ("Location root directory of system, prefix for standard paths like /usr/lib and /usr/include",

test/framework/docs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def test_list_software(self):
256256
" * toy v0.0 (versionsuffix: '-deps'): system",
257257
" * toy v0.0 (versionsuffix: '-iter'): system",
258258
" * toy v0.0 (versionsuffix: '-multiple'): system",
259-
" * toy v0.0 (versionsuffix: '-test'): gompi/2018a",
259+
" * toy v0.0 (versionsuffix: '-test'): gompi/2018a, system",
260260
]
261261
txt = list_software(output_format='txt', detailed=True)
262262
lines = txt.split('\n')
@@ -278,7 +278,7 @@ def test_list_software(self):
278278
'``0.0`` ``-deps`` ``system`` ',
279279
'``0.0`` ``-iter`` ``system`` ',
280280
'``0.0`` ``-multiple`` ``system`` ',
281-
'``0.0`` ``-test`` ``gompi/2018a`` ',
281+
'``0.0`` ``-test`` ``gompi/2018a``, ``system``',
282282
'======= ============= ===========================',
283283
]
284284
txt = list_software(output_format='rst', detailed=True)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name = 'toy'
2+
version = '0.0'
3+
versionsuffix = '-test'
4+
5+
homepage = 'https://easybuilders.github.io/easybuild'
6+
description = "Toy C program, 100% toy."
7+
8+
toolchain = SYSTEM
9+
10+
sources = [SOURCE_TAR_GZ]
11+
checksums = [[
12+
'be662daa971a640e40be5c804d9d7d10', # default (MD5)
13+
'44332000aa33b99ad1e00cbd1a7da769220d74647060a10e807b916d73ea27bc', # default (SHA256)
14+
('adler32', '0x998410035'),
15+
('crc32', '0x1553842328'),
16+
('md5', 'be662daa971a640e40be5c804d9d7d10'),
17+
('sha1', 'f618096c52244539d0e89867405f573fdb0b55b0'),
18+
('size', 273),
19+
]]
20+
patches = [
21+
'toy-0.0_fix-silly-typo-in-printf-statement.patch',
22+
('toy-extra.txt', 'toy-0.0'),
23+
]
24+
25+
sanity_check_paths = {
26+
'files': [('bin/yot', 'bin/toy')],
27+
'dirs': ['bin'],
28+
}
29+
30+
runtest = "make_test dummy_cmd" # Provide some value which is unique enough to be checked for
31+
32+
postinstallcmds = ["echo TOY > %(installdir)s/README"]
33+
34+
moduleclass = 'tools'
35+
# trailing comment, leave this here, it may trigger bugs with extract_comments()

test/framework/filetools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2013,7 +2013,7 @@ def test_index_functions(self):
20132013
# test with specified path with and without trailing '/'s
20142014
for path in [test_ecs, test_ecs + '/', test_ecs + '//']:
20152015
index = ft.create_index(path)
2016-
self.assertEqual(len(index), 82)
2016+
self.assertEqual(len(index), 83)
20172017

20182018
expected = [
20192019
os.path.join('b', 'bzip2', 'bzip2-1.0.6-GCC-4.9.2.eb'),

test/framework/options.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,40 @@ def test_skip(self):
340340

341341
self.assertEqual(len(glob.glob(toy_mod_glob)), 1)
342342

343+
def test_skip_test_step(self):
344+
"""Test skipping testing the build (--skip-test-step)."""
345+
346+
topdir = os.path.abspath(os.path.dirname(__file__))
347+
toy_ec = os.path.join(topdir, 'easyconfigs', 'test_ecs', 't', 'toy', 'toy-0.0-test.eb')
348+
349+
# check log message without --skip-test-step
350+
args = [
351+
toy_ec,
352+
'--extended-dry-run',
353+
'--force',
354+
'--debug',
355+
]
356+
self.mock_stdout(True)
357+
outtxt = self.eb_main(args, do_build=True)
358+
self.mock_stdout(False)
359+
found_msg = "Running method test_step part of step test"
360+
found = re.search(found_msg, outtxt)
361+
test_run_msg = "execute make_test dummy_cmd as a command for running unit tests"
362+
self.assertTrue(found, "Message about test step being run is present, outtxt: %s" % outtxt)
363+
found = re.search(test_run_msg, outtxt)
364+
self.assertTrue(found, "Test execution command is present, outtxt: %s" % outtxt)
365+
366+
# And now with the argument
367+
args.append('--skip-test-step')
368+
self.mock_stdout(True)
369+
outtxt = self.eb_main(args, do_build=True)
370+
self.mock_stdout(False)
371+
found_msg = "Skipping test step"
372+
found = re.search(found_msg, outtxt)
373+
self.assertTrue(found, "Message about test step being skipped is present, outtxt: %s" % outtxt)
374+
found = re.search(test_run_msg, outtxt)
375+
self.assertFalse(found, "Test execution command is NOT present, outtxt: %s" % outtxt)
376+
343377
def test_job(self):
344378
"""Test submitting build as a job."""
345379

0 commit comments

Comments
 (0)