diff options
author | Lars Wirzenius <liw@liw.fi> | 2024-01-10 16:39:26 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2024-01-10 17:38:05 +0200 |
commit | 6083f087d7eeb278b73c82c002078c2fe3cd2999 (patch) | |
tree | 9276e51d6322be0a3676e9eadf297e2b4ff29003 | |
parent | f660492c48f6d9b3acf80ab38aad19694bf8eb39 (diff) | |
download | radicle-native-ci-6083f087d7eeb278b73c82c002078c2fe3cd2999.tar.gz |
tests: no stdin for adapter
Signed-off-by: Lars Wirzenius <liw@liw.fi>
-rwxr-xr-x | test-suite | 27 |
1 files changed, 25 insertions, 2 deletions
@@ -172,6 +172,15 @@ class Suite: error = resps[1]["result"]["error"] assert commit in error + def test_no_message(self): + git = self._create_git_repo("no-message") + self._create_valid_native_yaml(git, "echo hello world") + ci = self._create_ci() + exit, resps, stderr = ci.run_without_request() + + assert exit != 0 + assert len(resps) == 0 + def test_malformed_trigger(self): git = self._create_git_repo("malformed-trigger") self._create_valid_native_yaml(git, "echo hello world") @@ -334,6 +343,20 @@ class NativeCI: resps = [json.loads(line.strip()) for line in p.stdout.splitlines()] return p.returncode, resps, p.stderr + def run_without_request(self): + p = run( + [ + "cargo", + "run", + "-q", + ], + stdin=subprocess.DEVNULL, + env=dict(self.env), + may_fail=True, + ) + resps = [json.loads(line.strip()) for line in p.stdout.splitlines()] + return p.returncode, resps, p.stderr + def debug(msg): logging.debug(msg) @@ -348,14 +371,14 @@ def die(msg, exc_info=None): sys.exit(1) -def run(argv, env=None, cwd=None, input=None, may_fail=False): +def run(argv, env=None, cwd=None, stdin=None, input=None, may_fail=False): debug(f"run {argv} with env={env}, cwd={cwd} input={input!r}") if env is not None: for name, value in os.environ.items(): if name not in env: env[name] = value p = subprocess.run( - argv, capture_output=True, env=env, cwd=cwd, input=input, text=True + argv, capture_output=True, env=env, cwd=cwd, stdin=stdin, input=input, text=True ) debug(f"stdout:\n{indent(p.stdout)}") |