diff --git a/test-suite b/test-suite index b2d06db..8aee7e5 100755 --- a/test-suite +++ b/test-suite @@ -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)}")