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 {...@@ -609,7 +609,7 @@ pub const Dir = struct {
609609
610 const name_utf16le = @ptrCast([*]u16, &dir_info.FileName)[0 .. dir_info.FileNameLength / 2];610 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{ '.', '.' }))
613 continue;613 continue;
614 // Trust that Windows gives us valid UTF-16LE614 // Trust that Windows gives us valid UTF-16LE
615 const name_utf8_len = std.unicode.utf16leToUtf8(self.name_data[0..], name_utf16le) catch unreachable;615 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...@@ -2633,7 +2633,7 @@ pub fn realpathW(pathname: [*:0]const u16, out_buffer: *[MAX_PATH_BYTES]u8) Real
2633 // Windows returns \\?\ prepended to the path.2633 // Windows returns \\?\ prepended to the path.
2634 // We strip it to make this function consistent across platforms.2634 // We strip it to make this function consistent across platforms.
2635 const prefix = [_]u16{ '\\', '\\', '?', '\\' };2635 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
2638 // Trust that Windows gives us valid UTF-16LE.2638 // Trust that Windows gives us valid UTF-16LE.
2639 const end_index = std.unicode.utf16leToUtf8(out_buffer, wide_slice[start_index..]) catch unreachable;2639 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 {...@@ -26,9 +26,9 @@ pub fn main() !void {
26 std.debug.warn("Expected second argument to be cache root directory path\n");26 std.debug.warn("Expected second argument to be cache root directory path\n");
27 return error.InvalidArgs;27 return error.InvalidArgs;
28 });28 });
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" });
32 const TestFn = fn ([]const u8, []const u8) anyerror!void;32 const TestFn = fn ([]const u8, []const u8) anyerror!void;
33 const test_fns = [_]TestFn{33 const test_fns = [_]TestFn{
34 testZigInitLib,34 testZigInitLib,
...@@ -85,22 +85,22 @@ fn exec(cwd: []const u8, argv: []const []const u8) !ChildProcess.ExecResult {...@@ -85,22 +85,22 @@ fn exec(cwd: []const u8, argv: []const []const u8) !ChildProcess.ExecResult {
85}85}
8686
87fn testZigInitLib(zig_exe: []const u8, dir_path: []const u8) !void {87fn testZigInitLib(zig_exe: []const u8, dir_path: []const u8) !void {
88 _ = try exec(dir_path, [_][]const u8{ zig_exe, "init-lib" });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" });89 const test_result = try exec(dir_path, &[_][]const u8{ zig_exe, "build", "test" });
90 testing.expect(std.mem.endsWith(u8, test_result.stderr, "All 1 tests passed.\n"));90 testing.expect(std.mem.endsWith(u8, test_result.stderr, "All 1 tests passed.\n"));
91}91}
9292
93fn testZigInitExe(zig_exe: []const u8, dir_path: []const u8) !void {93fn testZigInitExe(zig_exe: []const u8, dir_path: []const u8) !void {
94 _ = try exec(dir_path, [_][]const u8{ zig_exe, "init-exe" });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" });95 const run_result = try exec(dir_path, &[_][]const u8{ zig_exe, "build", "run" });
96 testing.expect(std.mem.eql(u8, run_result.stderr, "All your base are belong to us.\n"));96 testing.expect(std.mem.eql(u8, run_result.stderr, "All your base are belong to us.\n"));
97}97}
9898
99fn testGodboltApi(zig_exe: []const u8, dir_path: []const u8) anyerror!void {99fn testGodboltApi(zig_exe: []const u8, dir_path: []const u8) anyerror!void {
100 if (builtin.os != .linux or builtin.arch != .x86_64) return;100 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" });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" });103 const example_s_path = try fs.path.join(a, &[_][]const u8{ dir_path, "example.s" });
104104
105 try std.io.writeFile(example_zig_path,105 try std.io.writeFile(example_zig_path,
106 \\// Type your code here, or load an example.106 \\// Type your code here, or load an example.
...@@ -123,7 +123,7 @@ fn testGodboltApi(zig_exe: []const u8, dir_path: []const u8) anyerror!void {...@@ -123,7 +123,7 @@ fn testGodboltApi(zig_exe: []const u8, dir_path: []const u8) anyerror!void {
123 "--strip", "--release-fast",123 "--strip", "--release-fast",
124 example_zig_path, "--disable-gen-h",124 example_zig_path, "--disable-gen-h",
125 };125 };
126 _ = try exec(dir_path, args);126 _ = try exec(dir_path, &args);
127127
128 const out_asm = try std.io.readFileAlloc(a, example_s_path);128 const out_asm = try std.io.readFileAlloc(a, example_s_path);
129 testing.expect(std.mem.indexOf(u8, out_asm, "square:") != null);129 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 {...@@ -132,10 +132,10 @@ fn testGodboltApi(zig_exe: []const u8, dir_path: []const u8) anyerror!void {
132}132}
133133
134fn testMissingOutputPath(zig_exe: []const u8, dir_path: []const u8) !void {134fn testMissingOutputPath(zig_exe: []const u8, dir_path: []const u8) !void {
135 _ = try exec(dir_path, [_][]const u8{ zig_exe, "init-exe" });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" });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" });137 const source_path = try fs.path.join(a, &[_][]const u8{ "src", "main.zig" });
138 _ = try exec(dir_path, [_][]const u8{138 _ = try exec(dir_path, &[_][]const u8{
139 zig_exe, "build-exe", source_path, "--output-dir", output_path,139 zig_exe, "build-exe", source_path, "--output-dir", output_path,
140 });140 });
141}141}
test/runtime_safety.zig+2-2
...@@ -261,7 +261,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -261,7 +261,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
261 \\}261 \\}
262 \\pub fn main() void {262 \\pub fn main() void {
263 \\ const a = [_]i32{1, 2, 3, 4};263 \\ const a = [_]i32{1, 2, 3, 4};
264 \\ baz(bar(a));264 \\ baz(bar(&a));
265 \\}265 \\}
266 \\fn bar(a: []const i32) i32 {266 \\fn bar(a: []const i32) i32 {
267 \\ return a[4];267 \\ return a[4];
...@@ -471,7 +471,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -471,7 +471,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
471 \\ @import("std").os.exit(126);471 \\ @import("std").os.exit(126);
472 \\}472 \\}
473 \\pub fn main() !void {473 \\pub fn main() !void {
474 \\ const x = widenSlice([_]u8{1, 2, 3, 4, 5});474 \\ const x = widenSlice(&[_]u8{1, 2, 3, 4, 5});
475 \\ if (x.len == 0) return error.Whatever;475 \\ if (x.len == 0) return error.Whatever;
476 \\}476 \\}
477 \\fn widenSlice(slice: []align(1) const u8) []align(1) const i32 {477 \\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" {...@@ -360,3 +360,9 @@ test "access the null element of a null terminated array" {
360 S.doTheTest();360 S.doTheTest();
361 comptime S.doTheTest();361 comptime S.doTheTest();
362}362}
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 {...@@ -4,7 +4,7 @@ pub fn build(b: *Builder) void {
4 const rel_opts = b.standardReleaseOptions();4 const rel_opts = b.standardReleaseOptions();
55
6 const c_obj = b.addObject("cfuncs", null);6 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"});
8 c_obj.setBuildMode(rel_opts);8 c_obj.setBuildMode(rel_opts);
9 c_obj.linkSystemLibrary("c");9 c_obj.linkSystemLibrary("c");
1010
test/stage1/c_abi/main.zig+1-1
...@@ -124,7 +124,7 @@ test "C ABI array" {...@@ -124,7 +124,7 @@ test "C ABI array" {
124}124}
125125
126export fn zig_array(x: [10]u8) void {126export fn zig_array(x: [10]u8) void {
127 expect(std.mem.eql(u8, x, "1234567890"));127 expect(std.mem.eql(u8, &x, "1234567890"));
128}128}
129129
130const BigStruct = extern struct {130const BigStruct = extern struct {
test/standalone/mix_o_files/build.zig+1-1
...@@ -4,7 +4,7 @@ pub fn build(b: *Builder) void {...@@ -4,7 +4,7 @@ pub fn build(b: *Builder) void {
4 const obj = b.addObject("base64", "base64.zig");4 const obj = b.addObject("base64", "base64.zig");
55
6 const exe = b.addExecutable("test", null);6 const exe = b.addExecutable("test", null);
7 exe.addCSourceFile("test.c", [_][]const u8{"-std=c99"});7 exe.addCSourceFile("test.c", &[_][]const u8{"-std=c99"});
8 exe.addObject(obj);8 exe.addObject(obj);
9 exe.linkSystemLibrary("c");9 exe.linkSystemLibrary("c");
1010
test/standalone/shared_library/build.zig+1-1
...@@ -4,7 +4,7 @@ pub fn build(b: *Builder) void {...@@ -4,7 +4,7 @@ pub fn build(b: *Builder) void {
4 const lib = b.addSharedLibrary("mathtest", "mathtest.zig", b.version(1, 0, 0));4 const lib = b.addSharedLibrary("mathtest", "mathtest.zig", b.version(1, 0, 0));
55
6 const exe = b.addExecutable("test", null);6 const exe = b.addExecutable("test", null);
7 exe.addCSourceFile("test.c", [_][]const u8{"-std=c99"});7 exe.addCSourceFile("test.c", &[_][]const u8{"-std=c99"});
8 exe.linkLibrary(lib);8 exe.linkLibrary(lib);
9 exe.linkSystemLibrary("c");9 exe.linkSystemLibrary("c");
1010
test/standalone/static_c_lib/build.zig+1-1
...@@ -4,7 +4,7 @@ pub fn build(b: *Builder) void {...@@ -4,7 +4,7 @@ pub fn build(b: *Builder) void {
4 const mode = b.standardReleaseOptions();4 const mode = b.standardReleaseOptions();
55
6 const foo = b.addStaticLibrary("foo", null);6 const foo = b.addStaticLibrary("foo", null);
7 foo.addCSourceFile("foo.c", [_][]const u8{});7 foo.addCSourceFile("foo.c", &[_][]const u8{});
8 foo.setBuildMode(mode);8 foo.setBuildMode(mode);
9 foo.addIncludeDir(".");9 foo.addIncludeDir(".");
1010