specify the target for the newest test case

master
Andrew Kelley 2019-08-20 14:40:57 -04:00
parent 2addec8ea1
commit 276eb4402b
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
2 changed files with 33 additions and 21 deletions

View File

@ -2,17 +2,24 @@ const tests = @import("tests.zig");
const builtin = @import("builtin");
pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.add(
"variable in inline assembly template cannot be found",
\\export fn entry() void {
\\ var sp = asm volatile (
\\ "mov %[foo], sp"
\\ : [bar] "=r" (-> usize)
\\ );
\\}
,
"tmp.zig:2:14: error: could not find 'foo' in the inputs or outputs."
);
cases.addCase(x: {
var tc = cases.create("variable in inline assembly template cannot be found",
\\export fn entry() void {
\\ var sp = asm volatile (
\\ "mov %[foo], sp"
\\ : [bar] "=r" (-> usize)
\\ );
\\}
, "tmp.zig:2:14: error: could not find 'foo' in the inputs or outputs.");
tc.target = tests.Target{
.Cross = tests.CrossTarget{
.arch = .x86_64,
.os = .linux,
.abi = .gnu,
},
};
break :x tc;
});
cases.add(
"indirect recursion of async functions detected",

View File

@ -2,6 +2,8 @@ const std = @import("std");
const debug = std.debug;
const warn = debug.warn;
const build = std.build;
pub const Target = build.Target;
pub const CrossTarget = build.CrossTarget;
const Buffer = std.Buffer;
const io = std.io;
const fs = std.fs;
@ -20,24 +22,18 @@ const runtime_safety = @import("runtime_safety.zig");
const translate_c = @import("translate_c.zig");
const gen_h = @import("gen_h.zig");
const TestTarget = struct {
os: builtin.Os,
arch: builtin.Arch,
abi: builtin.Abi,
};
const test_targets = [_]TestTarget{
TestTarget{
const test_targets = [_]CrossTarget{
CrossTarget{
.os = .linux,
.arch = .x86_64,
.abi = .gnu,
},
TestTarget{
CrossTarget{
.os = .macosx,
.arch = .x86_64,
.abi = .gnu,
},
TestTarget{
CrossTarget{
.os = .windows,
.arch = .x86_64,
.abi = .msvc,
@ -568,6 +564,7 @@ pub const CompileErrorContext = struct {
link_libc: bool,
is_exe: bool,
is_test: bool,
target: Target = .Native,
const SourceFile = struct {
filename: []const u8,
@ -655,6 +652,14 @@ pub const CompileErrorContext = struct {
zig_args.append("--output-dir") catch unreachable;
zig_args.append(b.pathFromRoot(b.cache_root)) catch unreachable;
switch (self.case.target) {
.Native => {},
.Cross => {
try zig_args.append("-target");
try zig_args.append(try self.case.target.zigTriple(b.allocator));
},
}
switch (self.build_mode) {
Mode.Debug => {},
Mode.ReleaseSafe => zig_args.append("--release-safe") catch unreachable,