Skip to content

Commit

Permalink
fix(tests): make cmd/devel/tests work on non-GNU
Browse files Browse the repository at this point in the history
The tests were tied to the exact output of GNU ls.
Tests were failing on *BSD.
Fix them by using a different platform independent command.
POSIX sh should work everywhere.

Sponsored by: The FreeBSD Foundation
  • Loading branch information
igalic authored and holmanb committed Dec 13, 2023
1 parent e90cb10 commit c071f69
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions tests/unittests/cmd/devel/test_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,14 @@ def fake_subprocess_call(cmd, stdout=None, stderr=None):
"cloud-init? more like cloud-innit!\n",
),
(
["ls", "/nonexistent-directory"],
["sh", "-c", "echo test 1>&2; exit 42"],
(
"Unexpected error while running command.\n"
"Command: ['ls', '/nonexistent-directory']\n"
"Exit code: 2\n"
"Command: ['sh', '-c', 'echo test 1>&2; exit 42']\n"
"Exit code: 42\n"
"Reason: -\n"
"Stdout: \n"
"Stderr: ls: cannot access '/nonexistent-directory': "
"No such file or directory"
"Stderr: test"
),
None,
),
Expand Down Expand Up @@ -270,13 +269,7 @@ def test_write_command_output_to_file(
"cmd, expected_file_contents",
[
(["echo", "cloud-init, shmoud-init"], "cloud-init, shmoud-init\n"),
(
["ls", "/nonexistent-directory"],
(
"ls: cannot access '/nonexistent-directory': "
"No such file or directory\n"
),
),
(["sh", "-c", "echo test 1>&2; exit 42"], "test\n"),
],
)
def test_stream_command_output_to_file(
Expand Down

0 comments on commit c071f69

Please sign in to comment.