authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-29 23:04:19-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-29 23:04:19-05:00
logb220be7a33a9835a1ec7a033e472830290332d57
tree943f22171b156fc102f36d963890c117de880991
parentd87b13f2f7cef04058537c8bfeb1ceda1a067e73
signaturelock-open Commit is signed but in an unrecognized format.

more test regression fixes


10 files changed, 28 insertions(+), 22 deletions(-)

lib/std/fs.zig+1-1
......@@ -609,7 +609,7 @@ pub const Dir = struct {
609609
610610 const name_utf16le = @ptrCast([*]u16, &dir_info.FileName)[0 .. dir_info.FileNameLength / 2];
611611
612 if (mem.eql(u16, name_utf16le, [_]u16{'.'}) or mem.eql(u16, name_utf16le, [_]u16{ '.', '.' }))
612 if (mem.eql(u16, name_utf16le, &[_]u16{'.'}) or mem.eql(u16, name_utf16le, &[_]u16{ '.', '.' }))
613613 continue;
614614 // Trust that Windows gives us valid UTF-16LE
615615 const name_utf8_len = std.unicode.utf16leToUtf8(self.name_data[0..], name_utf16le) catch unreachable;
lib/std/os.zig+1-1
......@@ -2633,7 +2633,7 @@ pub fn realpathW(pathname: [*:0]const u16, out_buffer: *[MAX_PATH_BYTES]u8) Real
26332633 // Windows returns \\?\ prepended to the path.
26342634 // We strip it to make this function consistent across platforms.
26352635 const prefix = [_]u16{ '\\', '\\', '?', '\\' };
2636 const start_index = if (mem.startsWith(u16, wide_slice, prefix)) prefix.len else 0;
2636 const start_index = if (mem.startsWith(u16, wide_slice, &prefix)) prefix.len else 0;
26372637
26382638 // Trust that Windows gives us valid UTF-16LE.
26392639 const end_index = std.unicode.utf16leToUtf8(out_buffer, wide_slice[start_index..]) catch unreachable;
test/cli.zig+13-13
......@@ -26,9 +26,9 @@ pub fn main() !void {
2626 std.debug.warn("Expected second argument to be cache root directory path\n");
2727 return error.InvalidArgs;
2828 });
29 const zig_exe = try fs.path.resolve(a, [_][]const u8{zig_exe_rel});
29 const zig_exe = try fs.path.resolve(a, &[_][]const u8{zig_exe_rel});
3030
31 const dir_path = try fs.path.join(a, [_][]const u8{ cache_root, "clitest" });
31 const dir_path = try fs.path.join(a, &[_][]const u8{ cache_root, "clitest" });
3232 const TestFn = fn ([]const u8, []const u8) anyerror!void;
3333 const test_fns = [_]TestFn{
3434 testZigInitLib,
......@@ -85,22 +85,22 @@ fn exec(cwd: []const u8, argv: []const []const u8) !ChildProcess.ExecResult {
8585}
8686
8787fn testZigInitLib(zig_exe: []const u8, dir_path: []const u8) !void {
88 _ = try exec(dir_path, [_][]const u8{ zig_exe, "init-lib" });
89 const test_result = try exec(dir_path, [_][]const u8{ zig_exe, "build", "test" });
88 _ = try exec(dir_path, &[_][]const u8{ zig_exe, "init-lib" });
89 const test_result = try exec(dir_path, &[_][]const u8{ zig_exe, "build", "test" });
9090 testing.expect(std.mem.endsWith(u8, test_result.stderr, "All 1 tests passed.\n"));
9191}
9292
9393fn testZigInitExe(zig_exe: []const u8, dir_path: []const u8) !void {
94 _ = try exec(dir_path, [_][]const u8{ zig_exe, "init-exe" });
95 const run_result = try exec(dir_path, [_][]const u8{ zig_exe, "build", "run" });
94 _ = try exec(dir_path, &[_][]const u8{ zig_exe, "init-exe" });
95 const run_result = try exec(dir_path, &[_][]const u8{ zig_exe, "build", "run" });
9696 testing.expect(std.mem.eql(u8, run_result.stderr, "All your base are belong to us.\n"));
9797}
9898
9999fn testGodboltApi(zig_exe: []const u8, dir_path: []const u8) anyerror!void {
100100 if (builtin.os != .linux or builtin.arch != .x86_64) return;
101101
102 const example_zig_path = try fs.path.join(a, [_][]const u8{ dir_path, "example.zig" });
103 const example_s_path = try fs.path.join(a, [_][]const u8{ dir_path, "example.s" });
102 const example_zig_path = try fs.path.join(a, &[_][]const u8{ dir_path, "example.zig" });
103 const example_s_path = try fs.path.join(a, &[_][]const u8{ dir_path, "example.s" });
104104
105105 try std.io.writeFile(example_zig_path,
106106 \\// Type your code here, or load an example.
......@@ -123,7 +123,7 @@ fn testGodboltApi(zig_exe: []const u8, dir_path: []const u8) anyerror!void {
123123 "--strip", "--release-fast",
124124 example_zig_path, "--disable-gen-h",
125125 };
126 _ = try exec(dir_path, args);
126 _ = try exec(dir_path, &args);
127127
128128 const out_asm = try std.io.readFileAlloc(a, example_s_path);
129129 testing.expect(std.mem.indexOf(u8, out_asm, "square:") != null);
......@@ -132,10 +132,10 @@ fn testGodboltApi(zig_exe: []const u8, dir_path: []const u8) anyerror!void {
132132}
133133
134134fn testMissingOutputPath(zig_exe: []const u8, dir_path: []const u8) !void {
135 _ = try exec(dir_path, [_][]const u8{ zig_exe, "init-exe" });
136 const output_path = try fs.path.join(a, [_][]const u8{ "does", "not", "exist" });
137 const source_path = try fs.path.join(a, [_][]const u8{ "src", "main.zig" });
138 _ = try exec(dir_path, [_][]const u8{
135 _ = try exec(dir_path, &[_][]const u8{ zig_exe, "init-exe" });
136 const output_path = try fs.path.join(a, &[_][]const u8{ "does", "not", "exist" });
137 const source_path = try fs.path.join(a, &[_][]const u8{ "src", "main.zig" });
138 _ = try exec(dir_path, &[_][]const u8{
139139 zig_exe, "build-exe", source_path, "--output-dir", output_path,
140140 });
141141}
test/runtime_safety.zig+2-2
......@@ -261,7 +261,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
261261 \\}
262262 \\pub fn main() void {
263263 \\ const a = [_]i32{1, 2, 3, 4};
264 \\ baz(bar(a));
264 \\ baz(bar(&a));
265265 \\}
266266 \\fn bar(a: []const i32) i32 {
267267 \\ return a[4];
......@@ -471,7 +471,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
471471 \\ @import("std").os.exit(126);
472472 \\}
473473 \\pub fn main() !void {
474 \\ const x = widenSlice([_]u8{1, 2, 3, 4, 5});
474 \\ const x = widenSlice(&[_]u8{1, 2, 3, 4, 5});
475475 \\ if (x.len == 0) return error.Whatever;
476476 \\}
477477 \\fn widenSlice(slice: []align(1) const u8) []align(1) const i32 {
test/stage1/behavior/array.zig+6
......@@ -360,3 +360,9 @@ test "access the null element of a null terminated array" {
360360 S.doTheTest();
361361 comptime S.doTheTest();
362362}
363
364test "type coerce sentinel-terminated array to non-sentinel-terminated array" {
365 var array: [2]u8 = [_:255]u8{1, 2};
366 expect(array[0] == 1);
367 expect(array[1] == 2);
368}
test/stage1/c_abi/build.zig+1-1
......@@ -4,7 +4,7 @@ pub fn build(b: *Builder) void {
44 const rel_opts = b.standardReleaseOptions();
55
66 const c_obj = b.addObject("cfuncs", null);
7 c_obj.addCSourceFile("cfuncs.c", [_][]const u8{"-std=c99"});
7 c_obj.addCSourceFile("cfuncs.c", &[_][]const u8{"-std=c99"});
88 c_obj.setBuildMode(rel_opts);
99 c_obj.linkSystemLibrary("c");
1010
test/stage1/c_abi/main.zig+1-1
......@@ -124,7 +124,7 @@ test "C ABI array" {
124124}
125125
126126export fn zig_array(x: [10]u8) void {
127 expect(std.mem.eql(u8, x, "1234567890"));
127 expect(std.mem.eql(u8, &x, "1234567890"));
128128}
129129
130130const BigStruct = extern struct {
test/standalone/mix_o_files/build.zig+1-1
......@@ -4,7 +4,7 @@ pub fn build(b: *Builder) void {
44 const obj = b.addObject("base64", "base64.zig");
55
66 const exe = b.addExecutable("test", null);
7 exe.addCSourceFile("test.c", [_][]const u8{"-std=c99"});
7 exe.addCSourceFile("test.c", &[_][]const u8{"-std=c99"});
88 exe.addObject(obj);
99 exe.linkSystemLibrary("c");
1010
test/standalone/shared_library/build.zig+1-1
......@@ -4,7 +4,7 @@ pub fn build(b: *Builder) void {
44 const lib = b.addSharedLibrary("mathtest", "mathtest.zig", b.version(1, 0, 0));
55
66 const exe = b.addExecutable("test", null);
7 exe.addCSourceFile("test.c", [_][]const u8{"-std=c99"});
7 exe.addCSourceFile("test.c", &[_][]const u8{"-std=c99"});
88 exe.linkLibrary(lib);
99 exe.linkSystemLibrary("c");
1010
test/standalone/static_c_lib/build.zig+1-1
......@@ -4,7 +4,7 @@ pub fn build(b: *Builder) void {
44 const mode = b.standardReleaseOptions();
55
66 const foo = b.addStaticLibrary("foo", null);
7 foo.addCSourceFile("foo.c", [_][]const u8{});
7 foo.addCSourceFile("foo.c", &[_][]const u8{});
88 foo.setBuildMode(mode);
99 foo.addIncludeDir(".");
1010