Skip to content

Commit

Permalink
switch to run_shell_cmd in remaining test modules
Browse files Browse the repository at this point in the history
  • Loading branch information
boegel committed Jan 4, 2024
1 parent 14eb64f commit 060b9c3
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion test/framework/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/framework/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand Down
8 changes: 4 additions & 4 deletions test/framework/sandbox/easybuild/easyblocks/l/libtoy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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):
Expand All @@ -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}"')
8 changes: 4 additions & 4 deletions test/framework/sandbox/easybuild/easyblocks/t/toy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion test/framework/toy_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'',
]),
Expand Down

0 comments on commit 060b9c3

Please sign in to comment.