authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-03 10:05:19-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-03 10:05:19-04:00
log1fd24791a7ea74260c86212e65b13cafd6243863
tree93a334a287f80fd9b67d2e06d15acb733cd156ce
parenta19e73d8ae0bc5b7ac19b1bc72aa1fdb8f86d80f
signature Commit is signed but in an unrecognized format.

rename compare-panic to compare-stack-traces


4 files changed, 290 insertions(+), 293 deletions(-)

build.zig+2-2
...@@ -138,13 +138,13 @@ pub fn build(b: *Builder) !void {...@@ -138,13 +138,13 @@ pub fn build(b: *Builder) !void {
138138
139 test_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes));139 test_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes));
140 test_step.dependOn(tests.addStandaloneTests(b, test_filter, modes));140 test_step.dependOn(tests.addStandaloneTests(b, test_filter, modes));
141 test_step.dependOn(tests.addComparePanicTests(b, test_filter, modes));141 test_step.dependOn(tests.addCompareStackTracesTests(b, test_filter, modes));
142 test_step.dependOn(tests.addCliTests(b, test_filter, modes));142 test_step.dependOn(tests.addCliTests(b, test_filter, modes));
143 test_step.dependOn(tests.addCompileErrorTests(b, test_filter, modes));
144 test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, modes));143 test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, modes));
145 test_step.dependOn(tests.addRuntimeSafetyTests(b, test_filter, modes));144 test_step.dependOn(tests.addRuntimeSafetyTests(b, test_filter, modes));
146 test_step.dependOn(tests.addTranslateCTests(b, test_filter));145 test_step.dependOn(tests.addTranslateCTests(b, test_filter));
147 test_step.dependOn(tests.addGenHTests(b, test_filter));146 test_step.dependOn(tests.addGenHTests(b, test_filter));
147 test_step.dependOn(tests.addCompileErrorTests(b, test_filter, modes));
148 test_step.dependOn(docs_step);148 test_step.dependOn(docs_step);
149}149}
150150
test/compare_panic.zig deleted-277
...@@ -1,277 +0,0 @@
1const builtin = @import("builtin");
2const std = @import("std");
3const os = std.os;
4const tests = @import("tests.zig");
5
6pub fn addCases(cases: *tests.ComparePanicContext) void {
7 const source_return =
8 \\const std = @import("std");
9 \\
10 \\pub fn main() !void {
11 \\ return error.TheSkyIsFalling;
12 \\}
13 ;
14 const source_try_return =
15 \\const std = @import("std");
16 \\
17 \\fn foo() !void {
18 \\ return error.TheSkyIsFalling;
19 \\}
20 \\
21 \\pub fn main() !void {
22 \\ try foo();
23 \\}
24 ;
25 const source_try_try_return_return =
26 \\const std = @import("std");
27 \\
28 \\fn foo() !void {
29 \\ try bar();
30 \\}
31 \\
32 \\fn bar() !void {
33 \\ return make_error();
34 \\}
35 \\
36 \\fn make_error() !void {
37 \\ return error.TheSkyIsFalling;
38 \\}
39 \\
40 \\pub fn main() !void {
41 \\ try foo();
42 \\}
43 ;
44 switch (builtin.os) {
45 .linux => {
46 cases.addCase(
47 "return",
48 source_return,
49 [][]const u8{
50 // debug
51 \\error: TheSkyIsFalling
52 \\source.zig:4:5: [address] in main (test)
53 \\
54 ,
55 // release-safe
56 \\error: TheSkyIsFalling
57 \\source.zig:4:5: [address] in std.special.posixCallMainAndExit (test)
58 \\
59 ,
60 // release-fast
61 \\error: TheSkyIsFalling
62 \\
63 ,
64 // release-small
65 \\error: TheSkyIsFalling
66 \\
67 },
68 );
69 cases.addCase(
70 "try return",
71 source_try_return,
72 [][]const u8{
73 // debug
74 \\error: TheSkyIsFalling
75 \\source.zig:4:5: [address] in foo (test)
76 \\source.zig:8:5: [address] in main (test)
77 \\
78 ,
79 // release-safe
80 \\error: TheSkyIsFalling
81 \\source.zig:4:5: [address] in std.special.posixCallMainAndExit (test)
82 \\source.zig:8:5: [address] in std.special.posixCallMainAndExit (test)
83 \\
84 ,
85 // release-fast
86 \\error: TheSkyIsFalling
87 \\
88 ,
89 // release-small
90 \\error: TheSkyIsFalling
91 \\
92 },
93 );
94 cases.addCase(
95 "try try return return",
96 source_try_try_return_return,
97 [][]const u8{
98 // debug
99 \\error: TheSkyIsFalling
100 \\source.zig:12:5: [address] in make_error (test)
101 \\source.zig:8:5: [address] in bar (test)
102 \\source.zig:4:5: [address] in foo (test)
103 \\source.zig:16:5: [address] in main (test)
104 \\
105 ,
106 // release-safe
107 \\error: TheSkyIsFalling
108 \\source.zig:12:5: [address] in std.special.posixCallMainAndExit (test)
109 \\source.zig:8:5: [address] in std.special.posixCallMainAndExit (test)
110 \\source.zig:4:5: [address] in std.special.posixCallMainAndExit (test)
111 \\source.zig:16:5: [address] in std.special.posixCallMainAndExit (test)
112 \\
113 ,
114 // release-fast
115 \\error: TheSkyIsFalling
116 \\
117 ,
118 // release-small
119 \\error: TheSkyIsFalling
120 \\
121 },
122 );
123 },
124 .macosx => {
125 cases.addCase(
126 "return",
127 source_return,
128 [][]const u8{
129 // debug
130 \\error: TheSkyIsFalling
131 \\source.zig:4:5: [address] in _main.0 (test.o)
132 \\
133 ,
134 // release-safe
135 \\error: TheSkyIsFalling
136 \\source.zig:4:5: [address] in _main (test.o)
137 \\
138 ,
139 // release-fast
140 \\error: TheSkyIsFalling
141 \\
142 ,
143 // release-small
144 \\error: TheSkyIsFalling
145 \\
146 },
147 );
148 cases.addCase(
149 "try return",
150 source_try_return,
151 [][]const u8{
152 // debug
153 \\error: TheSkyIsFalling
154 \\source.zig:4:5: [address] in _foo (test.o)
155 \\source.zig:8:5: [address] in _main.0 (test.o)
156 \\
157 ,
158 // release-safe
159 \\error: TheSkyIsFalling
160 \\source.zig:4:5: [address] in _main (test.o)
161 \\source.zig:8:5: [address] in _main (test.o)
162 \\
163 ,
164 // release-fast
165 \\error: TheSkyIsFalling
166 \\
167 ,
168 // release-small
169 \\error: TheSkyIsFalling
170 \\
171 },
172 );
173 cases.addCase(
174 "try try return return",
175 source_try_try_return_return,
176 [][]const u8{
177 // debug
178 \\error: TheSkyIsFalling
179 \\source.zig:12:5: [address] in _make_error (test.o)
180 \\source.zig:8:5: [address] in _bar (test.o)
181 \\source.zig:4:5: [address] in _foo (test.o)
182 \\source.zig:16:5: [address] in _main.0 (test.o)
183 \\
184 ,
185 // release-safe
186 \\error: TheSkyIsFalling
187 \\source.zig:12:5: [address] in _main (test.o)
188 \\source.zig:8:5: [address] in _main (test.o)
189 \\source.zig:4:5: [address] in _main (test.o)
190 \\source.zig:16:5: [address] in _main (test.o)
191 \\
192 ,
193 // release-fast
194 \\error: TheSkyIsFalling
195 \\
196 ,
197 // release-small
198 \\error: TheSkyIsFalling
199 \\
200 },
201 );
202 },
203 .windows => {
204 cases.addCase(
205 "return",
206 source_return,
207 [][]const u8{
208 // debug
209 \\error: TheSkyIsFalling
210 \\source.zig:4:5: [address] in main (test.obj)
211 \\
212 ,
213 // release-safe
214 // --disabled-- results in segmenetation fault
215 ""
216 ,
217 // release-fast
218 \\error: TheSkyIsFalling
219 \\
220 ,
221 // release-small
222 \\error: TheSkyIsFalling
223 \\
224 },
225 );
226 cases.addCase(
227 "try return",
228 source_try_return,
229 [][]const u8{
230 // debug
231 \\error: TheSkyIsFalling
232 \\source.zig:4:5: [address] in foo (test.obj)
233 \\source.zig:8:5: [address] in main (test.obj)
234 \\
235 ,
236 // release-safe
237 // --disabled-- results in segmenetation fault
238 ""
239 ,
240 // release-fast
241 \\error: TheSkyIsFalling
242 \\
243 ,
244 // release-small
245 \\error: TheSkyIsFalling
246 \\
247 },
248 );
249 cases.addCase(
250 "try try return return",
251 source_try_try_return_return,
252 [][]const u8{
253 // debug
254 \\error: TheSkyIsFalling
255 \\source.zig:12:5: [address] in make_error (test.obj)
256 \\source.zig:8:5: [address] in bar (test.obj)
257 \\source.zig:4:5: [address] in foo (test.obj)
258 \\source.zig:16:5: [address] in main (test.obj)
259 \\
260 ,
261 // release-safe
262 // --disabled-- results in segmenetation fault
263 ""
264 ,
265 // release-fast
266 \\error: TheSkyIsFalling
267 \\
268 ,
269 // release-small
270 \\error: TheSkyIsFalling
271 \\
272 },
273 );
274 },
275 else => {},
276 }
277}
test/compare_traces.zig created+274
...@@ -0,0 +1,274 @@
1const builtin = @import("builtin");
2const std = @import("std");
3const os = std.os;
4const tests = @import("tests.zig");
5
6pub fn addCases(cases: *tests.CompareStackTracesContext) void {
7 const source_return =
8 \\const std = @import("std");
9 \\
10 \\pub fn main() !void {
11 \\ return error.TheSkyIsFalling;
12 \\}
13 ;
14 const source_try_return =
15 \\const std = @import("std");
16 \\
17 \\fn foo() !void {
18 \\ return error.TheSkyIsFalling;
19 \\}
20 \\
21 \\pub fn main() !void {
22 \\ try foo();
23 \\}
24 ;
25 const source_try_try_return_return =
26 \\const std = @import("std");
27 \\
28 \\fn foo() !void {
29 \\ try bar();
30 \\}
31 \\
32 \\fn bar() !void {
33 \\ return make_error();
34 \\}
35 \\
36 \\fn make_error() !void {
37 \\ return error.TheSkyIsFalling;
38 \\}
39 \\
40 \\pub fn main() !void {
41 \\ try foo();
42 \\}
43 ;
44 switch (builtin.os) {
45 .linux => {
46 cases.addCase(
47 "return",
48 source_return,
49 [_][]const u8{
50 // debug
51 \\error: TheSkyIsFalling
52 \\source.zig:4:5: [address] in main (test)
53 \\
54 ,
55 // release-safe
56 \\error: TheSkyIsFalling
57 \\source.zig:4:5: [address] in std.special.posixCallMainAndExit (test)
58 \\
59 ,
60 // release-fast
61 \\error: TheSkyIsFalling
62 \\
63 ,
64 // release-small
65 \\error: TheSkyIsFalling
66 \\
67 },
68 );
69 cases.addCase(
70 "try return",
71 source_try_return,
72 [_][]const u8{
73 // debug
74 \\error: TheSkyIsFalling
75 \\source.zig:4:5: [address] in foo (test)
76 \\source.zig:8:5: [address] in main (test)
77 \\
78 ,
79 // release-safe
80 \\error: TheSkyIsFalling
81 \\source.zig:4:5: [address] in std.special.posixCallMainAndExit (test)
82 \\source.zig:8:5: [address] in std.special.posixCallMainAndExit (test)
83 \\
84 ,
85 // release-fast
86 \\error: TheSkyIsFalling
87 \\
88 ,
89 // release-small
90 \\error: TheSkyIsFalling
91 \\
92 },
93 );
94 cases.addCase(
95 "try try return return",
96 source_try_try_return_return,
97 [_][]const u8{
98 // debug
99 \\error: TheSkyIsFalling
100 \\source.zig:12:5: [address] in make_error (test)
101 \\source.zig:8:5: [address] in bar (test)
102 \\source.zig:4:5: [address] in foo (test)
103 \\source.zig:16:5: [address] in main (test)
104 \\
105 ,
106 // release-safe
107 \\error: TheSkyIsFalling
108 \\source.zig:12:5: [address] in std.special.posixCallMainAndExit (test)
109 \\source.zig:8:5: [address] in std.special.posixCallMainAndExit (test)
110 \\source.zig:4:5: [address] in std.special.posixCallMainAndExit (test)
111 \\source.zig:16:5: [address] in std.special.posixCallMainAndExit (test)
112 \\
113 ,
114 // release-fast
115 \\error: TheSkyIsFalling
116 \\
117 ,
118 // release-small
119 \\error: TheSkyIsFalling
120 \\
121 },
122 );
123 },
124 .macosx => {
125 cases.addCase(
126 "return",
127 source_return,
128 [_][]const u8{
129 // debug
130 \\error: TheSkyIsFalling
131 \\source.zig:4:5: [address] in _main.0 (test.o)
132 \\
133 ,
134 // release-safe
135 \\error: TheSkyIsFalling
136 \\source.zig:4:5: [address] in _main (test.o)
137 \\
138 ,
139 // release-fast
140 \\error: TheSkyIsFalling
141 \\
142 ,
143 // release-small
144 \\error: TheSkyIsFalling
145 \\
146 },
147 );
148 cases.addCase(
149 "try return",
150 source_try_return,
151 [_][]const u8{
152 // debug
153 \\error: TheSkyIsFalling
154 \\source.zig:4:5: [address] in _foo (test.o)
155 \\source.zig:8:5: [address] in _main.0 (test.o)
156 \\
157 ,
158 // release-safe
159 \\error: TheSkyIsFalling
160 \\source.zig:4:5: [address] in _main (test.o)
161 \\source.zig:8:5: [address] in _main (test.o)
162 \\
163 ,
164 // release-fast
165 \\error: TheSkyIsFalling
166 \\
167 ,
168 // release-small
169 \\error: TheSkyIsFalling
170 \\
171 },
172 );
173 cases.addCase(
174 "try try return return",
175 source_try_try_return_return,
176 [_][]const u8{
177 // debug
178 \\error: TheSkyIsFalling
179 \\source.zig:12:5: [address] in _make_error (test.o)
180 \\source.zig:8:5: [address] in _bar (test.o)
181 \\source.zig:4:5: [address] in _foo (test.o)
182 \\source.zig:16:5: [address] in _main.0 (test.o)
183 \\
184 ,
185 // release-safe
186 \\error: TheSkyIsFalling
187 \\source.zig:12:5: [address] in _main (test.o)
188 \\source.zig:8:5: [address] in _main (test.o)
189 \\source.zig:4:5: [address] in _main (test.o)
190 \\source.zig:16:5: [address] in _main (test.o)
191 \\
192 ,
193 // release-fast
194 \\error: TheSkyIsFalling
195 \\
196 ,
197 // release-small
198 \\error: TheSkyIsFalling
199 \\
200 },
201 );
202 },
203 .windows => {
204 cases.addCase(
205 "return",
206 source_return,
207 [_][]const u8{
208 // debug
209 \\error: TheSkyIsFalling
210 \\source.zig:4:5: [address] in main (test.obj)
211 \\
212 ,
213 // release-safe
214 // --disabled-- results in segmenetation fault
215 "",
216 // release-fast
217 \\error: TheSkyIsFalling
218 \\
219 ,
220 // release-small
221 \\error: TheSkyIsFalling
222 \\
223 },
224 );
225 cases.addCase(
226 "try return",
227 source_try_return,
228 [_][]const u8{
229 // debug
230 \\error: TheSkyIsFalling
231 \\source.zig:4:5: [address] in foo (test.obj)
232 \\source.zig:8:5: [address] in main (test.obj)
233 \\
234 ,
235 // release-safe
236 // --disabled-- results in segmenetation fault
237 "",
238 // release-fast
239 \\error: TheSkyIsFalling
240 \\
241 ,
242 // release-small
243 \\error: TheSkyIsFalling
244 \\
245 },
246 );
247 cases.addCase(
248 "try try return return",
249 source_try_try_return_return,
250 [_][]const u8{
251 // debug
252 \\error: TheSkyIsFalling
253 \\source.zig:12:5: [address] in make_error (test.obj)
254 \\source.zig:8:5: [address] in bar (test.obj)
255 \\source.zig:4:5: [address] in foo (test.obj)
256 \\source.zig:16:5: [address] in main (test.obj)
257 \\
258 ,
259 // release-safe
260 // --disabled-- results in segmenetation fault
261 "",
262 // release-fast
263 \\error: TheSkyIsFalling
264 \\
265 ,
266 // release-small
267 \\error: TheSkyIsFalling
268 \\
269 },
270 );
271 },
272 else => {},
273 }
274}
test/tests.zig+14-14
...@@ -16,7 +16,7 @@ const LibExeObjStep = build.LibExeObjStep;...@@ -16,7 +16,7 @@ const LibExeObjStep = build.LibExeObjStep;
1616
17const compare_output = @import("compare_output.zig");17const compare_output = @import("compare_output.zig");
18const standalone = @import("standalone.zig");18const standalone = @import("standalone.zig");
19const compare_panic = @import("compare_panic.zig");19const compare_panic = @import("compare_traces.zig");
20const compile_errors = @import("compile_errors.zig");20const compile_errors = @import("compile_errors.zig");
21const assemble_and_link = @import("assemble_and_link.zig");21const assemble_and_link = @import("assemble_and_link.zig");
22const runtime_safety = @import("runtime_safety.zig");22const runtime_safety = @import("runtime_safety.zig");
...@@ -58,11 +58,11 @@ pub fn addCompareOutputTests(b: *build.Builder, test_filter: ?[]const u8, modes:...@@ -58,11 +58,11 @@ pub fn addCompareOutputTests(b: *build.Builder, test_filter: ?[]const u8, modes:
58 return cases.step;58 return cases.step;
59}59}
6060
61pub fn addComparePanicTests(b: *build.Builder, test_filter: ?[]const u8, modes: []const Mode) *build.Step {61pub fn addCompareStackTracesTests(b: *build.Builder, test_filter: ?[]const u8, modes: []const Mode) *build.Step {
62 const cases = b.allocator.create(ComparePanicContext) catch unreachable;62 const cases = b.allocator.create(CompareStackTracesContext) catch unreachable;
63 cases.* = ComparePanicContext{63 cases.* = CompareStackTracesContext{
64 .b = b,64 .b = b,
65 .step = b.step("test-compare-panic", "Run the compare panic tests"),65 .step = b.step("test-compare-traces", "Run the compare stack traces tests"),
66 .test_index = 0,66 .test_index = 0,
67 .test_filter = test_filter,67 .test_filter = test_filter,
68 .modes = modes,68 .modes = modes,
...@@ -565,7 +565,7 @@ pub const CompareOutputContext = struct {...@@ -565,7 +565,7 @@ pub const CompareOutputContext = struct {
565 }565 }
566};566};
567567
568pub const ComparePanicContext = struct {568pub const CompareStackTracesContext = struct {
569 b: *build.Builder,569 b: *build.Builder,
570 step: *build.Step,570 step: *build.Step,
571 test_index: usize,571 test_index: usize,
...@@ -575,7 +575,7 @@ pub const ComparePanicContext = struct {...@@ -575,7 +575,7 @@ pub const ComparePanicContext = struct {
575 const Expect = [@typeInfo(Mode).Enum.fields.len][]const u8;575 const Expect = [@typeInfo(Mode).Enum.fields.len][]const u8;
576576
577 pub fn addCase(577 pub fn addCase(
578 self: *ComparePanicContext,578 self: *CompareStackTracesContext,
579 name: []const u8,579 name: []const u8,
580 source: []const u8,580 source: []const u8,
581 expect: Expect,581 expect: Expect,
...@@ -584,14 +584,14 @@ pub const ComparePanicContext = struct {...@@ -584,14 +584,14 @@ pub const ComparePanicContext = struct {
584584
585 const source_pathname = fs.path.join(585 const source_pathname = fs.path.join(
586 b.allocator,586 b.allocator,
587 [][]const u8{ b.cache_root, "source.zig" },587 [_][]const u8{ b.cache_root, "source.zig" },
588 ) catch unreachable;588 ) catch unreachable;
589589
590 for (self.modes) |mode| {590 for (self.modes) |mode| {
591 const expect_for_mode = expect[@enumToInt(mode)];591 const expect_for_mode = expect[@enumToInt(mode)];
592 if (expect_for_mode.len == 0) continue;592 if (expect_for_mode.len == 0) continue;
593593
594 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{} {} ({})", "compare-panic", name, @tagName(mode)) catch unreachable;594 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{} {} ({})", "compare-stack-traces", name, @tagName(mode)) catch unreachable;
595 if (self.test_filter) |filter| {595 if (self.test_filter) |filter| {
596 if (mem.indexOf(u8, annotated_case_name, filter) == null) continue;596 if (mem.indexOf(u8, annotated_case_name, filter) == null) continue;
597 }597 }
...@@ -616,7 +616,7 @@ pub const ComparePanicContext = struct {...@@ -616,7 +616,7 @@ pub const ComparePanicContext = struct {
616616
617 const RunAndCompareStep = struct {617 const RunAndCompareStep = struct {
618 step: build.Step,618 step: build.Step,
619 context: *ComparePanicContext,619 context: *CompareStackTracesContext,
620 exe: *LibExeObjStep,620 exe: *LibExeObjStep,
621 name: []const u8,621 name: []const u8,
622 mode: Mode,622 mode: Mode,
...@@ -624,7 +624,7 @@ pub const ComparePanicContext = struct {...@@ -624,7 +624,7 @@ pub const ComparePanicContext = struct {
624 test_index: usize,624 test_index: usize,
625625
626 pub fn create(626 pub fn create(
627 context: *ComparePanicContext,627 context: *CompareStackTracesContext,
628 exe: *LibExeObjStep,628 exe: *LibExeObjStep,
629 name: []const u8,629 name: []const u8,
630 mode: Mode,630 mode: Mode,
...@@ -633,7 +633,7 @@ pub const ComparePanicContext = struct {...@@ -633,7 +633,7 @@ pub const ComparePanicContext = struct {
633 const allocator = context.b.allocator;633 const allocator = context.b.allocator;
634 const ptr = allocator.create(RunAndCompareStep) catch unreachable;634 const ptr = allocator.create(RunAndCompareStep) catch unreachable;
635 ptr.* = RunAndCompareStep{635 ptr.* = RunAndCompareStep{
636 .step = build.Step.init("PanicCompareOutputStep", allocator, make),636 .step = build.Step.init("StackTraceCompareOutputStep", allocator, make),
637 .context = context,637 .context = context,
638 .exe = exe,638 .exe = exe,
639 .name = name,639 .name = name,
...@@ -718,8 +718,8 @@ pub const ComparePanicContext = struct {...@@ -718,8 +718,8 @@ pub const ComparePanicContext = struct {
718 var it = mem.separate(bytes, "\n");718 var it = mem.separate(bytes, "\n");
719 process_lines: while (it.next()) |line| {719 process_lines: while (it.next()) |line| {
720 if (line.len == 0) continue;720 if (line.len == 0) continue;
721 const delims = []const []const u8{ ":", ":", ":", " in " };721 const delims = [_][]const u8{ ":", ":", ":", " in " };
722 var marks = []usize{0} ** 4;722 var marks = [_]usize{0} ** 4;
723 // offset search past `[drive]:` on windows723 // offset search past `[drive]:` on windows
724 var pos: usize = if (builtin.os == .windows) 2 else 0;724 var pos: usize = if (builtin.os == .windows) 2 else 0;
725 for (delims) |delim, i| {725 for (delims) |delim, i| {