authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-14 14:44:38-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-15 10:48:15-07:00
loged33901218363b9d1baee4c37e85f573dc034e06
tree9161dd89ba989f4daaf4d1848589ba5c7521250b
parent37a7d2c78d27a327c70bb6865e1c6d114459a3af

test-cli: fix expected stderr on windows

Needed to account for backward slashes in file system paths.

1 files changed, 8 insertions(+), 14 deletions(-)

test/tests.zig+8-14
...@@ -660,20 +660,19 @@ pub fn addLinkTests(...@@ -660,20 +660,19 @@ pub fn addLinkTests(
660660
661pub fn addCliTests(b: *std.Build) *Step {661pub fn addCliTests(b: *std.Build) *Step {
662 const step = b.step("test-cli", "Test the command line interface");662 const step = b.step("test-cli", "Test the command line interface");
663 const s = std.fs.path.sep_str;
663664
664 {665 {
666
665 // Test `zig init-lib`.667 // Test `zig init-lib`.
666 const tmp_path = b.makeTempPath();668 const tmp_path = b.makeTempPath();
667 const init_lib = b.addSystemCommand(&.{ b.zig_exe, "init-lib" });669 const init_lib = b.addSystemCommand(&.{ b.zig_exe, "init-lib" });
668 init_lib.cwd = tmp_path;670 init_lib.cwd = tmp_path;
669 init_lib.setName("zig init-lib");671 init_lib.setName("zig init-lib");
670 init_lib.expectStdOutEqual("");672 init_lib.expectStdOutEqual("");
671 init_lib.expectStdErrEqual(673 init_lib.expectStdErrEqual("info: Created build.zig\n" ++
672 \\info: Created build.zig674 "info: Created src" ++ s ++ "main.zig\n" ++
673 \\info: Created src/main.zig675 "info: Next, try `zig build --help` or `zig build test`\n");
674 \\info: Next, try `zig build --help` or `zig build test`
675 \\
676 );
677676
678 const run_test = b.addSystemCommand(&.{ b.zig_exe, "build", "test" });677 const run_test = b.addSystemCommand(&.{ b.zig_exe, "build", "test" });
679 run_test.cwd = tmp_path;678 run_test.cwd = tmp_path;
...@@ -694,15 +693,11 @@ pub fn addCliTests(b: *std.Build) *Step {...@@ -694,15 +693,11 @@ pub fn addCliTests(b: *std.Build) *Step {
694 init_exe.cwd = tmp_path;693 init_exe.cwd = tmp_path;
695 init_exe.setName("zig init-exe");694 init_exe.setName("zig init-exe");
696 init_exe.expectStdOutEqual("");695 init_exe.expectStdOutEqual("");
697 init_exe.expectStdErrEqual(696 init_exe.expectStdErrEqual("info: Created build.zig\n" ++
698 \\info: Created build.zig697 "info: Created src" ++ s ++ "main.zig\n" ++
699 \\info: Created src/main.zig698 "info: Next, try `zig build --help` or `zig build run`\n");
700 \\info: Next, try `zig build --help` or `zig build run`
701 \\
702 );
703699
704 // Test missing output path.700 // Test missing output path.
705 const s = std.fs.path.sep_str;
706 const bad_out_arg = "-femit-bin=does" ++ s ++ "not" ++ s ++ "exist" ++ s ++ "foo.exe";701 const bad_out_arg = "-femit-bin=does" ++ s ++ "not" ++ s ++ "exist" ++ s ++ "foo.exe";
707 const ok_src_arg = "src" ++ s ++ "main.zig";702 const ok_src_arg = "src" ++ s ++ "main.zig";
708 const expected = "error: unable to open output directory 'does" ++ s ++ "not" ++ s ++ "exist': FileNotFound\n";703 const expected = "error: unable to open output directory 'does" ++ s ++ "not" ++ s ++ "exist': FileNotFound\n";
...@@ -785,7 +780,6 @@ pub fn addCliTests(b: *std.Build) *Step {...@@ -785,7 +780,6 @@ pub fn addCliTests(b: *std.Build) *Step {
785 // owners.780 // owners.
786 const tmp_path = b.makeTempPath();781 const tmp_path = b.makeTempPath();
787 const unformatted_code = " // no reason for indent";782 const unformatted_code = " // no reason for indent";
788 const s = std.fs.path.sep_str;
789783
790 var dir = std.fs.cwd().openDir(tmp_path, .{}) catch @panic("unhandled");784 var dir = std.fs.cwd().openDir(tmp_path, .{}) catch @panic("unhandled");
791 defer dir.close();785 defer dir.close();