authorgravatar for noam@pixelhero.devNoam Preil <noam@pixelhero.dev> 2020-06-27 20:01:20-04:00
committergravatar for noam@pixelhero.devNoam Preil <noam@pixelhero.dev> 2020-06-27 20:01:20-04:00
log54148a8c888f47361c141f0635671e1ed12ddba4
tree2da3edd36a80f9b301efbff2e40360bfe0e75588
parentab307a22f627fd01ef6220d62a0312fdd610eaed
signature Commit is signed but in an unrecognized format.

Stage2/TestHarness: Improve progress reporting


1 files changed, 17 insertions(+), 7 deletions(-)

src-self-hosted/test.zig+17-7
......@@ -391,8 +391,10 @@ pub const TestContext = struct {
391391 prg_node.activate();
392392 defer prg_node.end();
393393
394 // So that we can see which test case failed when the leak checker goes off.
395 progress.refresh();
394 // So that we can see which test case failed when the leak checker goes off,
395 // or there's an internal error
396 progress.initial_delay_ns = 0;
397 progress.refresh_rate_ns = 0;
396398
397399 const info = try std.zig.system.NativeTargetInfo.detect(std.testing.allocator, case.target);
398400 try self.runOneCase(std.testing.allocator, &prg_node, case, info.target);
......@@ -408,10 +410,6 @@ pub const TestContext = struct {
408410 const root_pkg = try Package.create(allocator, tmp.dir, ".", tmp_src_path);
409411 defer root_pkg.destroy();
410412
411 var prg_node = root_node.start(case.name, case.updates.items.len);
412 prg_node.activate();
413 defer prg_node.end();
414
415413 const bin_name = try std.zig.binNameAlloc(allocator, "test_case", target, case.output_mode, null);
416414 defer allocator.free(bin_name);
417415
......@@ -434,7 +432,7 @@ pub const TestContext = struct {
434432 defer module.deinit();
435433
436434 for (case.updates.items) |update, update_index| {
437 var update_node = prg_node.start("update", 4);
435 var update_node = root_node.start("update", 3);
438436 update_node.activate();
439437 defer update_node.end();
440438
......@@ -451,6 +449,7 @@ pub const TestContext = struct {
451449
452450 switch (update.case) {
453451 .Transformation => |expected_output| {
452 update_node.estimated_total_items = 5;
454453 var emit_node = update_node.start("emit", null);
455454 emit_node.activate();
456455 var new_zir_module = try zir.emit(allocator, module);
......@@ -464,9 +463,15 @@ pub const TestContext = struct {
464463 try new_zir_module.writeToStream(allocator, out_zir.outStream());
465464 write_node.end();
466465
466 var test_node = update_node.start("assert", null);
467 test_node.activate();
467468 std.testing.expectEqualSlices(u8, expected_output, out_zir.items);
469 test_node.end();
468470 },
469471 .Error => |e| {
472 var test_node = update_node.start("assert", null);
473 test_node.activate();
474 defer test_node.end();
470475 var handled_errors = try allocator.alloc(bool, e.len);
471476 defer allocator.free(handled_errors);
472477 for (handled_errors) |*h| {
......@@ -495,6 +500,7 @@ pub const TestContext = struct {
495500 }
496501 },
497502 .Execution => |expected_stdout| {
503 update_node.estimated_total_items = 4;
498504 var exec_result = x: {
499505 var exec_node = update_node.start("execute", null);
500506 exec_node.activate();
......@@ -511,6 +517,10 @@ pub const TestContext = struct {
511517 .cwd_dir = tmp.dir,
512518 });
513519 };
520 var test_node = update_node.start("test", null);
521 test_node.activate();
522 defer test_node.end();
523
514524 defer allocator.free(exec_result.stdout);
515525 defer allocator.free(exec_result.stderr);
516526 switch (exec_result.term) {