Skip to content

Commit

Permalink
add test for non-fail command execution in run_cmd
Browse files Browse the repository at this point in the history
In c125f1e a behavior change was introduced, leading to crashes in
case a command does not exist. This test ensures that even non-existing
commands are properly handled under fail=False.

Signed-off-by: Felix Moessbauer <[email protected]>
Signed-off-by: Jan Kiszka <[email protected]>
  • Loading branch information
fmoessbauer authored and jan-kiszka committed Dec 5, 2024
1 parent bbbc087 commit e23df24
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import subprocess
import pytest
from kas import kas
from kas.libkas import TaskExecError, KasUserError
from kas.libkas import TaskExecError, KasUserError, run_cmd
from kas.attestation import file_digest_slow


Expand Down Expand Up @@ -418,3 +418,11 @@ def test_ff_merges(monkeykas, tmpdir):
with open('kas.yml', 'w') as f:
yaml.dump(kas_input, f)
kas.kas(['checkout', 'kas.yml'])


def test_cmd_not_found(monkeykas, tmpdir):
cmd = ['/usr/bin/kas-not-exists']
ret, _ = run_cmd(cmd, tmpdir, os.environ, fail=False)
assert ret != 0
with pytest.raises(FileNotFoundError):
run_cmd(cmd, tmpdir, os.environ, fail=True)

0 comments on commit e23df24

Please sign in to comment.