From e97a966b466af30f55d71fde795618b90524bf84 Mon Sep 17 00:00:00 2001 From: Rayyan Ansari Date: Thu, 1 Dec 2022 17:59:08 +0000 Subject: [PATCH] testsuite: archiver: fix test_create_paths_from_command on Windows On Windows, `echo` is a shell builtin and can only output one line at a time. A batch file that outputs the filenames is instead used as the command. --- src/borg/testsuite/archiver/create_cmd.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/borg/testsuite/archiver/create_cmd.py b/src/borg/testsuite/archiver/create_cmd.py index d2e93f818..fdedc5177 100644 --- a/src/borg/testsuite/archiver/create_cmd.py +++ b/src/borg/testsuite/archiver/create_cmd.py @@ -243,9 +243,20 @@ def test_create_paths_from_command(self): self.create_regular_file("file4", size=1024 * 80) input_data = "input/file1\ninput/file2\ninput/file3" + if is_win32: + with open("filenames.cmd", "w") as script: + for filename in input_data.splitlines(): + script.write(f"@echo {filename}\n") self.cmd( - f"--repo={self.repository_location}", "create", "--paths-from-command", "test", "--", "echo", input_data + f"--repo={self.repository_location}", + "create", + "--paths-from-command", + "test", + "--", + "filenames.cmd" if is_win32 else "echo", + input_data, ) + archive_list = self.cmd(f"--repo={self.repository_location}", "list", "test", "--json-lines") paths = [json.loads(line)["path"] for line in archive_list.split("\n") if line] assert paths == ["input/file1", "input/file2", "input/file3"]