Add echo in run_script()

own
Bobholamovic 2 years ago
parent 6619a4e6f8
commit a1f7747eb9
  1. 3
      tests/test_tutorials.py
  2. 4
      tests/testing_utils.py

@ -62,7 +62,8 @@ class TestTutorial(CpuCommonTest):
raise ValueError(
f"{script_name} should be directly contained in {cls.SUBDIR}"
)
setattr(cls, 'test_' + script_name, _test_tutorial(script_name))
setattr(cls, 'test_' + osp.splitext(script_name)[0],
_test_tutorial(script_name))
return cls

@ -24,13 +24,15 @@ import paddle
__all__ = ['CommonTest', 'CpuCommonTest', 'run_script']
def run_script(cmd, silent=True, wd=None, timeout=None):
def run_script(cmd, silent=True, wd=None, timeout=None, echo=True):
# XXX: This function is not safe!!!
cfg = dict(check=True, shell=True, timeout=timeout)
if silent:
cfg['stdout'] = subprocess.DEVNULL
if wd is not None:
cmd = f"cd {wd} && {cmd}"
if echo:
print(cmd)
return subprocess.run(cmd, **cfg)

Loading…
Cancel
Save