checkCompileErrors
Function parameters
Parameters
- compile:*Compile
Type definitions in this namespace
Types
Functions in this namespace
Functions
- installHeader
- Marks the specified header for installation alongside this artifact.
- installHeadersDirectory
- Marks headers from the specified directory for installation alongside this artifact.
- installConfigHeader
- Marks the specified config header for installation alongside this artifact.
- installLibraryHeaders
- Forwards all headers marked for installation from `lib` to this artifact.
- dependsOnSystemLibrary
- Returns whether the library, executable, or object depends on a particular system library.
- linkLibC
- Deprecated; use `compile.root_module.link_libc = true` instead.
- linkLibCpp
- Deprecated; use `compile.root_module.link_libcpp = true` instead.
- linkSystemLibrary
- Deprecated; use `compile.root_module.linkSystemLibrary(name, .{})` instead.
- linkSystemLibrary2
- Deprecated; use `compile.root_module.linkSystemLibrary(name, options)` instead.
- linkFramework
- Deprecated; use `c.root_module.linkFramework(name, .{})` instead.
- addCSourceFiles
- Deprecated; use `compile.root_module.addCSourceFiles(options)` instead.
- addCSourceFile
- Deprecated; use `compile.root_module.addCSourceFile(source)` instead.
- addWin32ResourceFile
- Deprecated; use `compile.root_module.addWin32ResourceFile(source)` instead.
- getEmittedBinDirectory
- Returns the path to the directory that contains the emitted binary file.
- getEmittedBin
- Returns the path to the generated executable, library or object file.
- getEmittedImplib
- Returns the path to the generated import library.
- getEmittedH
- Returns the path to the generated header file.
- getEmittedPdb
- Returns the generated PDB file.
- getEmittedDocs
- Returns the path to the generated documentation directory.
- getEmittedAsm
- Returns the path to the generated assembly code.
- getEmittedLlvmIr
- Returns the path to the generated LLVM IR.
- getEmittedLlvmBc
- Returns the path to the generated LLVM BC.
- addAssemblyFile
- Deprecated; use `compile.root_module.addAssemblyFile(source)` instead.
- addObjectFile
- Deprecated; use `compile.root_module.addObjectFile(source)` instead.
- addObject
- Deprecated; use `compile.root_module.addObject(object)` instead.
- linkLibrary
- Deprecated; use `compile.root_module.linkLibrary(library)` instead.
- addAfterIncludePath
- Deprecated; use `compile.root_module.addAfterIncludePath(lazy_path)` instead.
- addSystemIncludePath
- Deprecated; use `compile.root_module.addSystemIncludePath(lazy_path)` instead.
- addIncludePath
- Deprecated; use `compile.root_module.addIncludePath(lazy_path)` instead.
- addConfigHeader
- Deprecated; use `compile.root_module.addConfigHeader(config_header)` instead.
- addEmbedPath
- Deprecated; use `compile.root_module.addEmbedPath(lazy_path)` instead.
- addLibraryPath
- Deprecated; use `compile.root_module.addLibraryPath(directory_path)` instead.
- addRPath
- Deprecated; use `compile.root_module.addRPath(directory_path)` instead.
- addSystemFrameworkPath
- Deprecated; use `compile.root_module.addSystemFrameworkPath(directory_path)` instead.
- addFrameworkPath
- Deprecated; use `compile.root_module.addFrameworkPath(directory_path)` instead.
- getCompileDependencies
- Return the full set of `Step.Compile` which `start` depends on, recursively.
= .compile
Values
- base_id
- = .compile
Source
Implementation
fn checkCompileErrors(compile: *Compile) !void {
// Clear this field so that it does not get printed by the build runner.
const actual_eb = compile.step.result_error_bundle;
compile.step.result_error_bundle = .empty;
const arena = compile.step.owner.allocator;
const actual_errors = ae: {
var aw: std.io.Writer.Allocating = .init(arena);
defer aw.deinit();
try actual_eb.renderToWriter(.{
.ttyconf = .no_color,
.include_reference_trace = false,
.include_source_line = false,
}, &aw.writer);
break :ae try aw.toOwnedSlice();
};
// Render the expected lines into a string that we can compare verbatim.
var expected_generated: std.ArrayListUnmanaged(u8) = .empty;
const expect_errors = compile.expect_errors.?;
var actual_line_it = mem.splitScalar(u8, actual_errors, '\n');
// TODO merge this with the testing.expectEqualStrings logic, and also CheckFile
switch (expect_errors) {
.starts_with => |expect_starts_with| {
if (std.mem.startsWith(u8, actual_errors, expect_starts_with)) return;
return compile.step.fail(
\\
\\========= should start with: ============
\\{s}
\\========= but not found: ================
\\{s}
\\=========================================
, .{ expect_starts_with, actual_errors });
},
.contains => |expect_line| {
while (actual_line_it.next()) |actual_line| {
if (!matchCompileError(actual_line, expect_line)) continue;
return;
}
return compile.step.fail(
\\
\\========= should contain: ===============
\\{s}
\\========= but not found: ================
\\{s}
\\=========================================
, .{ expect_line, actual_errors });
},
.stderr_contains => |expect_line| {
const actual_stderr: []const u8 = if (compile.step.result_error_msgs.items.len > 0)
compile.step.result_error_msgs.items[0]
else
&.{};
compile.step.result_error_msgs.clearRetainingCapacity();
var stderr_line_it = mem.splitScalar(u8, actual_stderr, '\n');
while (stderr_line_it.next()) |actual_line| {
if (!matchCompileError(actual_line, expect_line)) continue;
return;
}
return compile.step.fail(
\\
\\========= should contain: ===============
\\{s}
\\========= but not found: ================
\\{s}
\\=========================================
, .{ expect_line, actual_stderr });
},
.exact => |expect_lines| {
for (expect_lines) |expect_line| {
const actual_line = actual_line_it.next() orelse {
try expected_generated.appendSlice(arena, expect_line);
try expected_generated.append(arena, '\n');
continue;
};
if (matchCompileError(actual_line, expect_line)) {
try expected_generated.appendSlice(arena, actual_line);
try expected_generated.append(arena, '\n');
continue;
}
try expected_generated.appendSlice(arena, expect_line);
try expected_generated.append(arena, '\n');
}
if (mem.eql(u8, expected_generated.items, actual_errors)) return;
return compile.step.fail(
\\
\\========= expected: =====================
\\{s}
\\========= but found: ====================
\\{s}
\\=========================================
, .{ expected_generated.items, actual_errors });
},
}
}