authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-12-16 15:37:10+00:00
committergravatar for bratishkaerik@landless-city.netEric Joldasov <bratishkaerik@landless-city.net> 2024-12-18 01:49:03+05:00
log8c5c1de60b71b4310ae629c30e3c7b0df3575341
tree0526c836b567d4b7683c36508fdfe2b44e318479
parent11b99339702fc91bfab912fb4ddc45995bdbfdb0
signaturelock-open Commit is signed but in an unrecognized format.

test-compare-output: migrate from deprecated std.Build APIs


1 files changed, 23 insertions(+), 21 deletions(-)

test/src/CompareOutput.zig+23-21
......@@ -89,19 +89,22 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {
8989
9090 switch (case.special) {
9191 Special.Asm => {
92 const annotated_case_name = fmt.allocPrint(self.b.allocator, "run assemble-and-link {s}", .{
92 const annotated_case_name = b.fmt("run assemble-and-link {s}", .{
9393 case.name,
94 }) catch @panic("OOM");
94 });
9595 for (self.test_filters) |test_filter| {
9696 if (mem.indexOf(u8, annotated_case_name, test_filter)) |_| break;
9797 } else if (self.test_filters.len > 0) return;
9898
9999 const exe = b.addExecutable(.{
100100 .name = "test",
101 .target = b.graph.host,
102 .optimize = .Debug,
101 .root_module = b.createModule(.{
102 .root_source_file = null,
103 .target = b.graph.host,
104 .optimize = .Debug,
105 }),
103106 });
104 exe.addAssemblyFile(first_file);
107 exe.root_module.addAssemblyFile(first_file);
105108
106109 const run = b.addRunArtifact(exe);
107110 run.setName(annotated_case_name);
......@@ -112,22 +115,22 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {
112115 },
113116 Special.None => {
114117 for (self.optimize_modes) |optimize| {
115 const annotated_case_name = fmt.allocPrint(self.b.allocator, "run compare-output {s} ({s})", .{
118 const annotated_case_name = b.fmt("run compare-output {s} ({s})", .{
116119 case.name, @tagName(optimize),
117 }) catch @panic("OOM");
120 });
118121 for (self.test_filters) |test_filter| {
119122 if (mem.indexOf(u8, annotated_case_name, test_filter)) |_| break;
120123 } else if (self.test_filters.len > 0) return;
121124
122125 const exe = b.addExecutable(.{
123126 .name = "test",
124 .root_source_file = first_file,
125 .optimize = optimize,
126 .target = b.graph.host,
127 .root_module = b.createModule(.{
128 .root_source_file = first_file,
129 .optimize = optimize,
130 .target = b.graph.host,
131 }),
127132 });
128 if (case.link_libc) {
129 exe.linkSystemLibrary("c");
130 }
133 if (case.link_libc) exe.root_module.link_libc = true;
131134
132135 const run = b.addRunArtifact(exe);
133136 run.setName(annotated_case_name);
......@@ -140,20 +143,20 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {
140143 Special.RuntimeSafety => {
141144 // TODO iterate over self.optimize_modes and test this in both
142145 // debug and release safe mode
143 const annotated_case_name = fmt.allocPrint(self.b.allocator, "run safety {s}", .{case.name}) catch @panic("OOM");
146 const annotated_case_name = b.fmt("run safety {s}", .{case.name});
144147 for (self.test_filters) |test_filter| {
145148 if (mem.indexOf(u8, annotated_case_name, test_filter)) |_| break;
146149 } else if (self.test_filters.len > 0) return;
147150
148151 const exe = b.addExecutable(.{
149152 .name = "test",
150 .root_source_file = first_file,
151 .target = b.graph.host,
152 .optimize = .Debug,
153 .root_module = b.createModule(.{
154 .root_source_file = first_file,
155 .target = b.graph.host,
156 .optimize = .Debug,
157 }),
153158 });
154 if (case.link_libc) {
155 exe.linkSystemLibrary("c");
156 }
159 if (case.link_libc) exe.root_module.link_libc = true;
157160
158161 const run = b.addRunArtifact(exe);
159162 run.setName(annotated_case_name);
......@@ -168,7 +171,6 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {
168171const CompareOutput = @This();
169172const std = @import("std");
170173const ArrayList = std.ArrayList;
171const fmt = std.fmt;
172174const mem = std.mem;
173175const fs = std.fs;
174176const OptimizeMode = std.builtin.OptimizeMode;