From a02b8ec2c0b55542da09432f759b71041a2f500c Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Thu, 1 Aug 2024 13:11:09 +0200 Subject: [PATCH 1/2] Add --skip-sanity-check option For some modules the sanity check command(s) fail when run in the build environment. This option can be used to still install it and investigate later. --- easybuild/framework/easyblock.py | 11 ++++++++--- easybuild/main.py | 8 +++++--- easybuild/tools/config.py | 1 + easybuild/tools/options.py | 3 +++ test/framework/options.py | 21 +++++++++++++++++++++ 5 files changed, 38 insertions(+), 6 deletions(-) diff --git a/easybuild/framework/easyblock.py b/easybuild/framework/easyblock.py index ce436f1841..c61963a4de 100644 --- a/easybuild/framework/easyblock.py +++ b/easybuild/framework/easyblock.py @@ -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'] @@ -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 @@ -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 diff --git a/easybuild/main.py b/easybuild/main.py index 451152f322..b6adc08559 100644 --- a/easybuild/main.py +++ b/easybuild/main.py @@ -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: diff --git a/easybuild/tools/config.py b/easybuild/tools/config.py index 6bec64764c..44362e6858 100644 --- a/easybuild/tools/config.py +++ b/easybuild/tools/config.py @@ -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', diff --git a/easybuild/tools/options.py b/easybuild/tools/options.py index df10ec859e..13338608c2 100644 --- a/easybuild/tools/options.py +++ b/easybuild/tools/options.py @@ -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), diff --git a/test/framework/options.py b/test/framework/options.py index a0ebac4324..3893befc01 100644 --- a/test/framework/options.py +++ b/test/framework/options.py @@ -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 ignore failing tests (--ignore-test-failure).""" + + 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.""" From 310d0c25aab8e6ca71956567f63665b269a650c9 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Tue, 13 Aug 2024 22:56:47 +0200 Subject: [PATCH 2/2] fix docstring in test_skip_sanity_check --- test/framework/options.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/framework/options.py b/test/framework/options.py index 3893befc01..056d77ed6b 100644 --- a/test/framework/options.py +++ b/test/framework/options.py @@ -444,7 +444,7 @@ def test_ignore_test_failure(self): self.assertErrorRegex(EasyBuildError, error_pattern, self.eb_main, args, do_build=True, raise_error=True) def test_skip_sanity_check(self): - """Test ignore failing tests (--ignore-test-failure).""" + """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')