treefmt-check
checks.x86_64-linux.self-formatting
· build #72
· raw
1bld1: building xvyaagf18yl7f5gqmmilmqak3rqqz3kj-treefmt-check.drv2treefmt v2.6.0traversed 412 files3emitted 148 files for processing4formatted 148 files (4 changed) in 447ms5 M checks/formatter-spec.sh6 M run-tests.sh7 M supported-programs.sh8diff --git a/checks/formatter-spec.sh b/checks/formatter-spec.sh9index f3e0cb1..b166dcf 10064410--- a/checks/formatter-spec.sh11+++ b/checks/formatter-spec.sh12@@ -15,54 +15,54 @@ fmt=("$@")13 14 spec=https://treefmt.com/latest/reference/formatter-spec15 fail() {16- echo "FAIL: $1 ($spec/#$2)" >&217- exit 118+ echo "FAIL: $1 ($spec/#$2)" >&219+ exit 120 }21 22 mkdir -p shallow deep/x/y decoy invalid23 24 for f in "$fixtures"/unformatted/*; do25- cp "$f" shallow/26- cp "$f" deep/x/y/27- cp "$f" decoy/28+ cp "$f" shallow/29+ cp "$f" deep/x/y/30+ cp "$f" decoy/31 done32 chmod -R u+w shallow deep decoy33 34 "${fmt[@]}" shallow/* deep/x/y/* ||35- fail "exited nonzero on valid input" 3-exit-nonzero-on-error36+ fail "exited nonzero on valid input" 3-exit-nonzero-on-error37 38 for f in "$fixtures"/unformatted/*; do39- name=$(basename "$f")40- cmp -s "$f" "shallow/$name" &&41- fail "$name was not modified" 2-write-to-changed-files42- cmp -s "$f" "decoy/$name" ||43- fail "$name was modified although not passed as argument" 1-files-passed-as-arguments44- diff -u "shallow/$name" "deep/x/y/$name" ||45- fail "$name formatted differently depending on its path; fine only if the formatter implements the stdin spec" 6-path-agnostic46+ name=$(basename "$f")47+ cmp -s "$f" "shallow/$name" &&48+ fail "$name was not modified" 2-write-to-changed-files49+ cmp -s "$f" "decoy/$name" ||50+ fail "$name was modified although not passed as argument" 1-files-passed-as-arguments51+ diff -u "shallow/$name" "deep/x/y/$name" ||52+ fail "$name formatted differently depending on its path; fine only if the formatter implements the stdin spec" 6-path-agnostic53 done54 55 cp -r shallow formatted56 touch -d @0 shallow/*57 "${fmt[@]}" shallow/* ||58- fail "exited nonzero on formatted input" 3-exit-nonzero-on-error59+ fail "exited nonzero on formatted input" 3-exit-nonzero-on-error60 diff -ru formatted shallow ||61- fail "second run changed the output" 4-idempotent62+ fail "second run changed the output" 4-idempotent63 for f in shallow/*; do64- [[ $(stat -c %Y "$f") == 0 ]] ||65- fail "$(basename "$f") was rewritten although unchanged" 2-write-to-changed-files66+ [[ $(stat -c %Y "$f") == 0 ]] ||67+ fail "$(basename "$f") was rewritten although unchanged" 2-write-to-changed-files68 done69 70 if [[ -d $fixtures/invalid ]]; then71- valid=(shallow/*)72- for f in "$fixtures"/invalid/*; do73- name=$(basename "$f")74- cp "$f" "invalid/$name"75- chmod u+w "invalid/$name"76- if "${fmt[@]}" "invalid/$name"; then77- fail "exited zero on invalid input $name" 3-exit-nonzero-on-error78- fi79- if "${fmt[@]}" "invalid/$name" "${valid[@]}"; then80- fail "exited zero on invalid input $name followed by valid files" 3-exit-nonzero-on-error81- fi82- done83+ valid=(shallow/*)84+ for f in "$fixtures"/invalid/*; do85+ name=$(basename "$f")86+ cp "$f" "invalid/$name"87+ chmod u+w "invalid/$name"88+ if "${fmt[@]}" "invalid/$name"; then89+ fail "exited zero on invalid input $name" 3-exit-nonzero-on-error90+ fi91+ if "${fmt[@]}" "invalid/$name" "${valid[@]}"; then92+ fail "exited zero on invalid input $name followed by valid files" 3-exit-nonzero-on-error93+ fi94+ done95 fi96diff --git a/run-tests.sh b/run-tests.sh97index 8d2ef9c..f94fb7a 10075598--- a/run-tests.sh99+++ b/run-tests.sh100@@ -8,11 +8,11 @@ nix flake check ./tests --recreate-lock-file --show-trace101 echo102 echo Checking that the flake.parts docs build...103 nix build github:hercules-ci/flake.parts-website --override-input treefmt-nix . --show-trace --log-lines 1000 || {104- echo105- echo "Looks like the docs aren't quite ok yet."106- echo "If there's a long stack trace, look for the keyword: option"107- echo "Ping flake-parts / module system maintainer @roberth if the error is unclear."108- # TODO After https://github.com/NixOS/nix/issues/7553 is resolved, review109- # --show-trace option and error elobaration.110- exit 1111+ echo112+ echo "Looks like the docs aren't quite ok yet."113+ echo "If there's a long stack trace, look for the keyword: option"114+ echo "Ping flake-parts / module system maintainer @roberth if the error is unclear."115+ # TODO After https://github.com/NixOS/nix/issues/7553 is resolved, review116+ # --show-trace option and error elobaration.117+ exit 1118 }119diff --git a/supported-programs.sh b/supported-programs.sh120index c3673cc..32df590 100755121--- a/supported-programs.sh122+++ b/supported-programs.sh123@@ -10,6 +10,6 @@ cd "$(dirname "$0")"124 programs=(programs/*.nix)125 126 for program in "${programs[@]}"; do127- name=$(basename "$program" .nix)128- echo "* [$name]($program)"129+ name=$(basename "$program" .nix)130+ echo "* [$name]($program)"131 done