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 fe83aa3fc3..1cb73eb52a 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 ae08d6be77..785a94f502 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 21d313b68c..64d750324e 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 f7c8d9a679..28ac21334d 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 6245be03ca..a5d5434a72 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 \