tests: run-translated-c now respects -Dtarget

This commit is contained in:
Andrew Kelley 2020-12-08 13:46:05 -07:00
parent 24cbf1c706
commit 58c8ad8ea8
3 changed files with 9 additions and 2 deletions

View File

@ -335,7 +335,7 @@ pub fn build(b: *Builder) !void {
test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, modes)); test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, modes));
test_step.dependOn(tests.addRuntimeSafetyTests(b, test_filter, modes)); test_step.dependOn(tests.addRuntimeSafetyTests(b, test_filter, modes));
test_step.dependOn(tests.addTranslateCTests(b, test_filter)); test_step.dependOn(tests.addTranslateCTests(b, test_filter));
test_step.dependOn(tests.addRunTranslatedCTests(b, test_filter)); test_step.dependOn(tests.addRunTranslatedCTests(b, test_filter, target));
// tests for this feature are disabled until we have the self-hosted compiler available // tests for this feature are disabled until we have the self-hosted compiler available
// test_step.dependOn(tests.addGenHTests(b, test_filter)); // test_step.dependOn(tests.addGenHTests(b, test_filter));
if (!skip_compile_errors) { if (!skip_compile_errors) {

View File

@ -13,6 +13,7 @@ pub const RunTranslatedCContext = struct {
step: *build.Step, step: *build.Step,
test_index: usize, test_index: usize,
test_filter: ?[]const u8, test_filter: ?[]const u8,
target: std.zig.CrossTarget,
const TestCase = struct { const TestCase = struct {
name: []const u8, name: []const u8,
@ -93,6 +94,7 @@ pub const RunTranslatedCContext = struct {
}); });
translate_c.step.name = b.fmt("{} translate-c", .{annotated_case_name}); translate_c.step.name = b.fmt("{} translate-c", .{annotated_case_name});
const exe = translate_c.addExecutable(); const exe = translate_c.addExecutable();
exe.setTarget(self.target);
exe.step.name = b.fmt("{} build-exe", .{annotated_case_name}); exe.step.name = b.fmt("{} build-exe", .{annotated_case_name});
exe.linkLibC(); exe.linkLibC();
const run = exe.run(); const run = exe.run();

View File

@ -434,13 +434,18 @@ pub fn addTranslateCTests(b: *build.Builder, test_filter: ?[]const u8) *build.St
return cases.step; return cases.step;
} }
pub fn addRunTranslatedCTests(b: *build.Builder, test_filter: ?[]const u8) *build.Step { pub fn addRunTranslatedCTests(
b: *build.Builder,
test_filter: ?[]const u8,
target: std.zig.CrossTarget,
) *build.Step {
const cases = b.allocator.create(RunTranslatedCContext) catch unreachable; const cases = b.allocator.create(RunTranslatedCContext) catch unreachable;
cases.* = .{ cases.* = .{
.b = b, .b = b,
.step = b.step("test-run-translated-c", "Run the Run-Translated-C tests"), .step = b.step("test-run-translated-c", "Run the Run-Translated-C tests"),
.test_index = 0, .test_index = 0,
.test_filter = test_filter, .test_filter = test_filter,
.target = target,
}; };
run_translated_c.addCases(cases); run_translated_c.addCases(cases);