Revert "reduce build error noise"

This reverts commit baead472d7.

Let's go through the proposal process on this one. I want to push back
on this. My position is that, at the very least, a full trace of command
lines of sub-processes should be printed on failure, with the exception
of opt-in flags such as `--prominent-compile-errors`.
This commit is contained in:
Andrew Kelley 2022-02-17 14:28:19 -07:00
parent 6235afc632
commit 5aa35f62c3
5 changed files with 1 additions and 58 deletions

View File

@ -3438,17 +3438,3 @@ test "LibExeObjStep.addPackage" {
const dupe = exe.packages.items[0];
try std.testing.expectEqualStrings(pkg_top.name, dupe.name);
}
/// This exit code from either "zig build" or the build_runner indicates
/// the "full reason" for a build failure has already been reported to stderr.
/// This will prevent 'zig` from piling on errors to the ones reported by the
/// build_runner.
pub const fail_fully_reported_exit_code = 0x3f;
/// Print an error message to stderr and exit with a special exit
/// code that notifies the invoking process that the build error
/// has already been fully reported to stderr.
pub fn fatalFullReport(comptime error_fmt: []const u8, args: anytype) noreturn {
std.log.err(error_fmt, args);
std.os.exit(fail_fully_reported_exit_code);
}

View File

@ -3616,9 +3616,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
.Exited => |code| {
if (code == 0) return cleanExit();
if (code == std.build.fail_fully_reported_exit_code) {
process.exit(std.build.fail_fully_reported_exit_code);
} else if (prominent_compile_errors) {
if (prominent_compile_errors) {
fatal("the build command failed with exit code {d}", .{code});
} else {
const cmd = try std.mem.join(arena, " ", child_argv);

View File

@ -49,7 +49,6 @@ pub fn addCases(cases: *tests.StandaloneContext) void {
cases.addBuildFile("test/standalone/issue_7030/build.zig", .{});
cases.addBuildFile("test/standalone/install_raw_hex/build.zig", .{});
cases.addBuildFile("test/standalone/issue_9812/build.zig", .{});
cases.addBuildFile("test/standalone/fail_full_report/build.zig", .{});
if (builtin.os.tag != .wasi) {
cases.addBuildFile("test/standalone/load_dynamic_library/build.zig", .{});
}

View File

@ -1,32 +0,0 @@
const std = @import("std");
const Builder = std.build.Builder;
pub fn build(b: *Builder) !void {
const test_step = b.step("test", "The test");
{
const run_step = b.addSystemCommand(&[_][]const u8{
b.zig_exe,
"build",
"--build-file",
"build2.zig",
});
run_step.stdout_action = .{ .expect_exact = "" };
test_step.dependOn(&run_step.step);
}
{
const run_step = b.addSystemCommand(&[_][]const u8{
b.zig_exe,
"build",
"--build-file",
"build2.zig",
"-Dbadoption",
});
run_step.stderr_action = .{ .expect_exact = "error: got a bad build option!\n" };
run_step.expected_exit_code = std.build.fail_fully_reported_exit_code;
test_step.dependOn(&run_step.step);
}
b.default_step.dependOn(test_step);
}

View File

@ -1,8 +0,0 @@
const std = @import("std");
const Builder = std.build.Builder;
pub fn build(b: *Builder) !void {
const bad_option = if (b.option(bool, "badoption", "Use this to emulator a bad build option")) |o| o else false;
if (bad_option)
std.build.fatalFullReport("got a bad build option!", .{});
}