authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-11-26 13:28:38+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-01-02 17:12:57-07:00
log4420afe64d5ae03565b51dcec55ce9dd7351d0ee
tree80ffb8e33dbfeeaa52f2da27cf41b27f6a855de8
parent1c13ca5a05978011283ff55a586443b10b69fc85

tests: Use {s} instead of {} when formatting strings


6 files changed, 243 insertions(+), 54 deletions(-)

build.zig+197-8
...@@ -224,7 +224,7 @@ pub fn build(b: *Builder) !void {...@@ -224,7 +224,7 @@ pub fn build(b: *Builder) !void {
224224
225 const opt_version_string = b.option([]const u8, "version-string", "Override Zig version string. Default is to find out with git.");225 const opt_version_string = b.option([]const u8, "version-string", "Override Zig version string. Default is to find out with git.");
226 const version = if (opt_version_string) |version| version else v: {226 const version = if (opt_version_string) |version| version else v: {
227 const version_string = b.fmt("{}.{}.{}", .{ zig_version.major, zig_version.minor, zig_version.patch });227 const version_string = b.fmt("{d}.{d}.{d}", .{ zig_version.major, zig_version.minor, zig_version.patch });
228228
229 var code: u8 = undefined;229 var code: u8 = undefined;
230 const git_describe_untrimmed = b.execAllowFail(&[_][]const u8{230 const git_describe_untrimmed = b.execAllowFail(&[_][]const u8{
...@@ -238,7 +238,7 @@ pub fn build(b: *Builder) !void {...@@ -238,7 +238,7 @@ pub fn build(b: *Builder) !void {
238 0 => {238 0 => {
239 // Tagged release version (e.g. 0.7.0).239 // Tagged release version (e.g. 0.7.0).
240 if (!mem.eql(u8, git_describe, version_string)) {240 if (!mem.eql(u8, git_describe, version_string)) {
241 std.debug.print("Zig version '{}' does not match Git tag '{}'\n", .{ version_string, git_describe });241 std.debug.print("Zig version '{s}' does not match Git tag '{s}'\n", .{ version_string, git_describe });
242 std.process.exit(1);242 std.process.exit(1);
243 }243 }
244 break :v version_string;244 break :v version_string;
...@@ -258,15 +258,15 @@ pub fn build(b: *Builder) !void {...@@ -258,15 +258,15 @@ pub fn build(b: *Builder) !void {
258258
259 // Check that the commit hash is prefixed with a 'g' (a Git convention).259 // Check that the commit hash is prefixed with a 'g' (a Git convention).
260 if (commit_id.len < 1 or commit_id[0] != 'g') {260 if (commit_id.len < 1 or commit_id[0] != 'g') {
261 std.debug.print("Unexpected `git describe` output: {}\n", .{git_describe});261 std.debug.print("Unexpected `git describe` output: {s}\n", .{git_describe});
262 break :v version_string;262 break :v version_string;
263 }263 }
264264
265 // The version is reformatted in accordance with the https://semver.org specification.265 // The version is reformatted in accordance with the https://semver.org specification.
266 break :v b.fmt("{}-dev.{}+{}", .{ version_string, commit_height, commit_id[1..] });266 break :v b.fmt("{s}-dev.{s}+{s}", .{ version_string, commit_height, commit_id[1..] });
267 },267 },
268 else => {268 else => {
269 std.debug.print("Unexpected `git describe` output: {}\n", .{git_describe});269 std.debug.print("Unexpected `git describe` output: {s}\n", .{git_describe});
270 break :v version_string;270 break :v version_string;
271 },271 },
272 }272 }
...@@ -359,6 +359,195 @@ pub fn build(b: *Builder) !void {...@@ -359,6 +359,195 @@ pub fn build(b: *Builder) !void {
359 test_step.dependOn(docs_step);359 test_step.dependOn(docs_step);
360}360}
361361
362fn dependOnLib(b: *Builder, lib_exe_obj: anytype, dep: LibraryDep) void {
363 for (dep.libdirs.items) |lib_dir| {
364 lib_exe_obj.addLibPath(lib_dir);
365 }
366 const lib_dir = fs.path.join(
367 b.allocator,
368 &[_][]const u8{ dep.prefix, "lib" },
369 ) catch unreachable;
370 for (dep.system_libs.items) |lib| {
371 const static_bare_name = if (mem.eql(u8, lib, "curses"))
372 @as([]const u8, "libncurses.a")
373 else
374 b.fmt("lib{s}.a", .{lib});
375 const static_lib_name = fs.path.join(
376 b.allocator,
377 &[_][]const u8{ lib_dir, static_bare_name },
378 ) catch unreachable;
379 const have_static = fileExists(static_lib_name) catch unreachable;
380 if (have_static) {
381 lib_exe_obj.addObjectFile(static_lib_name);
382 } else {
383 lib_exe_obj.linkSystemLibrary(lib);
384 }
385 }
386 for (dep.libs.items) |lib| {
387 lib_exe_obj.addObjectFile(lib);
388 }
389 for (dep.includes.items) |include_path| {
390 lib_exe_obj.addIncludeDir(include_path);
391 }
392}
393
394fn fileExists(filename: []const u8) !bool {
395 fs.cwd().access(filename, .{}) catch |err| switch (err) {
396 error.FileNotFound => return false,
397 else => return err,
398 };
399 return true;
400}
401
402fn addCppLib(b: *Builder, lib_exe_obj: anytype, cmake_binary_dir: []const u8, lib_name: []const u8) void {
403 lib_exe_obj.addObjectFile(fs.path.join(b.allocator, &[_][]const u8{
404 cmake_binary_dir,
405 "zigcpp",
406 b.fmt("{s}{s}{s}", .{ lib_exe_obj.target.libPrefix(), lib_name, lib_exe_obj.target.staticLibSuffix() }),
407 }) catch unreachable);
408}
409
410const LibraryDep = struct {
411 prefix: []const u8,
412 libdirs: ArrayList([]const u8),
413 libs: ArrayList([]const u8),
414 system_libs: ArrayList([]const u8),
415 includes: ArrayList([]const u8),
416};
417
418fn findLLVM(b: *Builder, llvm_config_exe: []const u8) !LibraryDep {
419 const shared_mode = try b.exec(&[_][]const u8{ llvm_config_exe, "--shared-mode" });
420 const is_static = mem.startsWith(u8, shared_mode, "static");
421 const libs_output = if (is_static)
422 try b.exec(&[_][]const u8{
423 llvm_config_exe,
424 "--libfiles",
425 "--system-libs",
426 })
427 else
428 try b.exec(&[_][]const u8{
429 llvm_config_exe,
430 "--libs",
431 });
432 const includes_output = try b.exec(&[_][]const u8{ llvm_config_exe, "--includedir" });
433 const libdir_output = try b.exec(&[_][]const u8{ llvm_config_exe, "--libdir" });
434 const prefix_output = try b.exec(&[_][]const u8{ llvm_config_exe, "--prefix" });
435
436 var result = LibraryDep{
437 .prefix = mem.tokenize(prefix_output, " \r\n").next().?,
438 .libs = ArrayList([]const u8).init(b.allocator),
439 .system_libs = ArrayList([]const u8).init(b.allocator),
440 .includes = ArrayList([]const u8).init(b.allocator),
441 .libdirs = ArrayList([]const u8).init(b.allocator),
442 };
443 {
444 var it = mem.tokenize(libs_output, " \r\n");
445 while (it.next()) |lib_arg| {
446 if (mem.startsWith(u8, lib_arg, "-l")) {
447 try result.system_libs.append(lib_arg[2..]);
448 } else {
449 if (fs.path.isAbsolute(lib_arg)) {
450 try result.libs.append(lib_arg);
451 } else {
452 var lib_arg_copy = lib_arg;
453 if (mem.endsWith(u8, lib_arg, ".lib")) {
454 lib_arg_copy = lib_arg[0 .. lib_arg.len - 4];
455 }
456 try result.system_libs.append(lib_arg_copy);
457 }
458 }
459 }
460 }
461 {
462 var it = mem.tokenize(includes_output, " \r\n");
463 while (it.next()) |include_arg| {
464 if (mem.startsWith(u8, include_arg, "-I")) {
465 try result.includes.append(include_arg[2..]);
466 } else {
467 try result.includes.append(include_arg);
468 }
469 }
470 }
471 {
472 var it = mem.tokenize(libdir_output, " \r\n");
473 while (it.next()) |libdir| {
474 if (mem.startsWith(u8, libdir, "-L")) {
475 try result.libdirs.append(libdir[2..]);
476 } else {
477 try result.libdirs.append(libdir);
478 }
479 }
480 }
481 return result;
482}
483
484fn configureStage2(b: *Builder, exe: anytype, ctx: Context, need_cpp_includes: bool) !void {
485 exe.addIncludeDir("src");
486 exe.addIncludeDir(ctx.cmake_binary_dir);
487 addCppLib(b, exe, ctx.cmake_binary_dir, "zigcpp");
488 assert(ctx.lld_include_dir.len != 0);
489 exe.addIncludeDir(ctx.lld_include_dir);
490 {
491 var it = mem.tokenize(ctx.lld_libraries, ";");
492 while (it.next()) |lib| {
493 exe.addObjectFile(lib);
494 }
495 }
496 {
497 var it = mem.tokenize(ctx.clang_libraries, ";");
498 while (it.next()) |lib| {
499 exe.addObjectFile(lib);
500 }
501 }
502 dependOnLib(b, exe, ctx.llvm);
503
504 // Boy, it sure would be nice to simply linkSystemLibrary("c++") and rely on zig's
505 // ability to provide libc++ right? Well thanks to C++ not having a stable ABI this
506 // will cause linker errors. It would work in the situation when `zig cc` is used to
507 // build LLVM, Clang, and LLD, however when depending on them as system libraries, system
508 // libc++ must be used.
509 const cross_compile = false; // TODO
510 if (cross_compile) {
511 // In this case we assume that zig cc was used to build the LLVM, Clang, LLD dependencies.
512 exe.linkSystemLibrary("c++");
513 } else {
514 if (exe.target.getOsTag() == .linux) {
515 // First we try to static link against gcc libstdc++. If that doesn't work,
516 // we fall back to -lc++ and cross our fingers.
517 addCxxKnownPath(b, ctx, exe, "libstdc++.a", "", need_cpp_includes) catch |err| switch (err) {
518 error.RequiredLibraryNotFound => {
519 exe.linkSystemLibrary("c++");
520 },
521 else => |e| return e,
522 };
523
524 exe.linkSystemLibrary("pthread");
525 } else if (exe.target.isFreeBSD()) {
526 try addCxxKnownPath(b, ctx, exe, "libc++.a", null, need_cpp_includes);
527 exe.linkSystemLibrary("pthread");
528 } else if (exe.target.isDarwin()) {
529 if (addCxxKnownPath(b, ctx, exe, "libgcc_eh.a", "", need_cpp_includes)) {
530 // Compiler is GCC.
531 try addCxxKnownPath(b, ctx, exe, "libstdc++.a", null, need_cpp_includes);
532 exe.linkSystemLibrary("pthread");
533 // TODO LLD cannot perform this link.
534 // Set ZIG_SYSTEM_LINKER_HACK env var to use system linker ld instead.
535 // See https://github.com/ziglang/zig/issues/1535
536 } else |err| switch (err) {
537 error.RequiredLibraryNotFound => {
538 // System compiler, not gcc.
539 exe.linkSystemLibrary("c++");
540 },
541 else => |e| return e,
542 }
543 }
544
545 if (ctx.dia_guids_lib.len != 0) {
546 exe.addObjectFile(ctx.dia_guids_lib);
547 }
548 }
549}
550
362fn addCxxKnownPath(551fn addCxxKnownPath(
363 b: *Builder,552 b: *Builder,
364 ctx: CMakeConfig,553 ctx: CMakeConfig,
...@@ -369,14 +558,14 @@ fn addCxxKnownPath(...@@ -369,14 +558,14 @@ fn addCxxKnownPath(
369) !void {558) !void {
370 const path_padded = try b.exec(&[_][]const u8{559 const path_padded = try b.exec(&[_][]const u8{
371 ctx.cxx_compiler,560 ctx.cxx_compiler,
372 b.fmt("-print-file-name={}", .{objname}),561 b.fmt("-print-file-name={s}", .{objname}),
373 });562 });
374 const path_unpadded = mem.tokenize(path_padded, "\r\n").next().?;563 const path_unpadded = mem.tokenize(path_padded, "\r\n").next().?;
375 if (mem.eql(u8, path_unpadded, objname)) {564 if (mem.eql(u8, path_unpadded, objname)) {
376 if (errtxt) |msg| {565 if (errtxt) |msg| {
377 warn("{}", .{msg});566 warn("{s}", .{msg});
378 } else {567 } else {
379 warn("Unable to determine path to {}\n", .{objname});568 warn("Unable to determine path to {s}\n", .{objname});
380 }569 }
381 return error.RequiredLibraryNotFound;570 return error.RequiredLibraryNotFound;
382 }571 }
lib/std/special/build_runner.zig+7-7
...@@ -98,7 +98,7 @@ pub fn main() !void {...@@ -98,7 +98,7 @@ pub fn main() !void {
98 return usageAndErr(builder, false, stderr_stream);98 return usageAndErr(builder, false, stderr_stream);
99 };99 };
100 builder.color = std.meta.stringToEnum(@TypeOf(builder.color), next_arg) orelse {100 builder.color = std.meta.stringToEnum(@TypeOf(builder.color), next_arg) orelse {
101 warn("expected [auto|on|off] after --color, found '{}'", .{next_arg});101 warn("expected [auto|on|off] after --color, found '{s}'", .{next_arg});
102 return usageAndErr(builder, false, stderr_stream);102 return usageAndErr(builder, false, stderr_stream);
103 };103 };
104 } else if (mem.eql(u8, arg, "--override-lib-dir")) {104 } else if (mem.eql(u8, arg, "--override-lib-dir")) {
...@@ -126,7 +126,7 @@ pub fn main() !void {...@@ -126,7 +126,7 @@ pub fn main() !void {
126 builder.args = argsRest(args, arg_idx);126 builder.args = argsRest(args, arg_idx);
127 break;127 break;
128 } else {128 } else {
129 warn("Unrecognized argument: {}\n\n", .{arg});129 warn("Unrecognized argument: {s}\n\n", .{arg});
130 return usageAndErr(builder, false, stderr_stream);130 return usageAndErr(builder, false, stderr_stream);
131 }131 }
132 } else {132 } else {
...@@ -168,7 +168,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void...@@ -168,7 +168,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void
168 }168 }
169169
170 try out_stream.print(170 try out_stream.print(
171 \\Usage: {} build [steps] [options]171 \\Usage: {s} build [steps] [options]
172 \\172 \\
173 \\Steps:173 \\Steps:
174 \\174 \\
...@@ -177,10 +177,10 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void...@@ -177,10 +177,10 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void
177 const allocator = builder.allocator;177 const allocator = builder.allocator;
178 for (builder.top_level_steps.items) |top_level_step| {178 for (builder.top_level_steps.items) |top_level_step| {
179 const name = if (&top_level_step.step == builder.default_step)179 const name = if (&top_level_step.step == builder.default_step)
180 try fmt.allocPrint(allocator, "{} (default)", .{top_level_step.step.name})180 try fmt.allocPrint(allocator, "{s} (default)", .{top_level_step.step.name})
181 else181 else
182 top_level_step.step.name;182 top_level_step.step.name;
183 try out_stream.print(" {s:<27} {}\n", .{ name, top_level_step.description });183 try out_stream.print(" {s:<27} {s}\n", .{ name, top_level_step.description });
184 }184 }
185185
186 try out_stream.writeAll(186 try out_stream.writeAll(
...@@ -200,12 +200,12 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void...@@ -200,12 +200,12 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void
200 try out_stream.print(" (none)\n", .{});200 try out_stream.print(" (none)\n", .{});
201 } else {201 } else {
202 for (builder.available_options_list.items) |option| {202 for (builder.available_options_list.items) |option| {
203 const name = try fmt.allocPrint(allocator, " -D{}=[{}]", .{203 const name = try fmt.allocPrint(allocator, " -D{s}=[{s}]", .{
204 option.name,204 option.name,
205 Builder.typeIdName(option.type_id),205 Builder.typeIdName(option.type_id),
206 });206 });
207 defer allocator.free(name);207 defer allocator.free(name);
208 try out_stream.print("{s:<29} {}\n", .{ name, option.description });208 try out_stream.print("{s:<29} {s}\n", .{ name, option.description });
209 }209 }
210 }210 }
211211
test/src/compare_output.zig+3-3
...@@ -97,7 +97,7 @@ pub const CompareOutputContext = struct {...@@ -97,7 +97,7 @@ pub const CompareOutputContext = struct {
9797
98 switch (case.special) {98 switch (case.special) {
99 Special.Asm => {99 Special.Asm => {
100 const annotated_case_name = fmt.allocPrint(self.b.allocator, "assemble-and-link {}", .{100 const annotated_case_name = fmt.allocPrint(self.b.allocator, "assemble-and-link {s}", .{
101 case.name,101 case.name,
102 }) catch unreachable;102 }) catch unreachable;
103 if (self.test_filter) |filter| {103 if (self.test_filter) |filter| {
...@@ -116,7 +116,7 @@ pub const CompareOutputContext = struct {...@@ -116,7 +116,7 @@ pub const CompareOutputContext = struct {
116 },116 },
117 Special.None => {117 Special.None => {
118 for (self.modes) |mode| {118 for (self.modes) |mode| {
119 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{} {} ({})", .{119 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{s} {s} ({s})", .{
120 "compare-output",120 "compare-output",
121 case.name,121 case.name,
122 @tagName(mode),122 @tagName(mode),
...@@ -141,7 +141,7 @@ pub const CompareOutputContext = struct {...@@ -141,7 +141,7 @@ pub const CompareOutputContext = struct {
141 }141 }
142 },142 },
143 Special.RuntimeSafety => {143 Special.RuntimeSafety => {
144 const annotated_case_name = fmt.allocPrint(self.b.allocator, "safety {}", .{case.name}) catch unreachable;144 const annotated_case_name = fmt.allocPrint(self.b.allocator, "safety {s}", .{case.name}) catch unreachable;
145 if (self.test_filter) |filter| {145 if (self.test_filter) |filter| {
146 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;146 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
147 }147 }
test/src/run_translated_c.zig+4-4
...@@ -77,7 +77,7 @@ pub const RunTranslatedCContext = struct {...@@ -77,7 +77,7 @@ pub const RunTranslatedCContext = struct {
77 pub fn addCase(self: *RunTranslatedCContext, case: *const TestCase) void {77 pub fn addCase(self: *RunTranslatedCContext, case: *const TestCase) void {
78 const b = self.b;78 const b = self.b;
7979
80 const annotated_case_name = fmt.allocPrint(self.b.allocator, "run-translated-c {}", .{case.name}) catch unreachable;80 const annotated_case_name = fmt.allocPrint(self.b.allocator, "run-translated-c {s}", .{case.name}) catch unreachable;
81 if (self.test_filter) |filter| {81 if (self.test_filter) |filter| {
82 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;82 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
83 }83 }
...@@ -92,13 +92,13 @@ pub const RunTranslatedCContext = struct {...@@ -92,13 +92,13 @@ pub const RunTranslatedCContext = struct {
92 .basename = case.sources.items[0].filename,92 .basename = case.sources.items[0].filename,
93 },93 },
94 });94 });
95 translate_c.step.name = b.fmt("{} translate-c", .{annotated_case_name});95 translate_c.step.name = b.fmt("{s} translate-c", .{annotated_case_name});
96 const exe = translate_c.addExecutable();96 const exe = translate_c.addExecutable();
97 exe.setTarget(self.target);97 exe.setTarget(self.target);
98 exe.step.name = b.fmt("{} build-exe", .{annotated_case_name});98 exe.step.name = b.fmt("{s} build-exe", .{annotated_case_name});
99 exe.linkLibC();99 exe.linkLibC();
100 const run = exe.run();100 const run = exe.run();
101 run.step.name = b.fmt("{} run", .{annotated_case_name});101 run.step.name = b.fmt("{s} run", .{annotated_case_name});
102 if (!case.allow_warnings) {102 if (!case.allow_warnings) {
103 run.expectStdErrEqual("");103 run.expectStdErrEqual("");
104 }104 }
test/src/translate_c.zig+1-1
...@@ -99,7 +99,7 @@ pub const TranslateCContext = struct {...@@ -99,7 +99,7 @@ pub const TranslateCContext = struct {
99 const b = self.b;99 const b = self.b;
100100
101 const translate_c_cmd = "translate-c";101 const translate_c_cmd = "translate-c";
102 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{} {}", .{ translate_c_cmd, case.name }) catch unreachable;102 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{s} {s}", .{ translate_c_cmd, case.name }) catch unreachable;
103 if (self.test_filter) |filter| {103 if (self.test_filter) |filter| {
104 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;104 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
105 }105 }
test/tests.zig+31-31
...@@ -482,7 +482,7 @@ pub fn addPkgTests(...@@ -482,7 +482,7 @@ pub fn addPkgTests(
482 is_wasmtime_enabled: bool,482 is_wasmtime_enabled: bool,
483 glibc_dir: ?[]const u8,483 glibc_dir: ?[]const u8,
484) *build.Step {484) *build.Step {
485 const step = b.step(b.fmt("test-{}", .{name}), desc);485 const step = b.step(b.fmt("test-{s}", .{name}), desc);
486486
487 for (test_targets) |test_target| {487 for (test_targets) |test_target| {
488 if (skip_non_native and !test_target.target.isNative())488 if (skip_non_native and !test_target.target.isNative())
...@@ -523,7 +523,7 @@ pub fn addPkgTests(...@@ -523,7 +523,7 @@ pub fn addPkgTests(
523523
524 const these_tests = b.addTest(root_src);524 const these_tests = b.addTest(root_src);
525 const single_threaded_txt = if (test_target.single_threaded) "single" else "multi";525 const single_threaded_txt = if (test_target.single_threaded) "single" else "multi";
526 these_tests.setNamePrefix(b.fmt("{}-{}-{}-{}-{} ", .{526 these_tests.setNamePrefix(b.fmt("{s}-{s}-{s}-{s}-{s} ", .{
527 name,527 name,
528 triple_prefix,528 triple_prefix,
529 @tagName(test_target.mode),529 @tagName(test_target.mode),
...@@ -570,7 +570,7 @@ pub const StackTracesContext = struct {...@@ -570,7 +570,7 @@ pub const StackTracesContext = struct {
570 const expect_for_mode = expect[@enumToInt(mode)];570 const expect_for_mode = expect[@enumToInt(mode)];
571 if (expect_for_mode.len == 0) continue;571 if (expect_for_mode.len == 0) continue;
572572
573 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{} {} ({})", .{573 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{s} {s} ({s})", .{
574 "stack-trace",574 "stack-trace",
575 name,575 name,
576 @tagName(mode),576 @tagName(mode),
...@@ -637,7 +637,7 @@ pub const StackTracesContext = struct {...@@ -637,7 +637,7 @@ pub const StackTracesContext = struct {
637 defer args.deinit();637 defer args.deinit();
638 args.append(full_exe_path) catch unreachable;638 args.append(full_exe_path) catch unreachable;
639639
640 warn("Test {}/{} {}...", .{ self.test_index + 1, self.context.test_index, self.name });640 warn("Test {d}/{d} {s}...", .{ self.test_index + 1, self.context.test_index, self.name });
641641
642 const child = std.ChildProcess.init(args.items, b.allocator) catch unreachable;642 const child = std.ChildProcess.init(args.items, b.allocator) catch unreachable;
643 defer child.deinit();643 defer child.deinit();
...@@ -650,7 +650,7 @@ pub const StackTracesContext = struct {...@@ -650,7 +650,7 @@ pub const StackTracesContext = struct {
650 if (b.verbose) {650 if (b.verbose) {
651 printInvocation(args.items);651 printInvocation(args.items);
652 }652 }
653 child.spawn() catch |err| debug.panic("Unable to spawn {}: {}\n", .{ full_exe_path, @errorName(err) });653 child.spawn() catch |err| debug.panic("Unable to spawn {s}: {s}\n", .{ full_exe_path, @errorName(err) });
654654
655 const stdout = child.stdout.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable;655 const stdout = child.stdout.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable;
656 defer b.allocator.free(stdout);656 defer b.allocator.free(stdout);
...@@ -659,14 +659,14 @@ pub const StackTracesContext = struct {...@@ -659,14 +659,14 @@ pub const StackTracesContext = struct {
659 var stderr = stderrFull;659 var stderr = stderrFull;
660660
661 const term = child.wait() catch |err| {661 const term = child.wait() catch |err| {
662 debug.panic("Unable to spawn {}: {}\n", .{ full_exe_path, @errorName(err) });662 debug.panic("Unable to spawn {s}: {s}\n", .{ full_exe_path, @errorName(err) });
663 };663 };
664664
665 switch (term) {665 switch (term) {
666 .Exited => |code| {666 .Exited => |code| {
667 const expect_code: u32 = 1;667 const expect_code: u32 = 1;
668 if (code != expect_code) {668 if (code != expect_code) {
669 warn("Process {} exited with error code {} but expected code {}\n", .{669 warn("Process {s} exited with error code {d} but expected code {d}\n", .{
670 full_exe_path,670 full_exe_path,
671 code,671 code,
672 expect_code,672 expect_code,
...@@ -676,17 +676,17 @@ pub const StackTracesContext = struct {...@@ -676,17 +676,17 @@ pub const StackTracesContext = struct {
676 }676 }
677 },677 },
678 .Signal => |signum| {678 .Signal => |signum| {
679 warn("Process {} terminated on signal {}\n", .{ full_exe_path, signum });679 warn("Process {s} terminated on signal {d}\n", .{ full_exe_path, signum });
680 printInvocation(args.items);680 printInvocation(args.items);
681 return error.TestFailed;681 return error.TestFailed;
682 },682 },
683 .Stopped => |signum| {683 .Stopped => |signum| {
684 warn("Process {} stopped on signal {}\n", .{ full_exe_path, signum });684 warn("Process {s} stopped on signal {d}\n", .{ full_exe_path, signum });
685 printInvocation(args.items);685 printInvocation(args.items);
686 return error.TestFailed;686 return error.TestFailed;
687 },687 },
688 .Unknown => |code| {688 .Unknown => |code| {
689 warn("Process {} terminated unexpectedly with error code {}\n", .{ full_exe_path, code });689 warn("Process {s} terminated unexpectedly with error code {d}\n", .{ full_exe_path, code });
690 printInvocation(args.items);690 printInvocation(args.items);
691 return error.TestFailed;691 return error.TestFailed;
692 },692 },
...@@ -732,9 +732,9 @@ pub const StackTracesContext = struct {...@@ -732,9 +732,9 @@ pub const StackTracesContext = struct {
732 warn(732 warn(
733 \\733 \\
734 \\========= Expected this output: =========734 \\========= Expected this output: =========
735 \\{}735 \\{s}
736 \\================================================736 \\================================================
737 \\{}737 \\{s}
738 \\738 \\
739 , .{ self.expect_output, got });739 , .{ self.expect_output, got });
740 return error.TestFailed;740 return error.TestFailed;
...@@ -856,7 +856,7 @@ pub const CompileErrorContext = struct {...@@ -856,7 +856,7 @@ pub const CompileErrorContext = struct {
856 zig_args.append("-O") catch unreachable;856 zig_args.append("-O") catch unreachable;
857 zig_args.append(@tagName(self.build_mode)) catch unreachable;857 zig_args.append(@tagName(self.build_mode)) catch unreachable;
858858
859 warn("Test {}/{} {}...", .{ self.test_index + 1, self.context.test_index, self.name });859 warn("Test {d}/{d} {s}...", .{ self.test_index + 1, self.context.test_index, self.name });
860860
861 if (b.verbose) {861 if (b.verbose) {
862 printInvocation(zig_args.items);862 printInvocation(zig_args.items);
...@@ -870,7 +870,7 @@ pub const CompileErrorContext = struct {...@@ -870,7 +870,7 @@ pub const CompileErrorContext = struct {
870 child.stdout_behavior = .Pipe;870 child.stdout_behavior = .Pipe;
871 child.stderr_behavior = .Pipe;871 child.stderr_behavior = .Pipe;
872872
873 child.spawn() catch |err| debug.panic("Unable to spawn {}: {}\n", .{ zig_args.items[0], @errorName(err) });873 child.spawn() catch |err| debug.panic("Unable to spawn {s}: {s}\n", .{ zig_args.items[0], @errorName(err) });
874874
875 var stdout_buf = ArrayList(u8).init(b.allocator);875 var stdout_buf = ArrayList(u8).init(b.allocator);
876 var stderr_buf = ArrayList(u8).init(b.allocator);876 var stderr_buf = ArrayList(u8).init(b.allocator);
...@@ -879,7 +879,7 @@ pub const CompileErrorContext = struct {...@@ -879,7 +879,7 @@ pub const CompileErrorContext = struct {
879 child.stderr.?.inStream().readAllArrayList(&stderr_buf, max_stdout_size) catch unreachable;879 child.stderr.?.inStream().readAllArrayList(&stderr_buf, max_stdout_size) catch unreachable;
880880
881 const term = child.wait() catch |err| {881 const term = child.wait() catch |err| {
882 debug.panic("Unable to spawn {}: {}\n", .{ zig_args.items[0], @errorName(err) });882 debug.panic("Unable to spawn {s}: {s}\n", .{ zig_args.items[0], @errorName(err) });
883 };883 };
884 switch (term) {884 switch (term) {
885 .Exited => |code| {885 .Exited => |code| {
...@@ -889,7 +889,7 @@ pub const CompileErrorContext = struct {...@@ -889,7 +889,7 @@ pub const CompileErrorContext = struct {
889 }889 }
890 },890 },
891 else => {891 else => {
892 warn("Process {} terminated unexpectedly\n", .{b.zig_exe});892 warn("Process {s} terminated unexpectedly\n", .{b.zig_exe});
893 printInvocation(zig_args.items);893 printInvocation(zig_args.items);
894 return error.TestFailed;894 return error.TestFailed;
895 },895 },
...@@ -903,7 +903,7 @@ pub const CompileErrorContext = struct {...@@ -903,7 +903,7 @@ pub const CompileErrorContext = struct {
903 \\903 \\
904 \\Expected empty stdout, instead found:904 \\Expected empty stdout, instead found:
905 \\================================================905 \\================================================
906 \\{}906 \\{s}
907 \\================================================907 \\================================================
908 \\908 \\
909 , .{stdout});909 , .{stdout});
...@@ -926,7 +926,7 @@ pub const CompileErrorContext = struct {...@@ -926,7 +926,7 @@ pub const CompileErrorContext = struct {
926 if (!ok) {926 if (!ok) {
927 warn("\n======== Expected these compile errors: ========\n", .{});927 warn("\n======== Expected these compile errors: ========\n", .{});
928 for (self.case.expected_errors.items) |expected| {928 for (self.case.expected_errors.items) |expected| {
929 warn("{}\n", .{expected});929 warn("{s}\n", .{expected});
930 }930 }
931 }931 }
932 } else {932 } else {
...@@ -935,7 +935,7 @@ pub const CompileErrorContext = struct {...@@ -935,7 +935,7 @@ pub const CompileErrorContext = struct {
935 warn(935 warn(
936 \\936 \\
937 \\=========== Expected compile error: ============937 \\=========== Expected compile error: ============
938 \\{}938 \\{s}
939 \\939 \\
940 , .{expected});940 , .{expected});
941 ok = false;941 ok = false;
...@@ -947,7 +947,7 @@ pub const CompileErrorContext = struct {...@@ -947,7 +947,7 @@ pub const CompileErrorContext = struct {
947 if (!ok) {947 if (!ok) {
948 warn(948 warn(
949 \\================= Full output: =================949 \\================= Full output: =================
950 \\{}950 \\{s}
951 \\951 \\
952 , .{stderr});952 , .{stderr});
953 return error.TestFailed;953 return error.TestFailed;
...@@ -1023,7 +1023,7 @@ pub const CompileErrorContext = struct {...@@ -1023,7 +1023,7 @@ pub const CompileErrorContext = struct {
1023 pub fn addCase(self: *CompileErrorContext, case: *const TestCase) void {1023 pub fn addCase(self: *CompileErrorContext, case: *const TestCase) void {
1024 const b = self.b;1024 const b = self.b;
10251025
1026 const annotated_case_name = fmt.allocPrint(self.b.allocator, "compile-error {}", .{1026 const annotated_case_name = fmt.allocPrint(self.b.allocator, "compile-error {s}", .{
1027 case.name,1027 case.name,
1028 }) catch unreachable;1028 }) catch unreachable;
1029 if (self.test_filter) |filter| {1029 if (self.test_filter) |filter| {
...@@ -1058,7 +1058,7 @@ pub const StandaloneContext = struct {...@@ -1058,7 +1058,7 @@ pub const StandaloneContext = struct {
1058 pub fn addBuildFile(self: *StandaloneContext, build_file: []const u8) void {1058 pub fn addBuildFile(self: *StandaloneContext, build_file: []const u8) void {
1059 const b = self.b;1059 const b = self.b;
10601060
1061 const annotated_case_name = b.fmt("build {} (Debug)", .{build_file});1061 const annotated_case_name = b.fmt("build {s} (Debug)", .{build_file});
1062 if (self.test_filter) |filter| {1062 if (self.test_filter) |filter| {
1063 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;1063 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
1064 }1064 }
...@@ -1079,7 +1079,7 @@ pub const StandaloneContext = struct {...@@ -1079,7 +1079,7 @@ pub const StandaloneContext = struct {
10791079
1080 const run_cmd = b.addSystemCommand(zig_args.items);1080 const run_cmd = b.addSystemCommand(zig_args.items);
10811081
1082 const log_step = b.addLog("PASS {}\n", .{annotated_case_name});1082 const log_step = b.addLog("PASS {s}\n", .{annotated_case_name});
1083 log_step.step.dependOn(&run_cmd.step);1083 log_step.step.dependOn(&run_cmd.step);
10841084
1085 self.step.dependOn(&log_step.step);1085 self.step.dependOn(&log_step.step);
...@@ -1089,7 +1089,7 @@ pub const StandaloneContext = struct {...@@ -1089,7 +1089,7 @@ pub const StandaloneContext = struct {
1089 const b = self.b;1089 const b = self.b;
10901090
1091 for (self.modes) |mode| {1091 for (self.modes) |mode| {
1092 const annotated_case_name = fmt.allocPrint(self.b.allocator, "build {} ({})", .{1092 const annotated_case_name = fmt.allocPrint(self.b.allocator, "build {s} ({s})", .{
1093 root_src,1093 root_src,
1094 @tagName(mode),1094 @tagName(mode),
1095 }) catch unreachable;1095 }) catch unreachable;
...@@ -1103,7 +1103,7 @@ pub const StandaloneContext = struct {...@@ -1103,7 +1103,7 @@ pub const StandaloneContext = struct {
1103 exe.linkSystemLibrary("c");1103 exe.linkSystemLibrary("c");
1104 }1104 }
11051105
1106 const log_step = b.addLog("PASS {}\n", .{annotated_case_name});1106 const log_step = b.addLog("PASS {s}\n", .{annotated_case_name});
1107 log_step.step.dependOn(&exe.step);1107 log_step.step.dependOn(&exe.step);
11081108
1109 self.step.dependOn(&log_step.step);1109 self.step.dependOn(&log_step.step);
...@@ -1172,7 +1172,7 @@ pub const GenHContext = struct {...@@ -1172,7 +1172,7 @@ pub const GenHContext = struct {
1172 const self = @fieldParentPtr(GenHCmpOutputStep, "step", step);1172 const self = @fieldParentPtr(GenHCmpOutputStep, "step", step);
1173 const b = self.context.b;1173 const b = self.context.b;
11741174
1175 warn("Test {}/{} {}...", .{ self.test_index + 1, self.context.test_index, self.name });1175 warn("Test {d}/{d} {s}...", .{ self.test_index + 1, self.context.test_index, self.name });
11761176
1177 const full_h_path = self.obj.getOutputHPath();1177 const full_h_path = self.obj.getOutputHPath();
1178 const actual_h = try io.readFileAlloc(b.allocator, full_h_path);1178 const actual_h = try io.readFileAlloc(b.allocator, full_h_path);
...@@ -1182,9 +1182,9 @@ pub const GenHContext = struct {...@@ -1182,9 +1182,9 @@ pub const GenHContext = struct {
1182 warn(1182 warn(
1183 \\1183 \\
1184 \\========= Expected this output: ================1184 \\========= Expected this output: ================
1185 \\{}1185 \\{s}
1186 \\========= But found: ===========================1186 \\========= But found: ===========================
1187 \\{}1187 \\{s}
1188 \\1188 \\
1189 , .{ expected_line, actual_h });1189 , .{ expected_line, actual_h });
1190 return error.TestFailed;1190 return error.TestFailed;
...@@ -1196,7 +1196,7 @@ pub const GenHContext = struct {...@@ -1196,7 +1196,7 @@ pub const GenHContext = struct {
11961196
1197 fn printInvocation(args: []const []const u8) void {1197 fn printInvocation(args: []const []const u8) void {
1198 for (args) |arg| {1198 for (args) |arg| {
1199 warn("{} ", .{arg});1199 warn("{s} ", .{arg});
1200 }1200 }
1201 warn("\n", .{});1201 warn("\n", .{});
1202 }1202 }
...@@ -1232,7 +1232,7 @@ pub const GenHContext = struct {...@@ -1232,7 +1232,7 @@ pub const GenHContext = struct {
1232 const b = self.b;1232 const b = self.b;
12331233
1234 const mode = builtin.Mode.Debug;1234 const mode = builtin.Mode.Debug;
1235 const annotated_case_name = fmt.allocPrint(self.b.allocator, "gen-h {} ({})", .{ case.name, @tagName(mode) }) catch unreachable;1235 const annotated_case_name = fmt.allocPrint(self.b.allocator, "gen-h {s} ({s})", .{ case.name, @tagName(mode) }) catch unreachable;
1236 if (self.test_filter) |filter| {1236 if (self.test_filter) |filter| {
1237 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;1237 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
1238 }1238 }
...@@ -1253,7 +1253,7 @@ pub const GenHContext = struct {...@@ -1253,7 +1253,7 @@ pub const GenHContext = struct {
12531253
1254fn printInvocation(args: []const []const u8) void {1254fn printInvocation(args: []const []const u8) void {
1255 for (args) |arg| {1255 for (args) |arg| {
1256 warn("{} ", .{arg});1256 warn("{s} ", .{arg});
1257 }1257 }
1258 warn("\n", .{});1258 warn("\n", .{});
1259}1259}