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 {
224224
225225 const opt_version_string = b.option([]const u8, "version-string", "Override Zig version string. Default is to find out with git.");
226226 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
229229 var code: u8 = undefined;
230230 const git_describe_untrimmed = b.execAllowFail(&[_][]const u8{
......@@ -238,7 +238,7 @@ pub fn build(b: *Builder) !void {
238238 0 => {
239239 // Tagged release version (e.g. 0.7.0).
240240 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 });
242242 std.process.exit(1);
243243 }
244244 break :v version_string;
......@@ -258,15 +258,15 @@ pub fn build(b: *Builder) !void {
258258
259259 // Check that the commit hash is prefixed with a 'g' (a Git convention).
260260 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});
262262 break :v version_string;
263263 }
264264
265265 // 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..] });
267267 },
268268 else => {
269 std.debug.print("Unexpected `git describe` output: {}\n", .{git_describe});
269 std.debug.print("Unexpected `git describe` output: {s}\n", .{git_describe});
270270 break :v version_string;
271271 },
272272 }
......@@ -359,6 +359,195 @@ pub fn build(b: *Builder) !void {
359359 test_step.dependOn(docs_step);
360360}
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
362551fn addCxxKnownPath(
363552 b: *Builder,
364553 ctx: CMakeConfig,
......@@ -369,14 +558,14 @@ fn addCxxKnownPath(
369558) !void {
370559 const path_padded = try b.exec(&[_][]const u8{
371560 ctx.cxx_compiler,
372 b.fmt("-print-file-name={}", .{objname}),
561 b.fmt("-print-file-name={s}", .{objname}),
373562 });
374563 const path_unpadded = mem.tokenize(path_padded, "\r\n").next().?;
375564 if (mem.eql(u8, path_unpadded, objname)) {
376565 if (errtxt) |msg| {
377 warn("{}", .{msg});
566 warn("{s}", .{msg});
378567 } else {
379 warn("Unable to determine path to {}\n", .{objname});
568 warn("Unable to determine path to {s}\n", .{objname});
380569 }
381570 return error.RequiredLibraryNotFound;
382571 }
lib/std/special/build_runner.zig+7-7
......@@ -98,7 +98,7 @@ pub fn main() !void {
9898 return usageAndErr(builder, false, stderr_stream);
9999 };
100100 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});
102102 return usageAndErr(builder, false, stderr_stream);
103103 };
104104 } else if (mem.eql(u8, arg, "--override-lib-dir")) {
......@@ -126,7 +126,7 @@ pub fn main() !void {
126126 builder.args = argsRest(args, arg_idx);
127127 break;
128128 } else {
129 warn("Unrecognized argument: {}\n\n", .{arg});
129 warn("Unrecognized argument: {s}\n\n", .{arg});
130130 return usageAndErr(builder, false, stderr_stream);
131131 }
132132 } else {
......@@ -168,7 +168,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void
168168 }
169169
170170 try out_stream.print(
171 \\Usage: {} build [steps] [options]
171 \\Usage: {s} build [steps] [options]
172172 \\
173173 \\Steps:
174174 \\
......@@ -177,10 +177,10 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void
177177 const allocator = builder.allocator;
178178 for (builder.top_level_steps.items) |top_level_step| {
179179 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})
181181 else
182182 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 });
184184 }
185185
186186 try out_stream.writeAll(
......@@ -200,12 +200,12 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void
200200 try out_stream.print(" (none)\n", .{});
201201 } else {
202202 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}]", .{
204204 option.name,
205205 Builder.typeIdName(option.type_id),
206206 });
207207 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 });
209209 }
210210 }
211211
test/src/compare_output.zig+3-3
......@@ -97,7 +97,7 @@ pub const CompareOutputContext = struct {
9797
9898 switch (case.special) {
9999 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}", .{
101101 case.name,
102102 }) catch unreachable;
103103 if (self.test_filter) |filter| {
......@@ -116,7 +116,7 @@ pub const CompareOutputContext = struct {
116116 },
117117 Special.None => {
118118 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})", .{
120120 "compare-output",
121121 case.name,
122122 @tagName(mode),
......@@ -141,7 +141,7 @@ pub const CompareOutputContext = struct {
141141 }
142142 },
143143 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;
145145 if (self.test_filter) |filter| {
146146 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
147147 }
test/src/run_translated_c.zig+4-4
......@@ -77,7 +77,7 @@ pub const RunTranslatedCContext = struct {
7777 pub fn addCase(self: *RunTranslatedCContext, case: *const TestCase) void {
7878 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;
8181 if (self.test_filter) |filter| {
8282 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
8383 }
......@@ -92,13 +92,13 @@ pub const RunTranslatedCContext = struct {
9292 .basename = case.sources.items[0].filename,
9393 },
9494 });
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});
9696 const exe = translate_c.addExecutable();
9797 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});
9999 exe.linkLibC();
100100 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});
102102 if (!case.allow_warnings) {
103103 run.expectStdErrEqual("");
104104 }
test/src/translate_c.zig+1-1
......@@ -99,7 +99,7 @@ pub const TranslateCContext = struct {
9999 const b = self.b;
100100
101101 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;
103103 if (self.test_filter) |filter| {
104104 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
105105 }
test/tests.zig+31-31
......@@ -482,7 +482,7 @@ pub fn addPkgTests(
482482 is_wasmtime_enabled: bool,
483483 glibc_dir: ?[]const u8,
484484) *build.Step {
485 const step = b.step(b.fmt("test-{}", .{name}), desc);
485 const step = b.step(b.fmt("test-{s}", .{name}), desc);
486486
487487 for (test_targets) |test_target| {
488488 if (skip_non_native and !test_target.target.isNative())
......@@ -523,7 +523,7 @@ pub fn addPkgTests(
523523
524524 const these_tests = b.addTest(root_src);
525525 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} ", .{
527527 name,
528528 triple_prefix,
529529 @tagName(test_target.mode),
......@@ -570,7 +570,7 @@ pub const StackTracesContext = struct {
570570 const expect_for_mode = expect[@enumToInt(mode)];
571571 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})", .{
574574 "stack-trace",
575575 name,
576576 @tagName(mode),
......@@ -637,7 +637,7 @@ pub const StackTracesContext = struct {
637637 defer args.deinit();
638638 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
642642 const child = std.ChildProcess.init(args.items, b.allocator) catch unreachable;
643643 defer child.deinit();
......@@ -650,7 +650,7 @@ pub const StackTracesContext = struct {
650650 if (b.verbose) {
651651 printInvocation(args.items);
652652 }
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
655655 const stdout = child.stdout.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable;
656656 defer b.allocator.free(stdout);
......@@ -659,14 +659,14 @@ pub const StackTracesContext = struct {
659659 var stderr = stderrFull;
660660
661661 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) });
663663 };
664664
665665 switch (term) {
666666 .Exited => |code| {
667667 const expect_code: u32 = 1;
668668 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", .{
670670 full_exe_path,
671671 code,
672672 expect_code,
......@@ -676,17 +676,17 @@ pub const StackTracesContext = struct {
676676 }
677677 },
678678 .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 });
680680 printInvocation(args.items);
681681 return error.TestFailed;
682682 },
683683 .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 });
685685 printInvocation(args.items);
686686 return error.TestFailed;
687687 },
688688 .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 });
690690 printInvocation(args.items);
691691 return error.TestFailed;
692692 },
......@@ -732,9 +732,9 @@ pub const StackTracesContext = struct {
732732 warn(
733733 \\
734734 \\========= Expected this output: =========
735 \\{}
735 \\{s}
736736 \\================================================
737 \\{}
737 \\{s}
738738 \\
739739 , .{ self.expect_output, got });
740740 return error.TestFailed;
......@@ -856,7 +856,7 @@ pub const CompileErrorContext = struct {
856856 zig_args.append("-O") catch unreachable;
857857 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
861861 if (b.verbose) {
862862 printInvocation(zig_args.items);
......@@ -870,7 +870,7 @@ pub const CompileErrorContext = struct {
870870 child.stdout_behavior = .Pipe;
871871 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
875875 var stdout_buf = ArrayList(u8).init(b.allocator);
876876 var stderr_buf = ArrayList(u8).init(b.allocator);
......@@ -879,7 +879,7 @@ pub const CompileErrorContext = struct {
879879 child.stderr.?.inStream().readAllArrayList(&stderr_buf, max_stdout_size) catch unreachable;
880880
881881 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) });
883883 };
884884 switch (term) {
885885 .Exited => |code| {
......@@ -889,7 +889,7 @@ pub const CompileErrorContext = struct {
889889 }
890890 },
891891 else => {
892 warn("Process {} terminated unexpectedly\n", .{b.zig_exe});
892 warn("Process {s} terminated unexpectedly\n", .{b.zig_exe});
893893 printInvocation(zig_args.items);
894894 return error.TestFailed;
895895 },
......@@ -903,7 +903,7 @@ pub const CompileErrorContext = struct {
903903 \\
904904 \\Expected empty stdout, instead found:
905905 \\================================================
906 \\{}
906 \\{s}
907907 \\================================================
908908 \\
909909 , .{stdout});
......@@ -926,7 +926,7 @@ pub const CompileErrorContext = struct {
926926 if (!ok) {
927927 warn("\n======== Expected these compile errors: ========\n", .{});
928928 for (self.case.expected_errors.items) |expected| {
929 warn("{}\n", .{expected});
929 warn("{s}\n", .{expected});
930930 }
931931 }
932932 } else {
......@@ -935,7 +935,7 @@ pub const CompileErrorContext = struct {
935935 warn(
936936 \\
937937 \\=========== Expected compile error: ============
938 \\{}
938 \\{s}
939939 \\
940940 , .{expected});
941941 ok = false;
......@@ -947,7 +947,7 @@ pub const CompileErrorContext = struct {
947947 if (!ok) {
948948 warn(
949949 \\================= Full output: =================
950 \\{}
950 \\{s}
951951 \\
952952 , .{stderr});
953953 return error.TestFailed;
......@@ -1023,7 +1023,7 @@ pub const CompileErrorContext = struct {
10231023 pub fn addCase(self: *CompileErrorContext, case: *const TestCase) void {
10241024 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}", .{
10271027 case.name,
10281028 }) catch unreachable;
10291029 if (self.test_filter) |filter| {
......@@ -1058,7 +1058,7 @@ pub const StandaloneContext = struct {
10581058 pub fn addBuildFile(self: *StandaloneContext, build_file: []const u8) void {
10591059 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});
10621062 if (self.test_filter) |filter| {
10631063 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
10641064 }
......@@ -1079,7 +1079,7 @@ pub const StandaloneContext = struct {
10791079
10801080 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});
10831083 log_step.step.dependOn(&run_cmd.step);
10841084
10851085 self.step.dependOn(&log_step.step);
......@@ -1089,7 +1089,7 @@ pub const StandaloneContext = struct {
10891089 const b = self.b;
10901090
10911091 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})", .{
10931093 root_src,
10941094 @tagName(mode),
10951095 }) catch unreachable;
......@@ -1103,7 +1103,7 @@ pub const StandaloneContext = struct {
11031103 exe.linkSystemLibrary("c");
11041104 }
11051105
1106 const log_step = b.addLog("PASS {}\n", .{annotated_case_name});
1106 const log_step = b.addLog("PASS {s}\n", .{annotated_case_name});
11071107 log_step.step.dependOn(&exe.step);
11081108
11091109 self.step.dependOn(&log_step.step);
......@@ -1172,7 +1172,7 @@ pub const GenHContext = struct {
11721172 const self = @fieldParentPtr(GenHCmpOutputStep, "step", step);
11731173 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
11771177 const full_h_path = self.obj.getOutputHPath();
11781178 const actual_h = try io.readFileAlloc(b.allocator, full_h_path);
......@@ -1182,9 +1182,9 @@ pub const GenHContext = struct {
11821182 warn(
11831183 \\
11841184 \\========= Expected this output: ================
1185 \\{}
1185 \\{s}
11861186 \\========= But found: ===========================
1187 \\{}
1187 \\{s}
11881188 \\
11891189 , .{ expected_line, actual_h });
11901190 return error.TestFailed;
......@@ -1196,7 +1196,7 @@ pub const GenHContext = struct {
11961196
11971197 fn printInvocation(args: []const []const u8) void {
11981198 for (args) |arg| {
1199 warn("{} ", .{arg});
1199 warn("{s} ", .{arg});
12001200 }
12011201 warn("\n", .{});
12021202 }
......@@ -1232,7 +1232,7 @@ pub const GenHContext = struct {
12321232 const b = self.b;
12331233
12341234 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;
12361236 if (self.test_filter) |filter| {
12371237 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
12381238 }
......@@ -1253,7 +1253,7 @@ pub const GenHContext = struct {
12531253
12541254fn printInvocation(args: []const []const u8) void {
12551255 for (args) |arg| {
1256 warn("{} ", .{arg});
1256 warn("{s} ", .{arg});
12571257 }
12581258 warn("\n", .{});
12591259}