authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-07-11 14:09:05-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-07-11 14:09:05-04:00
log5954c94d2079c9b378ae14bb4c9c24aed719beec
treed774648d89561ff234a0a6e499d06b55fbb5b3fa
parent3f30897fdcdb6c5579bc5609dda9746f67551870

build system: add -Dskip-release option to test faster


2 files changed, 14 insertions(+), 24 deletions(-)

build.zig+12-5
...@@ -59,6 +59,7 @@ pub fn build(b: *Builder) !void {...@@ -59,6 +59,7 @@ pub fn build(b: *Builder) !void {
5959
60 b.default_step.dependOn(&exe.step);60 b.default_step.dependOn(&exe.step);
6161
62 const skip_release = b.option(bool, "skip-release", "Main test suite skips release builds") orelse false;
62 const skip_self_hosted = b.option(bool, "skip-self-hosted", "Main test suite skips building self hosted compiler") orelse false;63 const skip_self_hosted = b.option(bool, "skip-self-hosted", "Main test suite skips building self hosted compiler") orelse false;
63 if (!skip_self_hosted) {64 if (!skip_self_hosted) {
64 test_step.dependOn(&exe.step);65 test_step.dependOn(&exe.step);
...@@ -71,19 +72,24 @@ pub fn build(b: *Builder) !void {...@@ -71,19 +72,24 @@ pub fn build(b: *Builder) !void {
71 installCHeaders(b, ctx.c_header_files);72 installCHeaders(b, ctx.c_header_files);
7273
73 const test_filter = b.option([]const u8, "test-filter", "Skip tests that do not match filter");74 const test_filter = b.option([]const u8, "test-filter", "Skip tests that do not match filter");
74 const with_lldb = b.option(bool, "with-lldb", "Run tests in LLDB to get a backtrace if one fails") orelse false;
7575
76 const test_stage2_step = b.step("test-stage2", "Run the stage2 compiler tests");76 const test_stage2_step = b.step("test-stage2", "Run the stage2 compiler tests");
77 test_stage2_step.dependOn(&test_stage2.step);77 test_stage2_step.dependOn(&test_stage2.step);
78 test_step.dependOn(test_stage2_step);78 test_step.dependOn(test_stage2_step);
7979
80 test_step.dependOn(docs_step);80 const all_modes = []builtin.Mode{
81 builtin.Mode.Debug,
82 builtin.Mode.ReleaseSafe,
83 builtin.Mode.ReleaseFast,
84 builtin.Mode.ReleaseSmall,
85 };
86 const modes = if (skip_release) []builtin.Mode{builtin.Mode.Debug} else all_modes;
8187
82 test_step.dependOn(tests.addPkgTests(b, test_filter, "test/behavior.zig", "behavior", "Run the behavior tests", with_lldb));88 test_step.dependOn(tests.addPkgTests(b, test_filter, "test/behavior.zig", "behavior", "Run the behavior tests", modes));
8389
84 test_step.dependOn(tests.addPkgTests(b, test_filter, "std/index.zig", "std", "Run the standard library tests", with_lldb));90 test_step.dependOn(tests.addPkgTests(b, test_filter, "std/index.zig", "std", "Run the standard library tests", modes));
8591
86 test_step.dependOn(tests.addPkgTests(b, test_filter, "std/special/compiler_rt/index.zig", "compiler-rt", "Run the compiler_rt tests", with_lldb));92 test_step.dependOn(tests.addPkgTests(b, test_filter, "std/special/compiler_rt/index.zig", "compiler-rt", "Run the compiler_rt tests", modes));
8793
88 test_step.dependOn(tests.addCompareOutputTests(b, test_filter));94 test_step.dependOn(tests.addCompareOutputTests(b, test_filter));
89 test_step.dependOn(tests.addBuildExampleTests(b, test_filter));95 test_step.dependOn(tests.addBuildExampleTests(b, test_filter));
...@@ -92,6 +98,7 @@ pub fn build(b: *Builder) !void {...@@ -92,6 +98,7 @@ pub fn build(b: *Builder) !void {
92 test_step.dependOn(tests.addRuntimeSafetyTests(b, test_filter));98 test_step.dependOn(tests.addRuntimeSafetyTests(b, test_filter));
93 test_step.dependOn(tests.addTranslateCTests(b, test_filter));99 test_step.dependOn(tests.addTranslateCTests(b, test_filter));
94 test_step.dependOn(tests.addGenHTests(b, test_filter));100 test_step.dependOn(tests.addGenHTests(b, test_filter));
101 test_step.dependOn(docs_step);
95}102}
96103
97fn dependOnLib(lib_exe_obj: var, dep: *const LibraryDep) void {104fn dependOnLib(lib_exe_obj: var, dep: *const LibraryDep) void {
test/tests.zig+2-19
...@@ -138,16 +138,11 @@ pub fn addGenHTests(b: *build.Builder, test_filter: ?[]const u8) *build.Step {...@@ -138,16 +138,11 @@ pub fn addGenHTests(b: *build.Builder, test_filter: ?[]const u8) *build.Step {
138 return cases.step;138 return cases.step;
139}139}
140140
141pub fn addPkgTests(b: *build.Builder, test_filter: ?[]const u8, root_src: []const u8, name: []const u8, desc: []const u8, with_lldb: bool) *build.Step {141pub fn addPkgTests(b: *build.Builder, test_filter: ?[]const u8, root_src: []const u8, name: []const u8, desc: []const u8, modes: []const Mode) *build.Step {
142 const step = b.step(b.fmt("test-{}", name), desc);142 const step = b.step(b.fmt("test-{}", name), desc);
143 for (test_targets) |test_target| {143 for (test_targets) |test_target| {
144 const is_native = (test_target.os == builtin.os and test_target.arch == builtin.arch);144 const is_native = (test_target.os == builtin.os and test_target.arch == builtin.arch);
145 for ([]Mode{145 for (modes) |mode| {
146 Mode.Debug,
147 Mode.ReleaseSafe,
148 Mode.ReleaseFast,
149 Mode.ReleaseSmall,
150 }) |mode| {
151 for ([]bool{146 for ([]bool{
152 false,147 false,
153 true,148 true,
...@@ -166,18 +161,6 @@ pub fn addPkgTests(b: *build.Builder, test_filter: ?[]const u8, root_src: []cons...@@ -166,18 +161,6 @@ pub fn addPkgTests(b: *build.Builder, test_filter: ?[]const u8, root_src: []cons
166 if (link_libc) {161 if (link_libc) {
167 these_tests.linkSystemLibrary("c");162 these_tests.linkSystemLibrary("c");
168 }163 }
169 if (with_lldb) {
170 these_tests.setExecCmd([]?[]const u8{
171 "lldb",
172 null,
173 "-o",
174 "run",
175 "-o",
176 "bt",
177 "-o",
178 "exit",
179 });
180 }
181 step.dependOn(&these_tests.step);164 step.dependOn(&these_tests.step);
182 }165 }
183 }166 }