From c071f69ac2449ccf95641040976f8bdb9b251c5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mina=20Gali=C4=87?= Date: Wed, 13 Dec 2023 21:50:43 +0000 Subject: [PATCH] fix(tests): make cmd/devel/tests work on non-GNU 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 --- tests/unittests/cmd/devel/test_logs.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/tests/unittests/cmd/devel/test_logs.py b/tests/unittests/cmd/devel/test_logs.py index a40d53c6ef3..af77717c60b 100644 --- a/tests/unittests/cmd/devel/test_logs.py +++ b/tests/unittests/cmd/devel/test_logs.py @@ -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, ), @@ -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(