소스 검색

Add echo in run_script()

Bobholamovic 2 년 전
부모
커밋
a1f7747eb9
2개의 변경된 파일5개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 1
      tests/test_tutorials.py
  2. 3 1
      tests/testing_utils.py

+ 2 - 1
tests/test_tutorials.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
 

+ 3 - 1
tests/testing_utils.py

@@ -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)