| author | |
| committer | |
| log | c8c32a056989cc669008f1fc295a29d55b753cc0 |
| tree | d4543479180184bd3bd9ff2fdaf10dd97aecb3ab |
| parent | beed47e8c3792abf87529c705726d9745546648e |
ReleaseSafe optimization mode now defaults error tracing to false.2 files changed, 59 insertions(+), 66 deletions(-)
test/src/StackTrace.zig+29-49| ... | ... | @@ -5,44 +5,33 @@ test_filter: ?[]const u8, |
| 5 | 5 | optimize_modes: []const OptimizeMode, |
| 6 | 6 | check_exe: *std.Build.Step.Compile, |
| 7 | 7 | |
| 8 | const Expect = [@typeInfo(OptimizeMode).Enum.fields.len][]const u8; | |
| 8 | const Config = struct { | |
| 9 | name: []const u8, | |
| 10 | source: []const u8, | |
| 11 | Debug: ?PerMode = null, | |
| 12 | ReleaseSmall: ?PerMode = null, | |
| 13 | ReleaseSafe: ?PerMode = null, | |
| 14 | ReleaseFast: ?PerMode = null, | |
| 9 | 15 | |
| 10 | pub fn addCase(self: *StackTrace, config: anytype) void { | |
| 11 | if (@hasField(@TypeOf(config), "exclude")) { | |
| 12 | if (config.exclude.exclude()) return; | |
| 13 | } | |
| 14 | if (@hasField(@TypeOf(config), "exclude_arch")) { | |
| 15 | const exclude_arch: []const std.Target.Cpu.Arch = &config.exclude_arch; | |
| 16 | for (exclude_arch) |arch| if (arch == builtin.cpu.arch) return; | |
| 17 | } | |
| 18 | if (@hasField(@TypeOf(config), "exclude_os")) { | |
| 19 | const exclude_os: []const std.Target.Os.Tag = &config.exclude_os; | |
| 20 | for (exclude_os) |os| if (os == builtin.os.tag) return; | |
| 21 | } | |
| 22 | for (self.optimize_modes) |optimize_mode| { | |
| 23 | switch (optimize_mode) { | |
| 24 | .Debug => { | |
| 25 | if (@hasField(@TypeOf(config), "Debug")) { | |
| 26 | self.addExpect(config.name, config.source, optimize_mode, config.Debug); | |
| 27 | } | |
| 28 | }, | |
| 29 | .ReleaseSafe => { | |
| 30 | if (@hasField(@TypeOf(config), "ReleaseSafe")) { | |
| 31 | self.addExpect(config.name, config.source, optimize_mode, config.ReleaseSafe); | |
| 32 | } | |
| 33 | }, | |
| 34 | .ReleaseFast => { | |
| 35 | if (@hasField(@TypeOf(config), "ReleaseFast")) { | |
| 36 | self.addExpect(config.name, config.source, optimize_mode, config.ReleaseFast); | |
| 37 | } | |
| 38 | }, | |
| 39 | .ReleaseSmall => { | |
| 40 | if (@hasField(@TypeOf(config), "ReleaseSmall")) { | |
| 41 | self.addExpect(config.name, config.source, optimize_mode, config.ReleaseSmall); | |
| 42 | } | |
| 43 | }, | |
| 44 | } | |
| 45 | } | |
| 16 | const PerMode = struct { | |
| 17 | expect: []const u8, | |
| 18 | exclude_os: []const std.Target.Os.Tag = &.{}, | |
| 19 | error_tracing: ?bool = null, | |
| 20 | }; | |
| 21 | }; | |
| 22 | ||
| 23 | pub fn addCase(self: *StackTrace, config: Config) void { | |
| 24 | if (config.Debug) |per_mode| | |
| 25 | self.addExpect(config.name, config.source, .Debug, per_mode); | |
| 26 | ||
| 27 | if (config.ReleaseSmall) |per_mode| | |
| 28 | self.addExpect(config.name, config.source, .ReleaseSmall, per_mode); | |
| 29 | ||
| 30 | if (config.ReleaseFast) |per_mode| | |
| 31 | self.addExpect(config.name, config.source, .ReleaseFast, per_mode); | |
| 32 | ||
| 33 | if (config.ReleaseSafe) |per_mode| | |
| 34 | self.addExpect(config.name, config.source, .ReleaseSafe, per_mode); | |
| 46 | 35 | } |
| 47 | 36 | |
| 48 | 37 | fn addExpect( |
| ... | ... | @@ -50,19 +39,9 @@ fn addExpect( |
| 50 | 39 | name: []const u8, |
| 51 | 40 | source: []const u8, |
| 52 | 41 | optimize_mode: OptimizeMode, |
| 53 | mode_config: anytype, | |
| 42 | mode_config: Config.PerMode, | |
| 54 | 43 | ) void { |
| 55 | if (@hasField(@TypeOf(mode_config), "exclude")) { | |
| 56 | if (mode_config.exclude.exclude()) return; | |
| 57 | } | |
| 58 | if (@hasField(@TypeOf(mode_config), "exclude_arch")) { | |
| 59 | const exclude_arch: []const std.Target.Cpu.Arch = &mode_config.exclude_arch; | |
| 60 | for (exclude_arch) |arch| if (arch == builtin.cpu.arch) return; | |
| 61 | } | |
| 62 | if (@hasField(@TypeOf(mode_config), "exclude_os")) { | |
| 63 | const exclude_os: []const std.Target.Os.Tag = &mode_config.exclude_os; | |
| 64 | for (exclude_os) |os| if (os == builtin.os.tag) return; | |
| 65 | } | |
| 44 | for (mode_config.exclude_os) |tag| if (tag == builtin.os.tag) return; | |
| 66 | 45 | |
| 67 | 46 | const b = self.b; |
| 68 | 47 | const annotated_case_name = fmt.allocPrint(b.allocator, "check {s} ({s})", .{ |
| ... | ... | @@ -78,6 +57,7 @@ fn addExpect( |
| 78 | 57 | .root_source_file = write_src.files.items[0].getPath(), |
| 79 | 58 | .optimize = optimize_mode, |
| 80 | 59 | .target = b.host, |
| 60 | .error_tracing = mode_config.error_tracing, | |
| 81 | 61 | }); |
| 82 | 62 | |
| 83 | 63 | const run = b.addRunArtifact(exe); |
test/stack_traces.zig+30-17| ... | ... | @@ -20,7 +20,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 20 | 20 | , |
| 21 | 21 | }, |
| 22 | 22 | .ReleaseSafe = .{ |
| 23 | .exclude_os = .{ | |
| 23 | .exclude_os = &.{ | |
| 24 | 24 | .windows, // TODO |
| 25 | 25 | .linux, // defeated by aggressive inlining |
| 26 | 26 | }, |
| ... | ... | @@ -31,6 +31,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 31 | 31 | \\ ^ |
| 32 | 32 | \\ |
| 33 | 33 | , |
| 34 | .error_tracing = true, | |
| 34 | 35 | }, |
| 35 | 36 | .ReleaseFast = .{ |
| 36 | 37 | .expect = |
| ... | ... | @@ -70,7 +71,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 70 | 71 | , |
| 71 | 72 | }, |
| 72 | 73 | .ReleaseSafe = .{ |
| 73 | .exclude_os = .{ | |
| 74 | .exclude_os = &.{ | |
| 74 | 75 | .windows, // TODO |
| 75 | 76 | }, |
| 76 | 77 | .expect = |
| ... | ... | @@ -83,6 +84,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 83 | 84 | \\ ^ |
| 84 | 85 | \\ |
| 85 | 86 | , |
| 87 | .error_tracing = true, | |
| 86 | 88 | }, |
| 87 | 89 | .ReleaseFast = .{ |
| 88 | 90 | .expect = |
| ... | ... | @@ -125,7 +127,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 125 | 127 | , |
| 126 | 128 | }, |
| 127 | 129 | .ReleaseSafe = .{ |
| 128 | .exclude_os = .{ | |
| 130 | .exclude_os = &.{ | |
| 129 | 131 | .windows, // TODO |
| 130 | 132 | .linux, // defeated by aggressive inlining |
| 131 | 133 | }, |
| ... | ... | @@ -136,6 +138,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 136 | 138 | \\ ^ |
| 137 | 139 | \\ |
| 138 | 140 | , |
| 141 | .error_tracing = true, | |
| 139 | 142 | }, |
| 140 | 143 | .ReleaseFast = .{ |
| 141 | 144 | .expect = |
| ... | ... | @@ -176,7 +179,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 176 | 179 | , |
| 177 | 180 | }, |
| 178 | 181 | .ReleaseSafe = .{ |
| 179 | .exclude_os = .{ | |
| 182 | .exclude_os = &.{ | |
| 180 | 183 | .windows, // TODO |
| 181 | 184 | .linux, // defeated by aggressive inlining |
| 182 | 185 | }, |
| ... | ... | @@ -187,6 +190,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 187 | 190 | \\ ^ |
| 188 | 191 | \\ |
| 189 | 192 | , |
| 193 | .error_tracing = true, | |
| 190 | 194 | }, |
| 191 | 195 | .ReleaseFast = .{ |
| 192 | 196 | .expect = |
| ... | ... | @@ -230,7 +234,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 230 | 234 | , |
| 231 | 235 | }, |
| 232 | 236 | .ReleaseSafe = .{ |
| 233 | .exclude_os = .{ | |
| 237 | .exclude_os = &.{ | |
| 234 | 238 | .windows, // TODO |
| 235 | 239 | .linux, // defeated by aggressive inlining |
| 236 | 240 | }, |
| ... | ... | @@ -244,6 +248,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 244 | 248 | \\ ^ |
| 245 | 249 | \\ |
| 246 | 250 | , |
| 251 | .error_tracing = true, | |
| 247 | 252 | }, |
| 248 | 253 | .ReleaseFast = .{ |
| 249 | 254 | .expect = |
| ... | ... | @@ -286,7 +291,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 286 | 291 | , |
| 287 | 292 | }, |
| 288 | 293 | .ReleaseSafe = .{ |
| 289 | .exclude_os = .{ | |
| 294 | .exclude_os = &.{ | |
| 290 | 295 | .windows, // TODO |
| 291 | 296 | .linux, // defeated by aggressive inlining |
| 292 | 297 | }, |
| ... | ... | @@ -297,6 +302,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 297 | 302 | \\ ^ |
| 298 | 303 | \\ |
| 299 | 304 | , |
| 305 | .error_tracing = true, | |
| 300 | 306 | }, |
| 301 | 307 | .ReleaseFast = .{ |
| 302 | 308 | .expect = |
| ... | ... | @@ -336,7 +342,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 336 | 342 | , |
| 337 | 343 | }, |
| 338 | 344 | .ReleaseSafe = .{ |
| 339 | .exclude_os = .{ | |
| 345 | .exclude_os = &.{ | |
| 340 | 346 | .windows, // TODO |
| 341 | 347 | .linux, // defeated by aggressive inlining |
| 342 | 348 | }, |
| ... | ... | @@ -350,6 +356,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 350 | 356 | \\ ^ |
| 351 | 357 | \\ |
| 352 | 358 | , |
| 359 | .error_tracing = true, | |
| 353 | 360 | }, |
| 354 | 361 | .ReleaseFast = .{ |
| 355 | 362 | .expect = |
| ... | ... | @@ -391,7 +398,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 391 | 398 | , |
| 392 | 399 | }, |
| 393 | 400 | .ReleaseSafe = .{ |
| 394 | .exclude_os = .{ | |
| 401 | .exclude_os = &.{ | |
| 395 | 402 | .windows, // TODO |
| 396 | 403 | .linux, // defeated by aggressive inlining |
| 397 | 404 | }, |
| ... | ... | @@ -402,6 +409,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 402 | 409 | \\ ^ |
| 403 | 410 | \\ |
| 404 | 411 | , |
| 412 | .error_tracing = true, | |
| 405 | 413 | }, |
| 406 | 414 | .ReleaseFast = .{ |
| 407 | 415 | .expect = |
| ... | ... | @@ -461,7 +469,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 461 | 469 | , |
| 462 | 470 | }, |
| 463 | 471 | .ReleaseSafe = .{ |
| 464 | .exclude_os = .{ | |
| 472 | .exclude_os = &.{ | |
| 465 | 473 | .windows, // TODO |
| 466 | 474 | .linux, // defeated by aggressive inlining |
| 467 | 475 | }, |
| ... | ... | @@ -478,6 +486,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 478 | 486 | \\ ^ |
| 479 | 487 | \\ |
| 480 | 488 | , |
| 489 | .error_tracing = true, | |
| 481 | 490 | }, |
| 482 | 491 | .ReleaseFast = .{ |
| 483 | 492 | .expect = |
| ... | ... | @@ -531,7 +540,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 531 | 540 | , |
| 532 | 541 | }, |
| 533 | 542 | .ReleaseSafe = .{ |
| 534 | .exclude_os = .{ | |
| 543 | .exclude_os = &.{ | |
| 535 | 544 | .windows, // TODO |
| 536 | 545 | }, |
| 537 | 546 | .expect = |
| ... | ... | @@ -547,6 +556,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 547 | 556 | \\ ^ |
| 548 | 557 | \\ |
| 549 | 558 | , |
| 559 | .error_tracing = true, | |
| 550 | 560 | }, |
| 551 | 561 | .ReleaseFast = .{ |
| 552 | 562 | .expect = |
| ... | ... | @@ -595,7 +605,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 595 | 605 | , |
| 596 | 606 | }, |
| 597 | 607 | .ReleaseSafe = .{ |
| 598 | .exclude_os = .{ | |
| 608 | .exclude_os = &.{ | |
| 599 | 609 | .windows, // TODO |
| 600 | 610 | }, |
| 601 | 611 | .expect = |
| ... | ... | @@ -611,6 +621,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 611 | 621 | \\ ^ |
| 612 | 622 | \\ |
| 613 | 623 | , |
| 624 | .error_tracing = true, | |
| 614 | 625 | }, |
| 615 | 626 | .ReleaseFast = .{ |
| 616 | 627 | .expect = |
| ... | ... | @@ -659,7 +670,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 659 | 670 | , |
| 660 | 671 | }, |
| 661 | 672 | .ReleaseSafe = .{ |
| 662 | .exclude_os = .{ | |
| 673 | .exclude_os = &.{ | |
| 663 | 674 | .windows, // TODO |
| 664 | 675 | }, |
| 665 | 676 | .expect = |
| ... | ... | @@ -675,6 +686,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 675 | 686 | \\ ^ |
| 676 | 687 | \\ |
| 677 | 688 | , |
| 689 | .error_tracing = true, | |
| 678 | 690 | }, |
| 679 | 691 | .ReleaseFast = .{ |
| 680 | 692 | .expect = |
| ... | ... | @@ -728,7 +740,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 728 | 740 | , |
| 729 | 741 | }, |
| 730 | 742 | .ReleaseSafe = .{ |
| 731 | .exclude_os = .{ | |
| 743 | .exclude_os = &.{ | |
| 732 | 744 | .windows, // TODO |
| 733 | 745 | }, |
| 734 | 746 | .expect = |
| ... | ... | @@ -747,6 +759,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 747 | 759 | \\ ^ |
| 748 | 760 | \\ |
| 749 | 761 | , |
| 762 | .error_tracing = true, | |
| 750 | 763 | }, |
| 751 | 764 | .ReleaseFast = .{ |
| 752 | 765 | .expect = |
| ... | ... | @@ -763,10 +776,6 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 763 | 776 | }); |
| 764 | 777 | |
| 765 | 778 | cases.addCase(.{ |
| 766 | .exclude_os = .{ | |
| 767 | .openbsd, // integer overflow | |
| 768 | .windows, // TODO intermittent failures | |
| 769 | }, | |
| 770 | 779 | .name = "dumpCurrentStackTrace", |
| 771 | 780 | .source = |
| 772 | 781 | \\const std = @import("std"); |
| ... | ... | @@ -783,6 +792,10 @@ pub fn addCases(cases: *tests.StackTracesContext) void { |
| 783 | 792 | \\} |
| 784 | 793 | , |
| 785 | 794 | .Debug = .{ |
| 795 | .exclude_os = &.{ | |
| 796 | .openbsd, // integer overflow | |
| 797 | .windows, // TODO intermittent failures | |
| 798 | }, | |
| 786 | 799 | .expect = |
| 787 | 800 | \\source.zig:7:8: [address] in foo (test) |
| 788 | 801 | \\ bar(); |