Commit df4068cabd
Changed files (9)
lib
std
Build
Step
test
lib/std/Build/Step/Compile.zig
@@ -292,6 +292,13 @@ pub const Kind = enum {
obj,
@"test",
test_obj,
+
+ pub fn isTest(kind: Kind) bool {
+ return switch (kind) {
+ .exe, .lib, .obj => false,
+ .@"test", .test_obj => true,
+ };
+ }
};
pub const HeaderInstallation = union(enum) {
@@ -368,19 +375,16 @@ pub fn create(owner: *std.Build, options: Options) *Compile {
panic("invalid name: '{s}'. It looks like a file path, but it is supposed to be the library or application name.", .{name});
}
- // Avoid the common case of the step name looking like "zig test test".
- const name_adjusted = if ((options.kind == .@"test" or options.kind == .test_obj) and mem.eql(u8, name, "test"))
- ""
- else
- owner.fmt("{s} ", .{name});
-
const resolved_target = options.root_module.resolved_target orelse
@panic("the root Module of a Compile step must be created with a known 'target' field");
const target = resolved_target.result;
- const step_name = owner.fmt("compile {s} {s}{s} {s}", .{
- @tagName(options.kind),
- name_adjusted,
+ const step_name = owner.fmt("compile {s} {s} {s}", .{
+ // Avoid the common case of the step name looking like "compile test test".
+ if (options.kind.isTest() and mem.eql(u8, name, "test"))
+ @tagName(options.kind)
+ else
+ owner.fmt("{s} {s}", .{ @tagName(options.kind), name }),
@tagName(options.root_module.optimize orelse .Debug),
resolved_target.query.zigTriple(owner.allocator) catch @panic("OOM"),
});
lib/std/Build.zig
@@ -1164,7 +1164,14 @@ pub fn addRunArtifact(b: *Build, exe: *Step.Compile) *Step.Run {
// It doesn't have to be native. We catch that if you actually try to run it.
// Consider that this is declarative; the run step may not be run unless a user
// option is supplied.
- const run_step = Step.Run.create(b, b.fmt("run {s}", .{exe.name}));
+
+ // Avoid the common case of the step name looking like "run test test".
+ const step_name = if (exe.kind.isTest() and mem.eql(u8, exe.name, "test"))
+ b.fmt("run {s}", .{@tagName(exe.kind)})
+ else
+ b.fmt("run {s} {s}", .{ @tagName(exe.kind), exe.name });
+
+ const run_step = Step.Run.create(b, step_name);
run_step.producer = exe;
if (exe.kind == .@"test") {
if (exe.exec_cmd_args) |exec_cmd_args| {
test/behavior/x86_64/build.zig
@@ -115,6 +115,7 @@ pub fn build(b: *std.Build) void {
},
}) |query| {
const target = b.resolveTargetQuery(query);
+ const triple = query.zigTriple(b.allocator) catch @panic("OOM");
const cpu = query.serializeCpuAlloc(b.allocator) catch @panic("OOM");
for ([_][]const u8{
"access.zig",
@@ -133,16 +134,14 @@ pub fn build(b: *std.Build) void {
.use_lld = false,
.root_module = test_mod,
});
+ test_exe.step.name = b.fmt("{s} {s}", .{ test_exe.step.name, cpu });
if (!target.result.cpu.has(.x86, .sse2)) {
test_exe.bundle_compiler_rt = false;
test_mod.linkLibrary(compiler_rt_lib);
}
const test_run = b.addRunArtifact(test_exe);
+ test_run.step.name = b.fmt("{s} {s} {s}", .{ test_run.step.name, triple, cpu });
b.default_step.dependOn(&test_run.step);
- for ([_]*std.Build.Step{
- &test_exe.step,
- &test_run.step,
- }) |step| step.name = b.fmt("{s} {s}", .{ step.name, cpu });
}
}
}
test/link/link.zig
@@ -13,7 +13,7 @@ pub const Options = struct {
};
pub fn addTestStep(b: *Build, prefix: []const u8, opts: Options) *Step {
- const target = opts.target.result.zigTriple(b.allocator) catch @panic("OOM");
+ const target = opts.target.query.zigTriple(b.allocator) catch @panic("OOM");
const optimize = @tagName(opts.optimize);
const use_llvm = if (opts.use_llvm) "llvm" else "no-llvm";
const use_lld = if (opts.use_lld) "lld" else "no-lld";
test/src/Cases.zig
@@ -610,7 +610,7 @@ pub fn lowerToBuildSteps(
if (std.mem.indexOf(u8, case.name, test_filter)) |_| break;
} else if (test_filters.len > 0) continue;
- const triple_txt = case.target.result.zigTriple(b.allocator) catch @panic("OOM");
+ const triple_txt = case.target.query.zigTriple(b.allocator) catch @panic("OOM");
if (test_target_filters.len > 0) {
for (test_target_filters) |filter| {
test/src/Debugger.zig
@@ -2447,7 +2447,7 @@ fn addTest(
} else return;
}
if (db.options.test_target_filters.len > 0) {
- const triple_txt = target.resolved.result.zigTriple(db.b.allocator) catch @panic("OOM");
+ const triple_txt = target.resolved.query.zigTriple(db.b.allocator) catch @panic("OOM");
for (db.options.test_target_filters) |filter| {
if (std.mem.indexOf(u8, triple_txt, filter) != null) break;
} else return;
test/src/LlvmIr.zig
@@ -75,7 +75,7 @@ pub fn addExact(
pub fn addCase(self: *LlvmIr, case: TestCase) void {
const target = self.b.resolveTargetQuery(case.params.target);
if (self.options.test_target_filters.len > 0) {
- const triple_txt = target.result.zigTriple(self.b.allocator) catch @panic("OOM");
+ const triple_txt = target.query.zigTriple(self.b.allocator) catch @panic("OOM");
for (self.options.test_target_filters) |filter| {
if (std.mem.indexOf(u8, triple_txt, filter) != null) break;
} else return;
test/src/TranslateC.zig
@@ -96,7 +96,7 @@ pub fn addCase(self: *TranslateCContext, case: *const TestCase) void {
const target = b.resolveTargetQuery(case.target);
if (self.test_target_filters.len > 0) {
- const triple_txt = target.result.zigTriple(b.allocator) catch @panic("OOM");
+ const triple_txt = target.query.zigTriple(b.allocator) catch @panic("OOM");
for (self.test_target_filters) |filter| {
if (std.mem.indexOf(u8, triple_txt, filter) != null) break;
test/tests.zig
@@ -2310,8 +2310,8 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
if (options.skip_llvm and would_use_llvm) continue;
const resolved_target = b.resolveTargetQuery(test_target.target);
+ const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM");
const target = resolved_target.result;
- const triple_txt = target.zigTriple(b.allocator) catch @panic("OOM");
if (options.test_target_filters.len > 0) {
for (options.test_target_filters) |filter| {
@@ -2556,8 +2556,8 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step {
if (options.skip_llvm and would_use_llvm) continue;
const resolved_target = b.resolveTargetQuery(c_abi_target.target);
+ const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM");
const target = resolved_target.result;
- const triple_txt = target.zigTriple(b.allocator) catch @panic("OOM");
if (options.test_target_filters.len > 0) {
for (options.test_target_filters) |filter| {