aboutsummaryrefslogtreecommitdiff
path: root/test/src
diff options
context:
space:
mode:
Diffstat (limited to 'test/src')
-rw-r--r--test/src/compare_output.zig36
-rw-r--r--test/src/run_translated_c.zig14
-rw-r--r--test/src/translate_c.zig12
3 files changed, 40 insertions, 22 deletions
diff --git a/test/src/compare_output.zig b/test/src/compare_output.zig
index 538e4023f0..edd48321c9 100644
--- a/test/src/compare_output.zig
+++ b/test/src/compare_output.zig
@@ -1,19 +1,18 @@
// This is the implementation of the test harness.
// For the actual test cases, see test/compare_output.zig.
const std = @import("std");
-const build = std.build;
const ArrayList = std.ArrayList;
const fmt = std.fmt;
const mem = std.mem;
const fs = std.fs;
-const Mode = std.builtin.Mode;
+const OptimizeMode = std.builtin.OptimizeMode;
pub const CompareOutputContext = struct {
- b: *build.Builder,
- step: *build.Step,
+ b: *std.Build,
+ step: *std.Build.Step,
test_index: usize,
test_filter: ?[]const u8,
- modes: []const Mode,
+ optimize_modes: []const OptimizeMode,
const Special = enum {
None,
@@ -102,7 +101,11 @@ pub const CompareOutputContext = struct {
if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
}
- const exe = b.addExecutable("test", null);
+ const exe = b.addExecutable(.{
+ .name = "test",
+ .target = .{},
+ .optimize = .Debug,
+ });
exe.addAssemblyFileSource(write_src.getFileSource(case.sources.items[0].filename).?);
const run = exe.run();
@@ -113,19 +116,23 @@ pub const CompareOutputContext = struct {
self.step.dependOn(&run.step);
},
Special.None => {
- for (self.modes) |mode| {
+ for (self.optimize_modes) |optimize| {
const annotated_case_name = fmt.allocPrint(self.b.allocator, "{s} {s} ({s})", .{
"compare-output",
case.name,
- @tagName(mode),
+ @tagName(optimize),
}) catch unreachable;
if (self.test_filter) |filter| {
if (mem.indexOf(u8, annotated_case_name, filter) == null) continue;
}
const basename = case.sources.items[0].filename;
- const exe = b.addExecutableSource("test", write_src.getFileSource(basename).?);
- exe.setBuildMode(mode);
+ const exe = b.addExecutable(.{
+ .name = "test",
+ .root_source_file = write_src.getFileSource(basename).?,
+ .optimize = optimize,
+ .target = .{},
+ });
if (case.link_libc) {
exe.linkSystemLibrary("c");
}
@@ -139,13 +146,20 @@ pub const CompareOutputContext = struct {
}
},
Special.RuntimeSafety => {
+ // TODO iterate over self.optimize_modes and test this in both
+ // debug and release safe mode
const annotated_case_name = fmt.allocPrint(self.b.allocator, "safety {s}", .{case.name}) catch unreachable;
if (self.test_filter) |filter| {
if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
}
const basename = case.sources.items[0].filename;
- const exe = b.addExecutableSource("test", write_src.getFileSource(basename).?);
+ const exe = b.addExecutable(.{
+ .name = "test",
+ .root_source_file = write_src.getFileSource(basename).?,
+ .target = .{},
+ .optimize = .Debug,
+ });
if (case.link_libc) {
exe.linkSystemLibrary("c");
}
diff --git a/test/src/run_translated_c.zig b/test/src/run_translated_c.zig
index 0204272f97..2103172ed6 100644
--- a/test/src/run_translated_c.zig
+++ b/test/src/run_translated_c.zig
@@ -1,15 +1,14 @@
// This is the implementation of the test harness for running translated
// C code. For the actual test cases, see test/run_translated_c.zig.
const std = @import("std");
-const build = std.build;
const ArrayList = std.ArrayList;
const fmt = std.fmt;
const mem = std.mem;
const fs = std.fs;
pub const RunTranslatedCContext = struct {
- b: *build.Builder,
- step: *build.Step,
+ b: *std.Build,
+ step: *std.Build.Step,
test_index: usize,
test_filter: ?[]const u8,
target: std.zig.CrossTarget,
@@ -85,11 +84,14 @@ pub const RunTranslatedCContext = struct {
for (case.sources.items) |src_file| {
write_src.add(src_file.filename, src_file.source);
}
- const translate_c = b.addTranslateC(write_src.getFileSource(case.sources.items[0].filename).?);
+ const translate_c = b.addTranslateC(.{
+ .source_file = write_src.getFileSource(case.sources.items[0].filename).?,
+ .target = .{},
+ .optimize = .Debug,
+ });
translate_c.step.name = b.fmt("{s} translate-c", .{annotated_case_name});
- const exe = translate_c.addExecutable();
- exe.setTarget(self.target);
+ const exe = translate_c.addExecutable(.{});
exe.step.name = b.fmt("{s} build-exe", .{annotated_case_name});
exe.linkLibC();
const run = exe.run();
diff --git a/test/src/translate_c.zig b/test/src/translate_c.zig
index f0f6f30c57..e275ee57ee 100644
--- a/test/src/translate_c.zig
+++ b/test/src/translate_c.zig
@@ -1,7 +1,6 @@
// This is the implementation of the test harness.
// For the actual test cases, see test/translate_c.zig.
const std = @import("std");
-const build = std.build;
const ArrayList = std.ArrayList;
const fmt = std.fmt;
const mem = std.mem;
@@ -9,8 +8,8 @@ const fs = std.fs;
const CrossTarget = std.zig.CrossTarget;
pub const TranslateCContext = struct {
- b: *build.Builder,
- step: *build.Step,
+ b: *std.Build,
+ step: *std.Build.Step,
test_index: usize,
test_filter: ?[]const u8,
@@ -108,10 +107,13 @@ pub const TranslateCContext = struct {
write_src.add(src_file.filename, src_file.source);
}
- const translate_c = b.addTranslateC(write_src.getFileSource(case.sources.items[0].filename).?);
+ const translate_c = b.addTranslateC(.{
+ .source_file = write_src.getFileSource(case.sources.items[0].filename).?,
+ .target = case.target,
+ .optimize = .Debug,
+ });
translate_c.step.name = annotated_case_name;
- translate_c.setTarget(case.target);
const check_file = translate_c.addCheckFile(case.expected_lines.items);