diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-02-07 00:42:41 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-02-07 00:42:41 -0500 |
| commit | 36bade5c562bf0b2479b6dfdd465a1a312890835 (patch) | |
| tree | 5ecb89cb50e08dc7032e31c84128f5d32d20d315 /test/tests.zig | |
| parent | c804ae2d6b1f62d9cb45db2613d36ef14ac539a0 (diff) | |
| download | zig-36bade5c562bf0b2479b6dfdd465a1a312890835.tar.gz zig-36bade5c562bf0b2479b6dfdd465a1a312890835.zip | |
fixups, and modify std.mem.join and std.os.path.resolve API
* zig fmt
* std.mem.join takes a slice of slices instead of var args
* std.mem.join takes a separator slice rather than byte,
and always inserts it. Previously it would not insert the separator
if there already was one, violating the documented behavior.
* std.mem.join calculates exactly the correct amount to allocate
and has no call to allocator.shrink()
* bring back joinWindows and joinPosix and the corresponding tests.
it is intended to be able to call these functions from any OS.
* rename std.os.path.resolveSlice to resolve (now resolve takes
a slice of slices instead of var args)
Diffstat (limited to 'test/tests.zig')
| -rw-r--r-- | test/tests.zig | 55 |
1 files changed, 44 insertions, 11 deletions
diff --git a/test/tests.zig b/test/tests.zig index fac941cbde..670c410509 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -439,7 +439,10 @@ pub const CompareOutputContext = struct { pub fn addCase(self: *CompareOutputContext, case: TestCase) void { const b = self.b; - const root_src = os.path.join(b.allocator, [][]const u8{b.cache_root, case.sources.items[0].filename}) catch unreachable; + const root_src = os.path.join( + b.allocator, + [][]const u8{ b.cache_root, case.sources.items[0].filename }, + ) catch unreachable; switch (case.special) { Special.Asm => { @@ -452,7 +455,10 @@ pub const CompareOutputContext = struct { exe.addAssemblyFile(root_src); for (case.sources.toSliceConst()) |src_file| { - const expanded_src_path = os.path.join(b.allocator, [][]const u8{b.cache_root, src_file.filename}) catch unreachable; + const expanded_src_path = os.path.join( + b.allocator, + [][]const u8{ b.cache_root, src_file.filename }, + ) catch unreachable; const write_src = b.addWriteFile(expanded_src_path, src_file.source); exe.step.dependOn(&write_src.step); } @@ -476,7 +482,10 @@ pub const CompareOutputContext = struct { } for (case.sources.toSliceConst()) |src_file| { - const expanded_src_path = os.path.join(b.allocator, [][]const u8{b.cache_root, src_file.filename}) catch unreachable; + const expanded_src_path = os.path.join( + b.allocator, + [][]const u8{ b.cache_root, src_file.filename }, + ) catch unreachable; const write_src = b.addWriteFile(expanded_src_path, src_file.source); exe.step.dependOn(&write_src.step); } @@ -499,7 +508,10 @@ pub const CompareOutputContext = struct { } for (case.sources.toSliceConst()) |src_file| { - const expanded_src_path = os.path.join(b.allocator, [][]const u8{b.cache_root, src_file.filename}) catch unreachable; + const expanded_src_path = os.path.join( + b.allocator, + [][]const u8{ b.cache_root, src_file.filename }, + ) catch unreachable; const write_src = b.addWriteFile(expanded_src_path, src_file.source); exe.step.dependOn(&write_src.step); } @@ -572,8 +584,14 @@ pub const CompileErrorContext = struct { const self = @fieldParentPtr(CompileCmpOutputStep, "step", step); const b = self.context.b; - const root_src = os.path.join(b.allocator, [][]const u8{b.cache_root, self.case.sources.items[0].filename}) catch unreachable; - const obj_path = os.path.join(b.allocator, [][]const u8{b.cache_root, "test.o"}) catch unreachable; + const root_src = os.path.join( + b.allocator, + [][]const u8{ b.cache_root, self.case.sources.items[0].filename }, + ) catch unreachable; + const obj_path = os.path.join( + b.allocator, + [][]const u8{ b.cache_root, "test.o" }, + ) catch unreachable; var zig_args = ArrayList([]const u8).init(b.allocator); zig_args.append(b.zig_exe) catch unreachable; @@ -721,7 +739,10 @@ pub const CompileErrorContext = struct { self.step.dependOn(&compile_and_cmp_errors.step); for (case.sources.toSliceConst()) |src_file| { - const expanded_src_path = os.path.join(b.allocator, [][]const u8{b.cache_root, src_file.filename}) catch unreachable; + const expanded_src_path = os.path.join( + b.allocator, + [][]const u8{ b.cache_root, src_file.filename }, + ) catch unreachable; const write_src = b.addWriteFile(expanded_src_path, src_file.source); compile_and_cmp_errors.step.dependOn(&write_src.step); } @@ -852,7 +873,10 @@ pub const TranslateCContext = struct { const self = @fieldParentPtr(TranslateCCmpOutputStep, "step", step); const b = self.context.b; - const root_src = os.path.join(b.allocator, [][]const u8{b.cache_root, self.case.sources.items[0].filename}) catch unreachable; + const root_src = os.path.join( + b.allocator, + [][]const u8{ b.cache_root, self.case.sources.items[0].filename }, + ) catch unreachable; var zig_args = ArrayList([]const u8).init(b.allocator); zig_args.append(b.zig_exe) catch unreachable; @@ -986,7 +1010,10 @@ pub const TranslateCContext = struct { self.step.dependOn(&translate_c_and_cmp.step); for (case.sources.toSliceConst()) |src_file| { - const expanded_src_path = os.path.join(b.allocator, [][]const u8{b.cache_root, src_file.filename}) catch unreachable; + const expanded_src_path = os.path.join( + b.allocator, + [][]const u8{ b.cache_root, src_file.filename }, + ) catch unreachable; const write_src = b.addWriteFile(expanded_src_path, src_file.source); translate_c_and_cmp.step.dependOn(&write_src.step); } @@ -1101,7 +1128,10 @@ pub const GenHContext = struct { pub fn addCase(self: *GenHContext, case: *const TestCase) void { const b = self.b; - const root_src = os.path.join(b.allocator, [][]const u8{b.cache_root, case.sources.items[0].filename}) catch unreachable; + const root_src = os.path.join( + b.allocator, + [][]const u8{ b.cache_root, case.sources.items[0].filename }, + ) catch unreachable; const mode = builtin.Mode.Debug; const annotated_case_name = fmt.allocPrint(self.b.allocator, "gen-h {} ({})", case.name, @tagName(mode)) catch unreachable; @@ -1113,7 +1143,10 @@ pub const GenHContext = struct { obj.setBuildMode(mode); for (case.sources.toSliceConst()) |src_file| { - const expanded_src_path = os.path.join(b.allocator, [][]const u8{b.cache_root, src_file.filename}) catch unreachable; + const expanded_src_path = os.path.join( + b.allocator, + [][]const u8{ b.cache_root, src_file.filename }, + ) catch unreachable; const write_src = b.addWriteFile(expanded_src_path, src_file.source); obj.step.dependOn(&write_src.step); } |
