Skip to content

Commit e2d0361

Browse files
committed
std.debug: Rename TTY.Color enum values to snake case
1 parent eef9275 commit e2d0361

File tree

5 files changed

+87
-87
lines changed

5 files changed

+87
-87
lines changed

lib/build_runner.zig

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,9 @@ fn runStepNames(
476476

477477
if (run.enable_summary != false) {
478478
const total_count = success_count + failure_count + pending_count + skipped_count;
479-
ttyconf.setColor(stderr, .Cyan) catch {};
479+
ttyconf.setColor(stderr, .cyan) catch {};
480480
stderr.writeAll("Build Summary:") catch {};
481-
ttyconf.setColor(stderr, .Reset) catch {};
481+
ttyconf.setColor(stderr, .reset) catch {};
482482
stderr.writer().print(" {d}/{d} steps succeeded", .{ success_count, total_count }) catch {};
483483
if (skipped_count > 0) stderr.writer().print("; {d} skipped", .{skipped_count}) catch {};
484484
if (failure_count > 0) stderr.writer().print("; {d} failed", .{failure_count}) catch {};
@@ -489,9 +489,9 @@ fn runStepNames(
489489
if (test_leak_count > 0) stderr.writer().print("; {d} leaked", .{test_leak_count}) catch {};
490490

491491
if (run.enable_summary == null) {
492-
ttyconf.setColor(stderr, .Dim) catch {};
492+
ttyconf.setColor(stderr, .dim) catch {};
493493
stderr.writeAll(" (disable with -fno-summary)") catch {};
494-
ttyconf.setColor(stderr, .Reset) catch {};
494+
ttyconf.setColor(stderr, .reset) catch {};
495495
}
496496
stderr.writeAll("\n") catch {};
497497

@@ -560,7 +560,7 @@ fn printTreeStep(
560560
const first = step_stack.swapRemove(s);
561561
try printPrefix(parent_node, stderr, ttyconf);
562562

563-
if (!first) try ttyconf.setColor(stderr, .Dim);
563+
if (!first) try ttyconf.setColor(stderr, .dim);
564564
if (parent_node.parent != null) {
565565
if (parent_node.last) {
566566
try stderr.writeAll(switch (ttyconf) {
@@ -586,28 +586,28 @@ fn printTreeStep(
586586
.running => unreachable,
587587

588588
.dependency_failure => {
589-
try ttyconf.setColor(stderr, .Dim);
589+
try ttyconf.setColor(stderr, .dim);
590590
try stderr.writeAll(" transitive failure\n");
591-
try ttyconf.setColor(stderr, .Reset);
591+
try ttyconf.setColor(stderr, .reset);
592592
},
593593

594594
.success => {
595-
try ttyconf.setColor(stderr, .Green);
595+
try ttyconf.setColor(stderr, .green);
596596
if (s.result_cached) {
597597
try stderr.writeAll(" cached");
598598
} else if (s.test_results.test_count > 0) {
599599
const pass_count = s.test_results.passCount();
600600
try stderr.writer().print(" {d} passed", .{pass_count});
601601
if (s.test_results.skip_count > 0) {
602-
try ttyconf.setColor(stderr, .Yellow);
602+
try ttyconf.setColor(stderr, .yellow);
603603
try stderr.writer().print(" {d} skipped", .{s.test_results.skip_count});
604604
}
605605
} else {
606606
try stderr.writeAll(" success");
607607
}
608-
try ttyconf.setColor(stderr, .Reset);
608+
try ttyconf.setColor(stderr, .reset);
609609
if (s.result_duration_ns) |ns| {
610-
try ttyconf.setColor(stderr, .Dim);
610+
try ttyconf.setColor(stderr, .dim);
611611
if (ns >= std.time.ns_per_min) {
612612
try stderr.writer().print(" {d}m", .{ns / std.time.ns_per_min});
613613
} else if (ns >= std.time.ns_per_s) {
@@ -619,11 +619,11 @@ fn printTreeStep(
619619
} else {
620620
try stderr.writer().print(" {d}ns", .{ns});
621621
}
622-
try ttyconf.setColor(stderr, .Reset);
622+
try ttyconf.setColor(stderr, .reset);
623623
}
624624
if (s.result_peak_rss != 0) {
625625
const rss = s.result_peak_rss;
626-
try ttyconf.setColor(stderr, .Dim);
626+
try ttyconf.setColor(stderr, .dim);
627627
if (rss >= 1000_000_000) {
628628
try stderr.writer().print(" MaxRSS:{d}G", .{rss / 1000_000_000});
629629
} else if (rss >= 1000_000) {
@@ -633,57 +633,57 @@ fn printTreeStep(
633633
} else {
634634
try stderr.writer().print(" MaxRSS:{d}B", .{rss});
635635
}
636-
try ttyconf.setColor(stderr, .Reset);
636+
try ttyconf.setColor(stderr, .reset);
637637
}
638638
try stderr.writeAll("\n");
639639
},
640640

641641
.skipped => {
642-
try ttyconf.setColor(stderr, .Yellow);
642+
try ttyconf.setColor(stderr, .yellow);
643643
try stderr.writeAll(" skipped\n");
644-
try ttyconf.setColor(stderr, .Reset);
644+
try ttyconf.setColor(stderr, .reset);
645645
},
646646

647647
.failure => {
648648
if (s.result_error_bundle.errorMessageCount() > 0) {
649-
try ttyconf.setColor(stderr, .Red);
649+
try ttyconf.setColor(stderr, .red);
650650
try stderr.writer().print(" {d} errors\n", .{
651651
s.result_error_bundle.errorMessageCount(),
652652
});
653-
try ttyconf.setColor(stderr, .Reset);
653+
try ttyconf.setColor(stderr, .reset);
654654
} else if (!s.test_results.isSuccess()) {
655655
try stderr.writer().print(" {d}/{d} passed", .{
656656
s.test_results.passCount(), s.test_results.test_count,
657657
});
658658
if (s.test_results.fail_count > 0) {
659659
try stderr.writeAll(", ");
660-
try ttyconf.setColor(stderr, .Red);
660+
try ttyconf.setColor(stderr, .red);
661661
try stderr.writer().print("{d} failed", .{
662662
s.test_results.fail_count,
663663
});
664-
try ttyconf.setColor(stderr, .Reset);
664+
try ttyconf.setColor(stderr, .reset);
665665
}
666666
if (s.test_results.skip_count > 0) {
667667
try stderr.writeAll(", ");
668-
try ttyconf.setColor(stderr, .Yellow);
668+
try ttyconf.setColor(stderr, .yellow);
669669
try stderr.writer().print("{d} skipped", .{
670670
s.test_results.skip_count,
671671
});
672-
try ttyconf.setColor(stderr, .Reset);
672+
try ttyconf.setColor(stderr, .reset);
673673
}
674674
if (s.test_results.leak_count > 0) {
675675
try stderr.writeAll(", ");
676-
try ttyconf.setColor(stderr, .Red);
676+
try ttyconf.setColor(stderr, .red);
677677
try stderr.writer().print("{d} leaked", .{
678678
s.test_results.leak_count,
679679
});
680-
try ttyconf.setColor(stderr, .Reset);
680+
try ttyconf.setColor(stderr, .reset);
681681
}
682682
try stderr.writeAll("\n");
683683
} else {
684-
try ttyconf.setColor(stderr, .Red);
684+
try ttyconf.setColor(stderr, .red);
685685
try stderr.writeAll(" failure\n");
686-
try ttyconf.setColor(stderr, .Reset);
686+
try ttyconf.setColor(stderr, .reset);
687687
}
688688
},
689689
}
@@ -703,7 +703,7 @@ fn printTreeStep(
703703
s.dependencies.items.len,
704704
});
705705
}
706-
try ttyconf.setColor(stderr, .Reset);
706+
try ttyconf.setColor(stderr, .reset);
707707
}
708708
}
709709

@@ -819,13 +819,13 @@ fn workerMakeOneStep(
819819
for (s.result_error_msgs.items) |msg| {
820820
// Sometimes it feels like you just can't catch a break. Finally,
821821
// with Zig, you can.
822-
ttyconf.setColor(stderr, .Bold) catch break;
822+
ttyconf.setColor(stderr, .bold) catch break;
823823
stderr.writeAll(s.owner.dep_prefix) catch break;
824824
stderr.writeAll(s.name) catch break;
825825
stderr.writeAll(": ") catch break;
826-
ttyconf.setColor(stderr, .Red) catch break;
826+
ttyconf.setColor(stderr, .red) catch break;
827827
stderr.writeAll("error: ") catch break;
828-
ttyconf.setColor(stderr, .Reset) catch break;
828+
ttyconf.setColor(stderr, .reset) catch break;
829829
stderr.writeAll(msg) catch break;
830830
stderr.writeAll("\n") catch break;
831831
}

lib/std/Build.zig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,9 +1713,9 @@ fn dumpBadGetPathHelp(
17131713
});
17141714

17151715
const tty_config = std.debug.detectTTYConfig(stderr);
1716-
tty_config.setColor(w, .Red) catch {};
1716+
tty_config.setColor(w, .red) catch {};
17171717
try stderr.writeAll(" The step was created by this stack trace:\n");
1718-
tty_config.setColor(w, .Reset) catch {};
1718+
tty_config.setColor(w, .reset) catch {};
17191719

17201720
const debug_info = std.debug.getSelfDebugInfo() catch |err| {
17211721
try w.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)});
@@ -1727,19 +1727,19 @@ fn dumpBadGetPathHelp(
17271727
return;
17281728
};
17291729
if (asking_step) |as| {
1730-
tty_config.setColor(w, .Red) catch {};
1730+
tty_config.setColor(w, .red) catch {};
17311731
try stderr.writeAll(" The step that is missing a dependency on the above step was created by this stack trace:\n");
1732-
tty_config.setColor(w, .Reset) catch {};
1732+
tty_config.setColor(w, .reset) catch {};
17331733

17341734
std.debug.writeStackTrace(as.getStackTrace(), w, ally, debug_info, tty_config) catch |err| {
17351735
try stderr.writer().print("Unable to dump stack trace: {s}\n", .{@errorName(err)});
17361736
return;
17371737
};
17381738
}
17391739

1740-
tty_config.setColor(w, .Red) catch {};
1740+
tty_config.setColor(w, .red) catch {};
17411741
try stderr.writeAll(" Hope that helps. Proceeding to panic.\n");
1742-
tty_config.setColor(w, .Reset) catch {};
1742+
tty_config.setColor(w, .reset) catch {};
17431743
}
17441744

17451745
/// Allocates a new string for assigning a value to a named macro.

lib/std/debug.zig

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,9 @@ pub fn writeStackTrace(
421421
if (stack_trace.index > stack_trace.instruction_addresses.len) {
422422
const dropped_frames = stack_trace.index - stack_trace.instruction_addresses.len;
423423

424-
tty_config.setColor(out_stream, .Bold) catch {};
424+
tty_config.setColor(out_stream, .bold) catch {};
425425
try out_stream.print("({d} additional stack frames skipped...)\n", .{dropped_frames});
426-
tty_config.setColor(out_stream, .Reset) catch {};
426+
tty_config.setColor(out_stream, .reset) catch {};
427427
}
428428
}
429429

@@ -655,14 +655,14 @@ pub fn writeCurrentStackTraceWindows(
655655
/// for debugging purposes, such as coloring text, etc.
656656
pub const TTY = struct {
657657
pub const Color = enum {
658-
Red,
659-
Green,
660-
Yellow,
661-
Cyan,
662-
White,
663-
Dim,
664-
Bold,
665-
Reset,
658+
red,
659+
green,
660+
yellow,
661+
cyan,
662+
white,
663+
dim,
664+
bold,
665+
reset,
666666
};
667667

668668
pub const Config = union(enum) {
@@ -680,26 +680,26 @@ pub const TTY = struct {
680680
.no_color => return,
681681
.escape_codes => {
682682
const color_string = switch (color) {
683-
.Red => "\x1b[31;1m",
684-
.Green => "\x1b[32;1m",
685-
.Yellow => "\x1b[33;1m",
686-
.Cyan => "\x1b[36;1m",
687-
.White => "\x1b[37;1m",
688-
.Bold => "\x1b[1m",
689-
.Dim => "\x1b[2m",
690-
.Reset => "\x1b[0m",
683+
.red => "\x1b[31;1m",
684+
.green => "\x1b[32;1m",
685+
.yellow => "\x1b[33;1m",
686+
.cyan => "\x1b[36;1m",
687+
.white => "\x1b[37;1m",
688+
.bold => "\x1b[1m",
689+
.dim => "\x1b[2m",
690+
.reset => "\x1b[0m",
691691
};
692692
try out_stream.writeAll(color_string);
693693
},
694694
.windows_api => |ctx| if (native_os == .windows) {
695695
const attributes = switch (color) {
696-
.Red => windows.FOREGROUND_RED | windows.FOREGROUND_INTENSITY,
697-
.Green => windows.FOREGROUND_GREEN | windows.FOREGROUND_INTENSITY,
698-
.Yellow => windows.FOREGROUND_RED | windows.FOREGROUND_GREEN | windows.FOREGROUND_INTENSITY,
699-
.Cyan => windows.FOREGROUND_GREEN | windows.FOREGROUND_BLUE | windows.FOREGROUND_INTENSITY,
700-
.White, .Bold => windows.FOREGROUND_RED | windows.FOREGROUND_GREEN | windows.FOREGROUND_BLUE | windows.FOREGROUND_INTENSITY,
701-
.Dim => windows.FOREGROUND_INTENSITY,
702-
.Reset => ctx.reset_attributes,
696+
.red => windows.FOREGROUND_RED | windows.FOREGROUND_INTENSITY,
697+
.green => windows.FOREGROUND_GREEN | windows.FOREGROUND_INTENSITY,
698+
.yellow => windows.FOREGROUND_RED | windows.FOREGROUND_GREEN | windows.FOREGROUND_INTENSITY,
699+
.cyan => windows.FOREGROUND_GREEN | windows.FOREGROUND_BLUE | windows.FOREGROUND_INTENSITY,
700+
.white, .bold => windows.FOREGROUND_RED | windows.FOREGROUND_GREEN | windows.FOREGROUND_BLUE | windows.FOREGROUND_INTENSITY,
701+
.dim => windows.FOREGROUND_INTENSITY,
702+
.reset => ctx.reset_attributes,
703703
};
704704
try windows.SetConsoleTextAttribute(ctx.handle, attributes);
705705
} else {
@@ -831,19 +831,19 @@ fn printLineInfo(
831831
comptime printLineFromFile: anytype,
832832
) !void {
833833
nosuspend {
834-
try tty_config.setColor(out_stream, .Bold);
834+
try tty_config.setColor(out_stream, .bold);
835835

836836
if (line_info) |*li| {
837837
try out_stream.print("{s}:{d}:{d}", .{ li.file_name, li.line, li.column });
838838
} else {
839839
try out_stream.writeAll("???:?:?");
840840
}
841841

842-
try tty_config.setColor(out_stream, .Reset);
842+
try tty_config.setColor(out_stream, .reset);
843843
try out_stream.writeAll(": ");
844-
try tty_config.setColor(out_stream, .Dim);
844+
try tty_config.setColor(out_stream, .dim);
845845
try out_stream.print("0x{x} in {s} ({s})", .{ address, symbol_name, compile_unit_name });
846-
try tty_config.setColor(out_stream, .Reset);
846+
try tty_config.setColor(out_stream, .reset);
847847
try out_stream.writeAll("\n");
848848

849849
// Show the matching source code line if possible
@@ -854,9 +854,9 @@ fn printLineInfo(
854854
const space_needed = @intCast(usize, li.column - 1);
855855

856856
try out_stream.writeByteNTimes(' ', space_needed);
857-
try tty_config.setColor(out_stream, .Green);
857+
try tty_config.setColor(out_stream, .green);
858858
try out_stream.writeAll("^");
859-
try tty_config.setColor(out_stream, .Reset);
859+
try tty_config.setColor(out_stream, .reset);
860860
}
861861
try out_stream.writeAll("\n");
862862
} else |err| switch (err) {

lib/std/testing.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,9 @@ fn SliceDiffer(comptime T: type) type {
387387
for (self.expected, 0..) |value, i| {
388388
var full_index = self.start_index + i;
389389
const diff = if (i < self.actual.len) !std.meta.eql(self.actual[i], value) else true;
390-
if (diff) try self.ttyconf.setColor(writer, .Red);
390+
if (diff) try self.ttyconf.setColor(writer, .red);
391391
try writer.print("[{}]: {any}\n", .{ full_index, value });
392-
if (diff) try self.ttyconf.setColor(writer, .Reset);
392+
if (diff) try self.ttyconf.setColor(writer, .reset);
393393
}
394394
}
395395
};
@@ -427,9 +427,9 @@ const BytesDiffer = struct {
427427
}
428428

429429
fn writeByteDiff(self: BytesDiffer, writer: anytype, comptime fmt: []const u8, byte: u8, diff: bool) !void {
430-
if (diff) try self.ttyconf.setColor(writer, .Red);
430+
if (diff) try self.ttyconf.setColor(writer, .red);
431431
try writer.print(fmt, .{byte});
432-
if (diff) try self.ttyconf.setColor(writer, .Reset);
432+
if (diff) try self.ttyconf.setColor(writer, .reset);
433433
}
434434

435435
const ChunkIterator = struct {

0 commit comments

Comments
 (0)