Commit 39c2eee285
Changed files (5)
lib/std/zig/ErrorBundle.zig
@@ -163,7 +163,7 @@ pub fn renderToStdErr(eb: ErrorBundle, options: RenderOptions) void {
pub fn renderToWriter(eb: ErrorBundle, options: RenderOptions, writer: anytype) anyerror!void {
for (eb.getMessages()) |err_msg| {
- try renderErrorMessageToWriter(eb, options, err_msg, writer, "error", .Red, 0);
+ try renderErrorMessageToWriter(eb, options, err_msg, writer, "error", .red, 0);
}
if (options.include_log_text) {
@@ -191,7 +191,7 @@ fn renderErrorMessageToWriter(
if (err_msg.src_loc != .none) {
const src = eb.extraData(SourceLocation, @enumToInt(err_msg.src_loc));
try counting_stderr.writeByteNTimes(' ', indent);
- try ttyconf.setColor(stderr, .Bold);
+ try ttyconf.setColor(stderr, .bold);
try counting_stderr.print("{s}:{d}:{d}: ", .{
eb.nullTerminatedString(src.data.src_path),
src.data.line + 1,
@@ -203,17 +203,17 @@ fn renderErrorMessageToWriter(
// This is the length of the part before the error message:
// e.g. "file.zig:4:5: error: "
const prefix_len = @intCast(usize, counting_stderr.context.bytes_written);
- try ttyconf.setColor(stderr, .Reset);
- try ttyconf.setColor(stderr, .Bold);
+ try ttyconf.setColor(stderr, .reset);
+ try ttyconf.setColor(stderr, .bold);
if (err_msg.count == 1) {
try writeMsg(eb, err_msg, stderr, prefix_len);
try stderr.writeByte('\n');
} else {
try writeMsg(eb, err_msg, stderr, prefix_len);
- try ttyconf.setColor(stderr, .Dim);
+ try ttyconf.setColor(stderr, .dim);
try stderr.print(" ({d} times)\n", .{err_msg.count});
}
- try ttyconf.setColor(stderr, .Reset);
+ try ttyconf.setColor(stderr, .reset);
if (src.data.source_line != 0 and options.include_source_line) {
const line = eb.nullTerminatedString(src.data.source_line);
for (line) |b| switch (b) {
@@ -226,19 +226,19 @@ fn renderErrorMessageToWriter(
// -1 since span.main includes the caret
const after_caret = src.data.span_end - src.data.span_main -| 1;
try stderr.writeByteNTimes(' ', src.data.column - before_caret);
- try ttyconf.setColor(stderr, .Green);
+ try ttyconf.setColor(stderr, .green);
try stderr.writeByteNTimes('~', before_caret);
try stderr.writeByte('^');
try stderr.writeByteNTimes('~', after_caret);
try stderr.writeByte('\n');
- try ttyconf.setColor(stderr, .Reset);
+ try ttyconf.setColor(stderr, .reset);
}
for (eb.getNotes(err_msg_index)) |note| {
- try renderErrorMessageToWriter(eb, options, note, stderr, "note", .Cyan, indent);
+ try renderErrorMessageToWriter(eb, options, note, stderr, "note", .cyan, indent);
}
if (src.data.reference_trace_len > 0 and options.include_reference_trace) {
- try ttyconf.setColor(stderr, .Reset);
- try ttyconf.setColor(stderr, .Dim);
+ try ttyconf.setColor(stderr, .reset);
+ try ttyconf.setColor(stderr, .dim);
try stderr.print("referenced by:\n", .{});
var ref_index = src.end;
for (0..src.data.reference_trace_len) |_| {
@@ -266,25 +266,25 @@ fn renderErrorMessageToWriter(
}
}
try stderr.writeByte('\n');
- try ttyconf.setColor(stderr, .Reset);
+ try ttyconf.setColor(stderr, .reset);
}
} else {
try ttyconf.setColor(stderr, color);
try stderr.writeByteNTimes(' ', indent);
try stderr.writeAll(kind);
try stderr.writeAll(": ");
- try ttyconf.setColor(stderr, .Reset);
+ try ttyconf.setColor(stderr, .reset);
const msg = eb.nullTerminatedString(err_msg.msg);
if (err_msg.count == 1) {
try stderr.print("{s}\n", .{msg});
} else {
try stderr.print("{s}", .{msg});
- try ttyconf.setColor(stderr, .Dim);
+ try ttyconf.setColor(stderr, .dim);
try stderr.print(" ({d} times)\n", .{err_msg.count});
}
- try ttyconf.setColor(stderr, .Reset);
+ try ttyconf.setColor(stderr, .reset);
for (eb.getNotes(err_msg_index)) |note| {
- try renderErrorMessageToWriter(eb, options, note, stderr, "note", .Cyan, indent + 4);
+ try renderErrorMessageToWriter(eb, options, note, stderr, "note", .cyan, indent + 4);
}
}
}
lib/std/Build.zig
@@ -1713,9 +1713,9 @@ fn dumpBadGetPathHelp(
});
const tty_config = std.debug.detectTTYConfig(stderr);
- tty_config.setColor(w, .Red) catch {};
+ tty_config.setColor(w, .red) catch {};
try stderr.writeAll(" The step was created by this stack trace:\n");
- tty_config.setColor(w, .Reset) catch {};
+ tty_config.setColor(w, .reset) catch {};
const debug_info = std.debug.getSelfDebugInfo() catch |err| {
try w.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)});
@@ -1727,9 +1727,9 @@ fn dumpBadGetPathHelp(
return;
};
if (asking_step) |as| {
- tty_config.setColor(w, .Red) catch {};
+ tty_config.setColor(w, .red) catch {};
try stderr.writeAll(" The step that is missing a dependency on the above step was created by this stack trace:\n");
- tty_config.setColor(w, .Reset) catch {};
+ tty_config.setColor(w, .reset) catch {};
std.debug.writeStackTrace(as.getStackTrace(), w, ally, debug_info, tty_config) catch |err| {
try stderr.writer().print("Unable to dump stack trace: {s}\n", .{@errorName(err)});
@@ -1737,9 +1737,9 @@ fn dumpBadGetPathHelp(
};
}
- tty_config.setColor(w, .Red) catch {};
+ tty_config.setColor(w, .red) catch {};
try stderr.writeAll(" Hope that helps. Proceeding to panic.\n");
- tty_config.setColor(w, .Reset) catch {};
+ tty_config.setColor(w, .reset) catch {};
}
/// Allocates a new string for assigning a value to a named macro.
lib/std/debug.zig
@@ -421,9 +421,9 @@ pub fn writeStackTrace(
if (stack_trace.index > stack_trace.instruction_addresses.len) {
const dropped_frames = stack_trace.index - stack_trace.instruction_addresses.len;
- tty_config.setColor(out_stream, .Bold) catch {};
+ tty_config.setColor(out_stream, .bold) catch {};
try out_stream.print("({d} additional stack frames skipped...)\n", .{dropped_frames});
- tty_config.setColor(out_stream, .Reset) catch {};
+ tty_config.setColor(out_stream, .reset) catch {};
}
}
@@ -655,14 +655,14 @@ pub fn writeCurrentStackTraceWindows(
/// for debugging purposes, such as coloring text, etc.
pub const TTY = struct {
pub const Color = enum {
- Red,
- Green,
- Yellow,
- Cyan,
- White,
- Dim,
- Bold,
- Reset,
+ red,
+ green,
+ yellow,
+ cyan,
+ white,
+ dim,
+ bold,
+ reset,
};
pub const Config = union(enum) {
@@ -680,26 +680,26 @@ pub const TTY = struct {
.no_color => return,
.escape_codes => {
const color_string = switch (color) {
- .Red => "\x1b[31;1m",
- .Green => "\x1b[32;1m",
- .Yellow => "\x1b[33;1m",
- .Cyan => "\x1b[36;1m",
- .White => "\x1b[37;1m",
- .Bold => "\x1b[1m",
- .Dim => "\x1b[2m",
- .Reset => "\x1b[0m",
+ .red => "\x1b[31;1m",
+ .green => "\x1b[32;1m",
+ .yellow => "\x1b[33;1m",
+ .cyan => "\x1b[36;1m",
+ .white => "\x1b[37;1m",
+ .bold => "\x1b[1m",
+ .dim => "\x1b[2m",
+ .reset => "\x1b[0m",
};
try out_stream.writeAll(color_string);
},
.windows_api => |ctx| if (native_os == .windows) {
const attributes = switch (color) {
- .Red => windows.FOREGROUND_RED | windows.FOREGROUND_INTENSITY,
- .Green => windows.FOREGROUND_GREEN | windows.FOREGROUND_INTENSITY,
- .Yellow => windows.FOREGROUND_RED | windows.FOREGROUND_GREEN | windows.FOREGROUND_INTENSITY,
- .Cyan => windows.FOREGROUND_GREEN | windows.FOREGROUND_BLUE | windows.FOREGROUND_INTENSITY,
- .White, .Bold => windows.FOREGROUND_RED | windows.FOREGROUND_GREEN | windows.FOREGROUND_BLUE | windows.FOREGROUND_INTENSITY,
- .Dim => windows.FOREGROUND_INTENSITY,
- .Reset => ctx.reset_attributes,
+ .red => windows.FOREGROUND_RED | windows.FOREGROUND_INTENSITY,
+ .green => windows.FOREGROUND_GREEN | windows.FOREGROUND_INTENSITY,
+ .yellow => windows.FOREGROUND_RED | windows.FOREGROUND_GREEN | windows.FOREGROUND_INTENSITY,
+ .cyan => windows.FOREGROUND_GREEN | windows.FOREGROUND_BLUE | windows.FOREGROUND_INTENSITY,
+ .white, .bold => windows.FOREGROUND_RED | windows.FOREGROUND_GREEN | windows.FOREGROUND_BLUE | windows.FOREGROUND_INTENSITY,
+ .dim => windows.FOREGROUND_INTENSITY,
+ .reset => ctx.reset_attributes,
};
try windows.SetConsoleTextAttribute(ctx.handle, attributes);
} else {
@@ -831,7 +831,7 @@ fn printLineInfo(
comptime printLineFromFile: anytype,
) !void {
nosuspend {
- try tty_config.setColor(out_stream, .Bold);
+ try tty_config.setColor(out_stream, .bold);
if (line_info) |*li| {
try out_stream.print("{s}:{d}:{d}", .{ li.file_name, li.line, li.column });
@@ -839,11 +839,11 @@ fn printLineInfo(
try out_stream.writeAll("???:?:?");
}
- try tty_config.setColor(out_stream, .Reset);
+ try tty_config.setColor(out_stream, .reset);
try out_stream.writeAll(": ");
- try tty_config.setColor(out_stream, .Dim);
+ try tty_config.setColor(out_stream, .dim);
try out_stream.print("0x{x} in {s} ({s})", .{ address, symbol_name, compile_unit_name });
- try tty_config.setColor(out_stream, .Reset);
+ try tty_config.setColor(out_stream, .reset);
try out_stream.writeAll("\n");
// Show the matching source code line if possible
@@ -854,9 +854,9 @@ fn printLineInfo(
const space_needed = @intCast(usize, li.column - 1);
try out_stream.writeByteNTimes(' ', space_needed);
- try tty_config.setColor(out_stream, .Green);
+ try tty_config.setColor(out_stream, .green);
try out_stream.writeAll("^");
- try tty_config.setColor(out_stream, .Reset);
+ try tty_config.setColor(out_stream, .reset);
}
try out_stream.writeAll("\n");
} else |err| switch (err) {
lib/std/testing.zig
@@ -387,9 +387,9 @@ fn SliceDiffer(comptime T: type) type {
for (self.expected, 0..) |value, i| {
var full_index = self.start_index + i;
const diff = if (i < self.actual.len) !std.meta.eql(self.actual[i], value) else true;
- if (diff) try self.ttyconf.setColor(writer, .Red);
+ if (diff) try self.ttyconf.setColor(writer, .red);
try writer.print("[{}]: {any}\n", .{ full_index, value });
- if (diff) try self.ttyconf.setColor(writer, .Reset);
+ if (diff) try self.ttyconf.setColor(writer, .reset);
}
}
};
@@ -427,9 +427,9 @@ const BytesDiffer = struct {
}
fn writeByteDiff(self: BytesDiffer, writer: anytype, comptime fmt: []const u8, byte: u8, diff: bool) !void {
- if (diff) try self.ttyconf.setColor(writer, .Red);
+ if (diff) try self.ttyconf.setColor(writer, .red);
try writer.print(fmt, .{byte});
- if (diff) try self.ttyconf.setColor(writer, .Reset);
+ if (diff) try self.ttyconf.setColor(writer, .reset);
}
const ChunkIterator = struct {
lib/build_runner.zig
@@ -476,9 +476,9 @@ fn runStepNames(
if (run.enable_summary != false) {
const total_count = success_count + failure_count + pending_count + skipped_count;
- ttyconf.setColor(stderr, .Cyan) catch {};
+ ttyconf.setColor(stderr, .cyan) catch {};
stderr.writeAll("Build Summary:") catch {};
- ttyconf.setColor(stderr, .Reset) catch {};
+ ttyconf.setColor(stderr, .reset) catch {};
stderr.writer().print(" {d}/{d} steps succeeded", .{ success_count, total_count }) catch {};
if (skipped_count > 0) stderr.writer().print("; {d} skipped", .{skipped_count}) catch {};
if (failure_count > 0) stderr.writer().print("; {d} failed", .{failure_count}) catch {};
@@ -489,9 +489,9 @@ fn runStepNames(
if (test_leak_count > 0) stderr.writer().print("; {d} leaked", .{test_leak_count}) catch {};
if (run.enable_summary == null) {
- ttyconf.setColor(stderr, .Dim) catch {};
+ ttyconf.setColor(stderr, .dim) catch {};
stderr.writeAll(" (disable with -fno-summary)") catch {};
- ttyconf.setColor(stderr, .Reset) catch {};
+ ttyconf.setColor(stderr, .reset) catch {};
}
stderr.writeAll("\n") catch {};
@@ -560,7 +560,7 @@ fn printTreeStep(
const first = step_stack.swapRemove(s);
try printPrefix(parent_node, stderr, ttyconf);
- if (!first) try ttyconf.setColor(stderr, .Dim);
+ if (!first) try ttyconf.setColor(stderr, .dim);
if (parent_node.parent != null) {
if (parent_node.last) {
try stderr.writeAll(switch (ttyconf) {
@@ -586,28 +586,28 @@ fn printTreeStep(
.running => unreachable,
.dependency_failure => {
- try ttyconf.setColor(stderr, .Dim);
+ try ttyconf.setColor(stderr, .dim);
try stderr.writeAll(" transitive failure\n");
- try ttyconf.setColor(stderr, .Reset);
+ try ttyconf.setColor(stderr, .reset);
},
.success => {
- try ttyconf.setColor(stderr, .Green);
+ try ttyconf.setColor(stderr, .green);
if (s.result_cached) {
try stderr.writeAll(" cached");
} else if (s.test_results.test_count > 0) {
const pass_count = s.test_results.passCount();
try stderr.writer().print(" {d} passed", .{pass_count});
if (s.test_results.skip_count > 0) {
- try ttyconf.setColor(stderr, .Yellow);
+ try ttyconf.setColor(stderr, .yellow);
try stderr.writer().print(" {d} skipped", .{s.test_results.skip_count});
}
} else {
try stderr.writeAll(" success");
}
- try ttyconf.setColor(stderr, .Reset);
+ try ttyconf.setColor(stderr, .reset);
if (s.result_duration_ns) |ns| {
- try ttyconf.setColor(stderr, .Dim);
+ try ttyconf.setColor(stderr, .dim);
if (ns >= std.time.ns_per_min) {
try stderr.writer().print(" {d}m", .{ns / std.time.ns_per_min});
} else if (ns >= std.time.ns_per_s) {
@@ -619,11 +619,11 @@ fn printTreeStep(
} else {
try stderr.writer().print(" {d}ns", .{ns});
}
- try ttyconf.setColor(stderr, .Reset);
+ try ttyconf.setColor(stderr, .reset);
}
if (s.result_peak_rss != 0) {
const rss = s.result_peak_rss;
- try ttyconf.setColor(stderr, .Dim);
+ try ttyconf.setColor(stderr, .dim);
if (rss >= 1000_000_000) {
try stderr.writer().print(" MaxRSS:{d}G", .{rss / 1000_000_000});
} else if (rss >= 1000_000) {
@@ -633,57 +633,57 @@ fn printTreeStep(
} else {
try stderr.writer().print(" MaxRSS:{d}B", .{rss});
}
- try ttyconf.setColor(stderr, .Reset);
+ try ttyconf.setColor(stderr, .reset);
}
try stderr.writeAll("\n");
},
.skipped => {
- try ttyconf.setColor(stderr, .Yellow);
+ try ttyconf.setColor(stderr, .yellow);
try stderr.writeAll(" skipped\n");
- try ttyconf.setColor(stderr, .Reset);
+ try ttyconf.setColor(stderr, .reset);
},
.failure => {
if (s.result_error_bundle.errorMessageCount() > 0) {
- try ttyconf.setColor(stderr, .Red);
+ try ttyconf.setColor(stderr, .red);
try stderr.writer().print(" {d} errors\n", .{
s.result_error_bundle.errorMessageCount(),
});
- try ttyconf.setColor(stderr, .Reset);
+ try ttyconf.setColor(stderr, .reset);
} else if (!s.test_results.isSuccess()) {
try stderr.writer().print(" {d}/{d} passed", .{
s.test_results.passCount(), s.test_results.test_count,
});
if (s.test_results.fail_count > 0) {
try stderr.writeAll(", ");
- try ttyconf.setColor(stderr, .Red);
+ try ttyconf.setColor(stderr, .red);
try stderr.writer().print("{d} failed", .{
s.test_results.fail_count,
});
- try ttyconf.setColor(stderr, .Reset);
+ try ttyconf.setColor(stderr, .reset);
}
if (s.test_results.skip_count > 0) {
try stderr.writeAll(", ");
- try ttyconf.setColor(stderr, .Yellow);
+ try ttyconf.setColor(stderr, .yellow);
try stderr.writer().print("{d} skipped", .{
s.test_results.skip_count,
});
- try ttyconf.setColor(stderr, .Reset);
+ try ttyconf.setColor(stderr, .reset);
}
if (s.test_results.leak_count > 0) {
try stderr.writeAll(", ");
- try ttyconf.setColor(stderr, .Red);
+ try ttyconf.setColor(stderr, .red);
try stderr.writer().print("{d} leaked", .{
s.test_results.leak_count,
});
- try ttyconf.setColor(stderr, .Reset);
+ try ttyconf.setColor(stderr, .reset);
}
try stderr.writeAll("\n");
} else {
- try ttyconf.setColor(stderr, .Red);
+ try ttyconf.setColor(stderr, .red);
try stderr.writeAll(" failure\n");
- try ttyconf.setColor(stderr, .Reset);
+ try ttyconf.setColor(stderr, .reset);
}
},
}
@@ -703,7 +703,7 @@ fn printTreeStep(
s.dependencies.items.len,
});
}
- try ttyconf.setColor(stderr, .Reset);
+ try ttyconf.setColor(stderr, .reset);
}
}
@@ -819,13 +819,13 @@ fn workerMakeOneStep(
for (s.result_error_msgs.items) |msg| {
// Sometimes it feels like you just can't catch a break. Finally,
// with Zig, you can.
- ttyconf.setColor(stderr, .Bold) catch break;
+ ttyconf.setColor(stderr, .bold) catch break;
stderr.writeAll(s.owner.dep_prefix) catch break;
stderr.writeAll(s.name) catch break;
stderr.writeAll(": ") catch break;
- ttyconf.setColor(stderr, .Red) catch break;
+ ttyconf.setColor(stderr, .red) catch break;
stderr.writeAll("error: ") catch break;
- ttyconf.setColor(stderr, .Reset) catch break;
+ ttyconf.setColor(stderr, .reset) catch break;
stderr.writeAll(msg) catch break;
stderr.writeAll("\n") catch break;
}