fix test-gen-h and test-compile-errors regression
This commit is contained in:
parent
157b8e6889
commit
242f5d10d5
@ -242,6 +242,20 @@ pub const Builder = struct {
|
|||||||
return LibExeObjStep.createObject(self, name, root_src_param);
|
return LibExeObjStep.createObject(self, name, root_src_param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn addObjectFromWriteFileStep(
|
||||||
|
self: *Builder,
|
||||||
|
name: []const u8,
|
||||||
|
wfs: *WriteFileStep,
|
||||||
|
basename: []const u8,
|
||||||
|
) *LibExeObjStep {
|
||||||
|
return LibExeObjStep.createObject(self, name, @as(FileSource, .{
|
||||||
|
.write_file = .{
|
||||||
|
.step = wfs,
|
||||||
|
.basename = basename,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
pub fn addSharedLibrary(self: *Builder, name: []const u8, root_src: ?[]const u8, ver: Version) *LibExeObjStep {
|
pub fn addSharedLibrary(self: *Builder, name: []const u8, root_src: ?[]const u8, ver: Version) *LibExeObjStep {
|
||||||
const root_src_param = if (root_src) |p| @as(FileSource, .{ .path = p }) else null;
|
const root_src_param = if (root_src) |p| @as(FileSource, .{ .path = p }) else null;
|
||||||
return LibExeObjStep.createSharedLibrary(self, name, root_src_param, ver);
|
return LibExeObjStep.createSharedLibrary(self, name, root_src_param, ver);
|
||||||
|
@ -737,6 +737,7 @@ pub const CompileErrorContext = struct {
|
|||||||
test_index: usize,
|
test_index: usize,
|
||||||
case: *const TestCase,
|
case: *const TestCase,
|
||||||
build_mode: Mode,
|
build_mode: Mode,
|
||||||
|
write_src: *build.WriteFileStep,
|
||||||
|
|
||||||
const ErrLineIter = struct {
|
const ErrLineIter = struct {
|
||||||
lines: mem.SplitIterator,
|
lines: mem.SplitIterator,
|
||||||
@ -756,7 +757,13 @@ pub const CompileErrorContext = struct {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn create(context: *CompileErrorContext, name: []const u8, case: *const TestCase, build_mode: Mode) *CompileCmpOutputStep {
|
pub fn create(
|
||||||
|
context: *CompileErrorContext,
|
||||||
|
name: []const u8,
|
||||||
|
case: *const TestCase,
|
||||||
|
build_mode: Mode,
|
||||||
|
write_src: *build.WriteFileStep,
|
||||||
|
) *CompileCmpOutputStep {
|
||||||
const allocator = context.b.allocator;
|
const allocator = context.b.allocator;
|
||||||
const ptr = allocator.create(CompileCmpOutputStep) catch unreachable;
|
const ptr = allocator.create(CompileCmpOutputStep) catch unreachable;
|
||||||
ptr.* = CompileCmpOutputStep{
|
ptr.* = CompileCmpOutputStep{
|
||||||
@ -766,6 +773,7 @@ pub const CompileErrorContext = struct {
|
|||||||
.test_index = context.test_index,
|
.test_index = context.test_index,
|
||||||
.case = case,
|
.case = case,
|
||||||
.build_mode = build_mode,
|
.build_mode = build_mode,
|
||||||
|
.write_src = write_src,
|
||||||
};
|
};
|
||||||
|
|
||||||
context.test_index += 1;
|
context.test_index += 1;
|
||||||
@ -776,11 +784,6 @@ pub const CompileErrorContext = struct {
|
|||||||
const self = @fieldParentPtr(CompileCmpOutputStep, "step", step);
|
const self = @fieldParentPtr(CompileCmpOutputStep, "step", step);
|
||||||
const b = self.context.b;
|
const b = self.context.b;
|
||||||
|
|
||||||
const root_src = fs.path.join(
|
|
||||||
b.allocator,
|
|
||||||
&[_][]const u8{ b.cache_root, self.case.sources.items[0].filename },
|
|
||||||
) catch unreachable;
|
|
||||||
|
|
||||||
var zig_args = ArrayList([]const u8).init(b.allocator);
|
var zig_args = ArrayList([]const u8).init(b.allocator);
|
||||||
zig_args.append(b.zig_exe) catch unreachable;
|
zig_args.append(b.zig_exe) catch unreachable;
|
||||||
|
|
||||||
@ -791,7 +794,8 @@ pub const CompileErrorContext = struct {
|
|||||||
} else {
|
} else {
|
||||||
try zig_args.append("build-obj");
|
try zig_args.append("build-obj");
|
||||||
}
|
}
|
||||||
zig_args.append(b.pathFromRoot(root_src)) catch unreachable;
|
const root_src_basename = self.case.sources.toSliceConst()[0].filename;
|
||||||
|
try zig_args.append(self.write_src.getOutputPath(root_src_basename));
|
||||||
|
|
||||||
zig_args.append("--name") catch unreachable;
|
zig_args.append("--name") catch unreachable;
|
||||||
zig_args.append("test") catch unreachable;
|
zig_args.append("test") catch unreachable;
|
||||||
@ -990,18 +994,14 @@ pub const CompileErrorContext = struct {
|
|||||||
if (self.test_filter) |filter| {
|
if (self.test_filter) |filter| {
|
||||||
if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
|
if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
|
||||||
}
|
}
|
||||||
|
const write_src = b.addWriteFiles();
|
||||||
const compile_and_cmp_errors = CompileCmpOutputStep.create(self, annotated_case_name, case, .Debug);
|
|
||||||
self.step.dependOn(&compile_and_cmp_errors.step);
|
|
||||||
|
|
||||||
for (case.sources.toSliceConst()) |src_file| {
|
for (case.sources.toSliceConst()) |src_file| {
|
||||||
const expanded_src_path = fs.path.join(
|
write_src.add(src_file.filename, src_file.source);
|
||||||
b.allocator,
|
|
||||||
&[_][]const u8{ b.cache_root, src_file.filename },
|
|
||||||
) catch unreachable;
|
|
||||||
const write_src = b.addWriteFile(expanded_src_path, src_file.source);
|
|
||||||
compile_and_cmp_errors.step.dependOn(&write_src.step);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const compile_and_cmp_errors = CompileCmpOutputStep.create(self, annotated_case_name, case, .Debug, write_src);
|
||||||
|
compile_and_cmp_errors.step.dependOn(&write_src.step);
|
||||||
|
self.step.dependOn(&compile_and_cmp_errors.step);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1195,10 +1195,6 @@ pub const GenHContext = struct {
|
|||||||
|
|
||||||
pub fn addCase(self: *GenHContext, case: *const TestCase) void {
|
pub fn addCase(self: *GenHContext, case: *const TestCase) void {
|
||||||
const b = self.b;
|
const b = self.b;
|
||||||
const root_src = fs.path.join(
|
|
||||||
b.allocator,
|
|
||||||
&[_][]const u8{ b.cache_root, case.sources.items[0].filename },
|
|
||||||
) catch unreachable;
|
|
||||||
|
|
||||||
const mode = builtin.Mode.Debug;
|
const mode = builtin.Mode.Debug;
|
||||||
const annotated_case_name = fmt.allocPrint(self.b.allocator, "gen-h {} ({})", .{ case.name, @tagName(mode) }) catch unreachable;
|
const annotated_case_name = fmt.allocPrint(self.b.allocator, "gen-h {} ({})", .{ case.name, @tagName(mode) }) catch unreachable;
|
||||||
@ -1206,18 +1202,14 @@ pub const GenHContext = struct {
|
|||||||
if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
|
if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const obj = b.addObject("test", root_src);
|
const write_src = b.addWriteFiles();
|
||||||
obj.setBuildMode(mode);
|
|
||||||
|
|
||||||
for (case.sources.toSliceConst()) |src_file| {
|
for (case.sources.toSliceConst()) |src_file| {
|
||||||
const expanded_src_path = fs.path.join(
|
write_src.add(src_file.filename, src_file.source);
|
||||||
b.allocator,
|
|
||||||
&[_][]const u8{ b.cache_root, src_file.filename },
|
|
||||||
) catch unreachable;
|
|
||||||
const write_src = b.addWriteFile(expanded_src_path, src_file.source);
|
|
||||||
obj.step.dependOn(&write_src.step);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const obj = b.addObjectFromWriteFileStep("test", write_src, case.sources.items[0].filename);
|
||||||
|
obj.setBuildMode(mode);
|
||||||
|
|
||||||
const cmp_h = GenHCmpOutputStep.create(self, obj, annotated_case_name, case);
|
const cmp_h = GenHCmpOutputStep.create(self, obj, annotated_case_name, case);
|
||||||
|
|
||||||
self.step.dependOn(&cmp_h.step);
|
self.step.dependOn(&cmp_h.step);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user