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");
22const builtin = @import("builtin");
33
44pub fn addCases(cases: *tests.CompileErrorContext) void {
5 cases.add(
6 "variable in inline assembly template cannot be found",
7 \\export fn entry() void {
8 \\ var sp = asm volatile (
9 \\ "mov %[foo], sp"
10 \\ : [bar] "=r" (-> usize)
11 \\ );
12 \\}
13 ,
14 "tmp.zig:2:14: error: could not find 'foo' in the inputs or outputs."
15 );
5 cases.addCase(x: {
6 var tc = cases.create("variable in inline assembly template cannot be found",
7 \\export fn entry() void {
8 \\ var sp = asm volatile (
9 \\ "mov %[foo], sp"
10 \\ : [bar] "=r" (-> usize)
11 \\ );
12 \\}
13 , "tmp.zig:2:14: error: could not find 'foo' in the inputs or outputs.");
14 tc.target = tests.Target{
15 .Cross = tests.CrossTarget{
16 .arch = .x86_64,
17 .os = .linux,
18 .abi = .gnu,
19 },
20 };
21 break :x tc;
22 });
1623
1724 cases.add(
1825 "indirect recursion of async functions detected",
test/tests.zig+15-10
......@@ -2,6 +2,8 @@ const std = @import("std");
22const debug = std.debug;
33const warn = debug.warn;
44const build = std.build;
5pub const Target = build.Target;
6pub const CrossTarget = build.CrossTarget;
57const Buffer = std.Buffer;
68const io = std.io;
79const fs = std.fs;
......@@ -20,24 +22,18 @@ const runtime_safety = @import("runtime_safety.zig");
2022const translate_c = @import("translate_c.zig");
2123const gen_h = @import("gen_h.zig");
2224
23const TestTarget = struct {
24 os: builtin.Os,
25 arch: builtin.Arch,
26 abi: builtin.Abi,
27};
28
29const test_targets = [_]TestTarget{
30 TestTarget{
25const test_targets = [_]CrossTarget{
26 CrossTarget{
3127 .os = .linux,
3228 .arch = .x86_64,
3329 .abi = .gnu,
3430 },
35 TestTarget{
31 CrossTarget{
3632 .os = .macosx,
3733 .arch = .x86_64,
3834 .abi = .gnu,
3935 },
40 TestTarget{
36 CrossTarget{
4137 .os = .windows,
4238 .arch = .x86_64,
4339 .abi = .msvc,
......@@ -568,6 +564,7 @@ pub const CompileErrorContext = struct {
568564 link_libc: bool,
569565 is_exe: bool,
570566 is_test: bool,
567 target: Target = .Native,
571568
572569 const SourceFile = struct {
573570 filename: []const u8,
......@@ -655,6 +652,14 @@ pub const CompileErrorContext = struct {
655652 zig_args.append("--output-dir") catch unreachable;
656653 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
658663 switch (self.build_mode) {
659664 Mode.Debug => {},
660665 Mode.ReleaseSafe => zig_args.append("--release-safe") catch unreachable,