1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-26 01:37:20 +00:00

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.
This commit is contained in:
Rayyan Ansari 2022-12-01 17:59:08 +00:00
parent 9e9b94615e
commit e97a966b46

View file

@ -243,9 +243,20 @@ def test_create_paths_from_command(self):
self.create_regular_file("file4", size=1024 * 80) self.create_regular_file("file4", size=1024 * 80)
input_data = "input/file1\ninput/file2\ninput/file3" 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( 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") 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] paths = [json.loads(line)["path"] for line in archive_list.split("\n") if line]
assert paths == ["input/file1", "input/file2", "input/file3"] assert paths == ["input/file1", "input/file2", "input/file3"]