add builder.addFmt API and use it to test stage1 zig fmt

closes #1968
master
Andrew Kelley 2019-02-26 18:10:40 -05:00
parent 6365f5a9f3
commit 4563f6b424
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
3 changed files with 14 additions and 0 deletions

View File

@ -448,6 +448,7 @@ set(ZIG_STD_FILES
"buf_set.zig"
"buffer.zig"
"build.zig"
"build/fmt.zig"
"c/darwin.zig"
"c/freebsd.zig"
"c/index.zig"

View File

@ -55,6 +55,8 @@ pub fn build(b: *Builder) !void {
var test_stage2 = b.addTest("src-self-hosted/test.zig");
test_stage2.setBuildMode(builtin.Mode.Debug);
const fmt_build_zig = b.addFmt([][]const u8{"build.zig"});
var exe = b.addExecutable("zig", "src-self-hosted/main.zig");
exe.setBuildMode(mode);
@ -106,6 +108,11 @@ pub fn build(b: *Builder) !void {
}
const modes = chosen_modes[0..chosen_mode_index];
// run stage1 `zig fmt` on this build.zig file just to make sure it works
test_step.dependOn(&fmt_build_zig.step);
const fmt_step = b.step("test-fmt", "Run zig fmt against build.zig to make sure it works");
fmt_step.dependOn(&fmt_build_zig.step);
test_step.dependOn(tests.addPkgTests(b, test_filter, "test/stage1/behavior.zig", "behavior", "Run the behavior tests", modes));
test_step.dependOn(tests.addPkgTests(b, test_filter, "std/index.zig", "std", "Run the standard library tests", modes));

View File

@ -15,6 +15,8 @@ const BufSet = std.BufSet;
const BufMap = std.BufMap;
const fmt_lib = std.fmt;
pub const FmtStep = @import("build/fmt.zig").FmtStep;
pub const Builder = struct {
uninstall_tls: TopLevelStep,
install_tls: TopLevelStep,
@ -205,6 +207,10 @@ pub const Builder = struct {
return remove_dir_step;
}
pub fn addFmt(self: *Builder, paths: []const []const u8) *FmtStep {
return FmtStep.create(self, paths);
}
pub fn version(self: *const Builder, major: u32, minor: u32, patch: u32) Version {
return Version{
.major = major,