Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --skip-sanity-check option #4590

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading