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 {...@@ -89,19 +89,22 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {
8989
90 switch (case.special) {90 switch (case.special) {
91 Special.Asm => {91 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}", .{
93 case.name,93 case.name,
94 }) catch @panic("OOM");94 });
95 for (self.test_filters) |test_filter| {95 for (self.test_filters) |test_filter| {
96 if (mem.indexOf(u8, annotated_case_name, test_filter)) |_| break;96 if (mem.indexOf(u8, annotated_case_name, test_filter)) |_| break;
97 } else if (self.test_filters.len > 0) return;97 } else if (self.test_filters.len > 0) return;
9898
99 const exe = b.addExecutable(.{99 const exe = b.addExecutable(.{
100 .name = "test",100 .name = "test",
101 .target = b.graph.host,101 .root_module = b.createModule(.{
102 .optimize = .Debug,102 .root_source_file = null,
103 .target = b.graph.host,
104 .optimize = .Debug,
105 }),
103 });106 });
104 exe.addAssemblyFile(first_file);107 exe.root_module.addAssemblyFile(first_file);
105108
106 const run = b.addRunArtifact(exe);109 const run = b.addRunArtifact(exe);
107 run.setName(annotated_case_name);110 run.setName(annotated_case_name);
...@@ -112,22 +115,22 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {...@@ -112,22 +115,22 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {
112 },115 },
113 Special.None => {116 Special.None => {
114 for (self.optimize_modes) |optimize| {117 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})", .{
116 case.name, @tagName(optimize),119 case.name, @tagName(optimize),
117 }) catch @panic("OOM");120 });
118 for (self.test_filters) |test_filter| {121 for (self.test_filters) |test_filter| {
119 if (mem.indexOf(u8, annotated_case_name, test_filter)) |_| break;122 if (mem.indexOf(u8, annotated_case_name, test_filter)) |_| break;
120 } else if (self.test_filters.len > 0) return;123 } else if (self.test_filters.len > 0) return;
121124
122 const exe = b.addExecutable(.{125 const exe = b.addExecutable(.{
123 .name = "test",126 .name = "test",
124 .root_source_file = first_file,127 .root_module = b.createModule(.{
125 .optimize = optimize,128 .root_source_file = first_file,
126 .target = b.graph.host,129 .optimize = optimize,
130 .target = b.graph.host,
131 }),
127 });132 });
128 if (case.link_libc) {133 if (case.link_libc) exe.root_module.link_libc = true;
129 exe.linkSystemLibrary("c");
130 }
131134
132 const run = b.addRunArtifact(exe);135 const run = b.addRunArtifact(exe);
133 run.setName(annotated_case_name);136 run.setName(annotated_case_name);
...@@ -140,20 +143,20 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {...@@ -140,20 +143,20 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {
140 Special.RuntimeSafety => {143 Special.RuntimeSafety => {
141 // TODO iterate over self.optimize_modes and test this in both144 // TODO iterate over self.optimize_modes and test this in both
142 // debug and release safe mode145 // 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});
144 for (self.test_filters) |test_filter| {147 for (self.test_filters) |test_filter| {
145 if (mem.indexOf(u8, annotated_case_name, test_filter)) |_| break;148 if (mem.indexOf(u8, annotated_case_name, test_filter)) |_| break;
146 } else if (self.test_filters.len > 0) return;149 } else if (self.test_filters.len > 0) return;
147150
148 const exe = b.addExecutable(.{151 const exe = b.addExecutable(.{
149 .name = "test",152 .name = "test",
150 .root_source_file = first_file,153 .root_module = b.createModule(.{
151 .target = b.graph.host,154 .root_source_file = first_file,
152 .optimize = .Debug,155 .target = b.graph.host,
156 .optimize = .Debug,
157 }),
153 });158 });
154 if (case.link_libc) {159 if (case.link_libc) exe.root_module.link_libc = true;
155 exe.linkSystemLibrary("c");
156 }
157160
158 const run = b.addRunArtifact(exe);161 const run = b.addRunArtifact(exe);
159 run.setName(annotated_case_name);162 run.setName(annotated_case_name);
...@@ -168,7 +171,6 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {...@@ -168,7 +171,6 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void {
168const CompareOutput = @This();171const CompareOutput = @This();
169const std = @import("std");172const std = @import("std");
170const ArrayList = std.ArrayList;173const ArrayList = std.ArrayList;
171const fmt = std.fmt;
172const mem = std.mem;174const mem = std.mem;
173const fs = std.fs;175const fs = std.fs;
174const OptimizeMode = std.builtin.OptimizeMode;176const OptimizeMode = std.builtin.OptimizeMode;