aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lib/process.py27
-rw-r--r--test/lib/test_repo.py4
-rw-r--r--test/test_basic.py3
3 files changed, 22 insertions, 12 deletions
diff --git a/test/lib/process.py b/test/lib/process.py
index b32d093..3436280 100644
--- a/test/lib/process.py
+++ b/test/lib/process.py
@@ -87,8 +87,7 @@ class CmdLine:
return cls(outer.argv[0], *outer.argv[1:], *inner.argv, name=inner.process_name)
def run(self, *argv):
- result = Process.run(*self.argv, *argv)
- return result.returncode, result.stdout
+ return Process.run(*self.argv, *argv)
@contextmanager
def run_async(self, *argv):
@@ -119,20 +118,32 @@ class Process(subprocess.Popen):
@staticmethod
def _log_process_start(argv):
- if len(argv) > 1:
- logging.info('Executing binary %s with arguments: %s', argv[0], ' '.join(argv[1:]))
+ logging.info('Executing command: %s', argv)
+
+ @staticmethod
+ def _log_process_end(argv, ec, output):
+ log = logging.info
+ if ec:
+ log = logging.error
+ if ec:
+ log('Command %s exited with code %s', argv, ec)
else:
- logging.info('Executing binary %s', argv[0])
+ log('Command %s completed successfully', argv)
+ if output:
+ log('Output:\n%s', output)
@staticmethod
def run(*args, **kwargs):
argv = list(args)
Process._log_process_start(argv)
try:
- return subprocess.run(argv, check=True, **Process._COMMON_ARGS, **kwargs)
+ result = subprocess.run(argv, check=True, **Process._COMMON_ARGS, **kwargs)
+ ec, output = result.returncode, result.stdout
+ Process._log_process_end(argv, ec, output)
+ return output
except subprocess.CalledProcessError as e:
- logging.error('Command %s exited with code %s', e.cmd, e.returncode)
- logging.error('Output:\n%s', e.output)
+ ec, output = e.returncode, e.stdout
+ Process._log_process_end(argv, ec, output)
raise
def __init__(self, cmd_line, *args):
diff --git a/test/lib/test_repo.py b/test/lib/test_repo.py
index 820c73f..1922245 100644
--- a/test/lib/test_repo.py
+++ b/test/lib/test_repo.py
@@ -16,7 +16,7 @@ class Repo:
def __init__(self, path):
self.path = os.path.abspath(path)
os.makedirs(path, exist_ok=True)
- self.run('git', 'init', f'--initial-branch={Repo.BRANCH}')
+ self.run('git', 'init', '-q', f'--initial-branch={Repo.BRANCH}')
self.run('git', 'config', 'user.name', 'Test User')
self.run('git', 'config', 'user.email', 'test@example.com')
@@ -40,7 +40,7 @@ class TestRepo(Repo):
super().__init__(path)
shutil.copy(self.get_ci_script(), self.path)
self.run('git', 'add', '.')
- self.run('git', 'commit', '-m', 'add CI script')
+ self.run('git', 'commit', '-q', '-m', 'add CI script')
self.output_dir = os.path.join(self.path, TestRepo.OUTPUT_DIR)
os.makedirs(self.output_dir, exist_ok=True)
diff --git a/test/test_basic.py b/test/test_basic.py
index 7deca0f..3544a11 100644
--- a/test/test_basic.py
+++ b/test/test_basic.py
@@ -13,8 +13,7 @@ def test_server_and_workers_run(server_and_workers):
def test_client_version(client, version):
- ec, output = client.run('--version')
- assert ec == 0
+ output = client.run('--version')
assert output.endswith(version + '\n')