authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-02-25 21:46:32-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-02-25 21:46:32-05:00
log82fafca375ebf474e95a7312bb2c96f8df30375e
treeee7d20d99ba1ad0d398e15ef924491ba7ccf6bc4
parent7571db05de3efcbc70a8404de6f479909b465eaa

fix the libc compile error tests to only run on linux


1 files changed, 22 insertions(+), 19 deletions(-)

test/compile_errors.zig+22-19
...@@ -1,26 +1,29 @@...@@ -1,26 +1,29 @@
1const tests = @import("tests.zig");1const tests = @import("tests.zig");
2const builtin = @import("builtin");
23
3pub fn addCases(cases: *tests.CompileErrorContext) void {4pub fn addCases(cases: *tests.CompileErrorContext) void {
4 cases.addTest(5 if (builtin.os == builtin.Os.linux) {
5 "implicit dependency on libc",6 cases.addTest(
6 \\extern "c" fn exit(u8) void;7 "implicit dependency on libc",
7 \\export fn entry() void {8 \\extern "c" fn exit(u8) void;
8 \\ exit(0);9 \\export fn entry() void {
9 \\}10 \\ exit(0);
10 ,11 \\}
11 ".tmp_source.zig:3:5: error: dependency on library c must be explicitly specified in the build command",12 ,
12 );13 ".tmp_source.zig:3:5: error: dependency on library c must be explicitly specified in the build command",
14 );
1315
14 cases.addTest(16 cases.addTest(
15 "libc headers note",17 "libc headers note",
16 \\const c = @cImport(@cInclude("stdio.h"));18 \\const c = @cImport(@cInclude("stdio.h"));
17 \\export fn entry() void {19 \\export fn entry() void {
18 \\ c.printf("hello, world!\n");20 \\ _ = c.printf(c"hello, world!\n");
19 \\}21 \\}
20 ,22 ,
21 ".tmp_source.zig:1:11: error: C import failed",23 ".tmp_source.zig:1:11: error: C import failed",
22 ".tmp_source.zig:1:11: note: libc headers not available; compilation does not link against libc",24 ".tmp_source.zig:1:11: note: libc headers not available; compilation does not link against libc",
23 );25 );
26 }
2427
25 cases.addTest(28 cases.addTest(
26 "comptime vector overflow shows the index",29 "comptime vector overflow shows the index",