authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-08-20 14:40:57-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-08-20 14:40:57-04:00
log276eb4402b3c54adef10033d1ec54bf2053cc563
tree43b99a9c9095517a21869dac8ab0e7e0de7ab7e7
parent2addec8ea1f35241e9399c5da6855c427481985f
signaturelock-open Commit is signed but in an unrecognized format.

specify the target for the newest test case


2 files changed, 33 insertions(+), 21 deletions(-)

test/compile_errors.zig+18-11
...@@ -2,17 +2,24 @@ const tests = @import("tests.zig");...@@ -2,17 +2,24 @@ const tests = @import("tests.zig");
2const builtin = @import("builtin");2const builtin = @import("builtin");
33
4pub fn addCases(cases: *tests.CompileErrorContext) void {4pub fn addCases(cases: *tests.CompileErrorContext) void {
5 cases.add(5 cases.addCase(x: {
6 "variable in inline assembly template cannot be found",6 var tc = cases.create("variable in inline assembly template cannot be found",
7 \\export fn entry() void {7 \\export fn entry() void {
8 \\ var sp = asm volatile (8 \\ var sp = asm volatile (
9 \\ "mov %[foo], sp"9 \\ "mov %[foo], sp"
10 \\ : [bar] "=r" (-> usize)10 \\ : [bar] "=r" (-> usize)
11 \\ );11 \\ );
12 \\}12 \\}
13 ,13 , "tmp.zig:2:14: error: could not find 'foo' in the inputs or outputs.");
14 "tmp.zig:2:14: error: could not find 'foo' in the inputs or outputs."14 tc.target = tests.Target{
15 );15 .Cross = tests.CrossTarget{
16 .arch = .x86_64,
17 .os = .linux,
18 .abi = .gnu,
19 },
20 };
21 break :x tc;
22 });
1623
17 cases.add(24 cases.add(
18 "indirect recursion of async functions detected",25 "indirect recursion of async functions detected",
test/tests.zig+15-10
...@@ -2,6 +2,8 @@ const std = @import("std");...@@ -2,6 +2,8 @@ const std = @import("std");
2const debug = std.debug;2const debug = std.debug;
3const warn = debug.warn;3const warn = debug.warn;
4const build = std.build;4const build = std.build;
5pub const Target = build.Target;
6pub const CrossTarget = build.CrossTarget;
5const Buffer = std.Buffer;7const Buffer = std.Buffer;
6const io = std.io;8const io = std.io;
7const fs = std.fs;9const fs = std.fs;
...@@ -20,24 +22,18 @@ const runtime_safety = @import("runtime_safety.zig");...@@ -20,24 +22,18 @@ const runtime_safety = @import("runtime_safety.zig");
20const translate_c = @import("translate_c.zig");22const translate_c = @import("translate_c.zig");
21const gen_h = @import("gen_h.zig");23const gen_h = @import("gen_h.zig");
2224
23const TestTarget = struct {25const test_targets = [_]CrossTarget{
24 os: builtin.Os,26 CrossTarget{
25 arch: builtin.Arch,
26 abi: builtin.Abi,
27};
28
29const test_targets = [_]TestTarget{
30 TestTarget{
31 .os = .linux,27 .os = .linux,
32 .arch = .x86_64,28 .arch = .x86_64,
33 .abi = .gnu,29 .abi = .gnu,
34 },30 },
35 TestTarget{31 CrossTarget{
36 .os = .macosx,32 .os = .macosx,
37 .arch = .x86_64,33 .arch = .x86_64,
38 .abi = .gnu,34 .abi = .gnu,
39 },35 },
40 TestTarget{36 CrossTarget{
41 .os = .windows,37 .os = .windows,
42 .arch = .x86_64,38 .arch = .x86_64,
43 .abi = .msvc,39 .abi = .msvc,
...@@ -568,6 +564,7 @@ pub const CompileErrorContext = struct {...@@ -568,6 +564,7 @@ pub const CompileErrorContext = struct {
568 link_libc: bool,564 link_libc: bool,
569 is_exe: bool,565 is_exe: bool,
570 is_test: bool,566 is_test: bool,
567 target: Target = .Native,
571568
572 const SourceFile = struct {569 const SourceFile = struct {
573 filename: []const u8,570 filename: []const u8,
...@@ -655,6 +652,14 @@ pub const CompileErrorContext = struct {...@@ -655,6 +652,14 @@ pub const CompileErrorContext = struct {
655 zig_args.append("--output-dir") catch unreachable;652 zig_args.append("--output-dir") catch unreachable;
656 zig_args.append(b.pathFromRoot(b.cache_root)) catch unreachable;653 zig_args.append(b.pathFromRoot(b.cache_root)) catch unreachable;
657654
655 switch (self.case.target) {
656 .Native => {},
657 .Cross => {
658 try zig_args.append("-target");
659 try zig_args.append(try self.case.target.zigTriple(b.allocator));
660 },
661 }
662
658 switch (self.build_mode) {663 switch (self.build_mode) {
659 Mode.Debug => {},664 Mode.Debug => {},
660 Mode.ReleaseSafe => zig_args.append("--release-safe") catch unreachable,665 Mode.ReleaseSafe => zig_args.append("--release-safe") catch unreachable,