From cb1d1bdf59f2979de9c534c21813d824f9736cfb Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 16 Jun 2024 19:31:59 -0700 Subject: [PATCH] make `zig build test` check for conforming formatting There was already `zig build test-fmt` but now `zig build test` depends on that one. The CI scripts no longer need explicit logic since they already do `zig build test`. --- build.zig | 10 +++++----- ci/aarch64-linux-debug.sh | 7 ------- ci/aarch64-linux-release.sh | 7 ------- ci/x86_64-linux-debug.sh | 7 ------- ci/x86_64-linux-release.sh | 8 -------- 5 files changed, 5 insertions(+), 34 deletions(-) diff --git a/build.zig b/build.zig index fe83aa3fc3080b7d7f2e6772e6c7325dc6505b42..1cb73eb52a18acea27298c13dadaed4b0268f454 100644 --- a/build.zig +++ b/build.zig @@ -428,18 +428,21 @@ pub fn build(b: *std.Build) !void { } const optimization_modes = chosen_opt_modes_buf[0..chosen_mode_index]; - const fmt_include_paths = &.{ "doc", "lib", "src", "test", "tools", "build.zig" }; + const fmt_include_paths = &.{ "lib", "src", "test", "tools", "build.zig", "build.zig.zon" }; const fmt_exclude_paths = &.{"test/cases"}; const do_fmt = b.addFmt(.{ .paths = fmt_include_paths, .exclude_paths = fmt_exclude_paths, }); + b.step("fmt", "Modify source files in place to have conforming formatting").dependOn(&do_fmt.step); - b.step("test-fmt", "Check source files having conforming formatting").dependOn(&b.addFmt(.{ + const check_fmt = b.step("test-fmt", "Check source files having conforming formatting"); + check_fmt.dependOn(&b.addFmt(.{ .paths = fmt_include_paths, .exclude_paths = fmt_exclude_paths, .check = true, }).step); + test_step.dependOn(check_fmt); const test_cases_step = b.step("test-cases", "Run the main compiler test cases"); try tests.addCases(b, test_cases_step, test_filters, check_case_exe, target, .{ @@ -534,9 +537,6 @@ pub fn build(b: *std.Build) !void { try addWasiUpdateStep(b, version); - b.step("fmt", "Modify source files in place to have conforming formatting") - .dependOn(&do_fmt.step); - const update_mingw_step = b.step("update-mingw", "Update zig's bundled mingw"); const opt_mingw_src_path = b.option([]const u8, "mingw-src", "path to mingw-w64 source directory"); const update_mingw_exe = b.addExecutable(.{ diff --git a/ci/aarch64-linux-debug.sh b/ci/aarch64-linux-debug.sh index ae08d6be7781852a3dc7a4ce79bc30f05319c2b9..785a94f502d5fa8ff8471ada97d10d2424dc12be 100644 --- a/ci/aarch64-linux-debug.sh +++ b/ci/aarch64-linux-debug.sh @@ -49,13 +49,6 @@ unset CXX ninja install -# TODO: move this to a build.zig step (check-fmt) -echo "Looking for non-conforming code formatting..." -stage3-debug/bin/zig fmt --check .. \ - --exclude ../test/cases/ \ - --exclude ../doc/ \ - --exclude ../build-debug - # simultaneously test building self-hosted without LLVM and with 32-bit arm stage3-debug/bin/zig build \ -Dtarget=arm-linux-musleabihf \ diff --git a/ci/aarch64-linux-release.sh b/ci/aarch64-linux-release.sh index 21d313b68c462670ef7288b210c70cad56d1aad3..64d750324ee0d249244f250f1c9fd8ca2703039f 100644 --- a/ci/aarch64-linux-release.sh +++ b/ci/aarch64-linux-release.sh @@ -49,13 +49,6 @@ unset CXX ninja install -# TODO: move this to a build.zig step (check-fmt) -echo "Looking for non-conforming code formatting..." -stage3-release/bin/zig fmt --check .. \ - --exclude ../test/cases/ \ - --exclude ../doc/ \ - --exclude ../build-release - # simultaneously test building self-hosted without LLVM and with 32-bit arm stage3-release/bin/zig build \ -Dtarget=arm-linux-musleabihf \ diff --git a/ci/x86_64-linux-debug.sh b/ci/x86_64-linux-debug.sh index f7c8d9a6790765ea2d79c2330be01bd2ab8551a6..28ac21334d017850923153fa1ebf0b639d00ca79 100755 --- a/ci/x86_64-linux-debug.sh +++ b/ci/x86_64-linux-debug.sh @@ -57,13 +57,6 @@ unset CXX ninja install -# TODO: move this to a build.zig step (check-fmt) -echo "Looking for non-conforming code formatting..." -stage3-debug/bin/zig fmt --check .. \ - --exclude ../test/cases/ \ - --exclude ../doc/ \ - --exclude ../build-debug - # simultaneously test building self-hosted without LLVM and with 32-bit arm stage3-debug/bin/zig build \ -Dtarget=arm-linux-musleabihf \ diff --git a/ci/x86_64-linux-release.sh b/ci/x86_64-linux-release.sh index 6245be03ca52d7748e92cafbd7dfc582c015f072..a5d5434a7251afbcd83868f204897ad2673ae6a7 100755 --- a/ci/x86_64-linux-release.sh +++ b/ci/x86_64-linux-release.sh @@ -57,14 +57,6 @@ unset CXX ninja install -# TODO: move this to a build.zig step (check-fmt) -echo "Looking for non-conforming code formatting..." -stage3-release/bin/zig fmt --check .. \ - --exclude ../test/cases/ \ - --exclude ../doc/ \ - --exclude ../build-debug \ - --exclude ../build-release - # simultaneously test building self-hosted without LLVM and with 32-bit arm stage3-release/bin/zig build \ -Dtarget=arm-linux-musleabihf \ -- 2.54.0