Skip to content

Commit

Permalink
Merge pull request #4590 from Flamefire/skip-sanity-check
Browse files Browse the repository at this point in the history
Add `--skip-sanity-check` option
  • Loading branch information
boegel authored Aug 13, 2024
2 parents 60eebbb + 310d0c2 commit fe6469e
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 6 deletions.
11 changes: 8 additions & 3 deletions easybuild/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -3901,12 +3901,13 @@ def update_config_template_run_step(self):
self.cfg.generate_template_values()

def skip_step(self, step, skippable):
"""Dedice whether or not to skip the specified step."""
"""Decide whether or not to skip the specified step."""
skip = False
force = build_option('force')
module_only = build_option('module_only') or self.cfg['module_only']
sanity_check_only = build_option('sanity_check_only')
skip_extensions = build_option('skip_extensions')
skip_sanity_check = build_option('skip_sanity_check')
skip_test_step = build_option('skip_test_step')
skipsteps = self.cfg['skipsteps']

Expand Down Expand Up @@ -3934,6 +3935,10 @@ def skip_step(self, step, skippable):
self.log.info("Skipping %s step because of sanity-check-only mode", step)
skip = True

elif skip_sanity_check and step == SANITYCHECK_STEP:
self.log.info("Skipping %s step as request via skip-sanity-check", step)
skip = True

elif skip_extensions and step == EXTENSIONS_STEP:
self.log.info("Skipping %s step as requested via skip-extensions", step)
skip = True
Expand All @@ -3944,9 +3949,9 @@ def skip_step(self, step, skippable):

else:
msg = "Not skipping %s step (skippable: %s, skip: %s, skipsteps: %s, module_only: %s, force: %s, "
msg += "sanity_check_only: %s, skip_extensions: %s, skip_test_step: %s)"
msg += "sanity_check_only: %s, skip_extensions: %s, skip_test_step: %s, skip_sanity_check: %s)"
self.log.debug(msg, step, skippable, self.skip, skipsteps, module_only, force,
sanity_check_only, skip_extensions, skip_test_step)
sanity_check_only, skip_extensions, skip_test_step, skip_sanity_check)

return skip

Expand Down
8 changes: 5 additions & 3 deletions easybuild/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,9 +727,11 @@ def main(args=None, logfile=None, do_build=None, testing=False, modtool=None, pr
if options.ignore_test_failure:
raise EasyBuildError("Found both ignore-test-failure and skip-test-step enabled. "
"Please use only one of them.")
else:
print_warning("Will not run the test step as requested via skip-test-step. "
"Consider using ignore-test-failure instead and verify the results afterwards")
print_warning("Will not run the test step as requested via skip-test-step. "
"Consider using ignore-test-failure instead and verify the results afterwards")
if options.skip_sanity_check and options.sanity_check_only:
raise EasyBuildError("Found both skip-sanity-check and sanity-check-only enabled. "
"Please use only one of them.")

# if EasyStack file is provided, parse it, and loop over the items in the EasyStack file
if options.easystack:
Expand Down
1 change: 1 addition & 0 deletions easybuild/tools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ def mk_full_default_path(name, prefix=DEFAULT_PREFIX):
'set_gid_bit',
'silence_hook_trigger',
'skip_extensions',
'skip_sanity_check',
'skip_test_cases',
'skip_test_step',
'sticky_bit',
Expand Down
3 changes: 3 additions & 0 deletions easybuild/tools/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,9 @@ def override_options(self):
'silence-hook-trigger': ("Suppress printing of debug message every time a hook is triggered",
None, 'store_true', False),
'skip-extensions': ("Skip installation of extensions", None, 'store_true', False),
'skip-sanity-check': ("Skip running the sanity check step "
"(e.g. testing for installed files or running basic commands)",
None, 'store_true', False),
'skip-test-cases': ("Skip running test cases", None, 'store_true', False, 't'),
'skip-test-step': ("Skip running the test step (e.g. unit tests)", None, 'store_true', False),
'sticky-bit': ("Set sticky bit on newly created directories", None, 'store_true', False),
Expand Down
21 changes: 21 additions & 0 deletions test/framework/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,27 @@ def test_ignore_test_failure(self):
error_pattern = 'Found both ignore-test-failure and skip-test-step enabled'
self.assertErrorRegex(EasyBuildError, error_pattern, self.eb_main, args, do_build=True, raise_error=True)

def test_skip_sanity_check(self):
"""Test skipping of sanity check step (--skip-sanity-check)."""

topdir = os.path.abspath(os.path.dirname(__file__))
toy_ec = os.path.join(topdir, 'easyconfigs', 'test_ecs', 't', 'toy', 'toy-0.0.eb')
test_ec = os.path.join(self.test_prefix, 'test.eb')
write_file(test_ec, read_file(toy_ec) + "\nsanity_check_commands = ['this_will_fail']")

args = [test_ec, '--rebuild']
err_msg = "Sanity check failed"
self.assertErrorRegex(EasyBuildError, err_msg, self.eb_main, args, do_build=True, raise_error=True)

args.append('--skip-sanity-check')
outtext = self.eb_main(args, do_build=True, raise_error=True)
self.assertNotIn('sanity checking...', outtext)

# Passing skip and only options is disallowed
args.append('--sanity-check-only')
error_pattern = 'Found both skip-sanity-check and sanity-check-only enabled'
self.assertErrorRegex(EasyBuildError, error_pattern, self.eb_main, args, do_build=True, raise_error=True)

def test_job(self):
"""Test submitting build as a job."""

Expand Down

0 comments on commit fe6469e

Please sign in to comment.