Skip to content

Commit

Permalink
[Resolves #1383] Simplify stderr test for cmd hook (#1387)
Browse files Browse the repository at this point in the history
The old test expected `/bin/sh` to write Dash's error message. This works on
Ubuntu 20.

It old test failed  when `/bin/sh` pointed to `/bin/bash`. This happens on
macOS.

The new test no longer depends on system-defined side effects of a missing
command. It just writes to the standard error stream and checks that the same
text comes out.
  • Loading branch information
iainelder authored Nov 24, 2023
1 parent 17217e5 commit 0d05f7f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions tests/test_hooks/test_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,10 @@ def test_hook_writes_to_stdout(stack, capfd):


def test_hook_writes_to_stderr(stack, capfd):
with pytest.raises(Exception):
Cmd("missing_command", stack).run()
Cmd("echo hello >&2", stack).run()
cap = capfd.readouterr()
assert cap.out.strip() == ""
assert cap.err.strip() == "/bin/sh: 1: missing_command: not found"
assert cap.err.strip() == "hello"


def test_default_shell_is_sh(stack, capfd):
Expand Down

0 comments on commit 0d05f7f

Please sign in to comment.