From 060b9c3d0e3d00658ee66f432d5616701cd15e65 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Thu, 4 Jan 2024 14:41:39 +0100 Subject: [PATCH] switch to run_shell_cmd in remaining test modules --- test/framework/package.py | 2 +- test/framework/repository.py | 6 +++--- .../sandbox/easybuild/easyblocks/generic/toy_extension.py | 4 ++-- test/framework/sandbox/easybuild/easyblocks/l/libtoy.py | 8 ++++---- test/framework/sandbox/easybuild/easyblocks/t/toy.py | 8 ++++---- test/framework/toy_build.py | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/test/framework/package.py b/test/framework/package.py index 38f24242a7..7298d6ecc9 100644 --- a/test/framework/package.py +++ b/test/framework/package.py @@ -44,7 +44,7 @@ FPM_OUTPUT_FILE = 'fpm_mocked.out' -# purposely using non-bash script, to detect issues with shebang line being ignored (run_cmd with shell=False) +# purposely using non-bash script, to detect issues with shebang line being ignored (run_shell_cmd with use_bash=False) MOCKED_FPM = """#!/usr/bin/env python import os, sys diff --git a/test/framework/repository.py b/test/framework/repository.py index a10cfeebf8..acc2749c55 100644 --- a/test/framework/repository.py +++ b/test/framework/repository.py @@ -43,7 +43,7 @@ from easybuild.tools.repository.hgrepo import HgRepository from easybuild.tools.repository.svnrepo import SvnRepository from easybuild.tools.repository.repository import init_repository -from easybuild.tools.run import run_cmd +from easybuild.tools.run import run_shell_cmd from easybuild.tools.version import VERSION @@ -95,10 +95,10 @@ def test_gitrepo(self): tmpdir = tempfile.mkdtemp() cmd = "cd %s && git clone --bare %s" % (tmpdir, test_repo_url) with self.mocked_stdout_stderr(): - _, ec = run_cmd(cmd, simple=False, log_all=False, log_ok=False) + res = run_shell_cmd(cmd, fail_on_error=False) # skip remainder of test if creating bare git repo didn't work - if ec == 0: + if res.exit_code == 0: repo = GitRepository(os.path.join(tmpdir, 'testrepository.git')) repo.init() toy_ec_file = os.path.join(os.path.dirname(__file__), 'easyconfigs', 'test_ecs', 't', 'toy', 'toy-0.0.eb') diff --git a/test/framework/sandbox/easybuild/easyblocks/generic/toy_extension.py b/test/framework/sandbox/easybuild/easyblocks/generic/toy_extension.py index 9c700cf779..de8c4c89c1 100644 --- a/test/framework/sandbox/easybuild/easyblocks/generic/toy_extension.py +++ b/test/framework/sandbox/easybuild/easyblocks/generic/toy_extension.py @@ -32,7 +32,7 @@ from easybuild.framework.extensioneasyblock import ExtensionEasyBlock from easybuild.easyblocks.toy import EB_toy, compose_toy_build_cmd from easybuild.tools.build_log import EasyBuildError -from easybuild.tools.run import run_cmd +from easybuild.tools.run import run_shell_cmd class Toy_Extension(ExtensionEasyBlock): @@ -67,7 +67,7 @@ def run(self, *args, **kwargs): EB_toy.build_step(self.master, name=self.name, cfg=self.cfg) if self.cfg['toy_ext_param']: - run_cmd(self.cfg['toy_ext_param']) + run_shell_cmd(self.cfg['toy_ext_param']) return self.module_generator.set_environment('TOY_EXT_%s' % self.name.upper().replace('-', '_'), self.name) diff --git a/test/framework/sandbox/easybuild/easyblocks/l/libtoy.py b/test/framework/sandbox/easybuild/easyblocks/l/libtoy.py index 50b573649a..2c0ba5a9e5 100644 --- a/test/framework/sandbox/easybuild/easyblocks/l/libtoy.py +++ b/test/framework/sandbox/easybuild/easyblocks/l/libtoy.py @@ -30,7 +30,7 @@ import os from easybuild.framework.easyblock import EasyBlock -from easybuild.tools.run import run_cmd +from easybuild.tools.run import run_shell_cmd from easybuild.tools.systemtools import get_shared_lib_ext SHLIB_EXT = get_shared_lib_ext() @@ -40,7 +40,7 @@ class EB_libtoy(EasyBlock): """Support for building/installing libtoy.""" def banned_linked_shared_libs(self): - default = '/thiswillnotbethere,libtoytoytoy.%s,toytoytoy' % SHLIB_EXT + default = f'/thiswillnotbethere,libtoytoytoy.{SHLIB_EXT},toytoytoy' return os.getenv('EB_LIBTOY_BANNED_SHARED_LIBS', default).split(',') def required_linked_shared_libs(self): @@ -53,8 +53,8 @@ def configure_step(self, name=None): def build_step(self, name=None, buildopts=None): """Build libtoy.""" - run_cmd('make') + run_shell_cmd('make') def install_step(self, name=None): """Install libtoy.""" - run_cmd('make install PREFIX="%s"' % self.installdir) + run_shell_cmd(f'make install PREFIX="{self.installdir}"') diff --git a/test/framework/sandbox/easybuild/easyblocks/t/toy.py b/test/framework/sandbox/easybuild/easyblocks/t/toy.py index c4614e3333..a1454435e3 100644 --- a/test/framework/sandbox/easybuild/easyblocks/t/toy.py +++ b/test/framework/sandbox/easybuild/easyblocks/t/toy.py @@ -38,7 +38,7 @@ from easybuild.tools.environment import setvar from easybuild.tools.filetools import mkdir, write_file from easybuild.tools.modules import get_software_root, get_software_version -from easybuild.tools.run import run_cmd +from easybuild.tools.run import run_shell_cmd def compose_toy_build_cmd(cfg, name, prebuildopts, buildopts): @@ -108,7 +108,7 @@ def configure_step(self, name=None, cfg=None): 'echo "Configured"', cfg['configopts'] ]) - run_cmd(cmd) + run_shell_cmd(cmd) if os.path.exists("%s.source" % name): os.rename('%s.source' % name, '%s.c' % name) @@ -124,8 +124,8 @@ def build_step(self, name=None, cfg=None): cmd = compose_toy_build_cmd(self.cfg, name, cfg['prebuildopts'], cfg['buildopts']) # purposely run build command without checking exit code; # we rely on this in test_toy_build_hooks - (out, ec) = run_cmd(cmd, log_ok=False, log_all=False) - if ec: + res = run_shell_cmd(cmd, fail_on_error=False) + if res.exit_code: print_warning("Command '%s' failed, but we'll ignore it..." % cmd) def install_step(self, name=None): diff --git a/test/framework/toy_build.py b/test/framework/toy_build.py index d4c7988534..ca53efc610 100644 --- a/test/framework/toy_build.py +++ b/test/framework/toy_build.py @@ -2963,7 +2963,7 @@ def test_toy_build_trace(self): r"^ >> running command:", r"\t\[started at: .*\]", r"\t\[working dir: .*\]", - r"\t\[output logged in .*\]", + r"\t\[output saved to .*\]", r"\tgcc toy.c -o toy\n" r'', ]),