bld1: building xvyaagf18yl7f5gqmmilmqak3rqqz3kj-treefmt-check.drv treefmt v2.6.0traversed 412 files emitted 148 files for processing formatted 148 files (4 changed) in 447ms M checks/formatter-spec.sh M run-tests.sh M supported-programs.sh diff --git a/checks/formatter-spec.sh b/checks/formatter-spec.sh index f3e0cb1..b166dcf 100644 --- a/checks/formatter-spec.sh +++ b/checks/formatter-spec.sh @@ -15,54 +15,54 @@ fmt=("$@") spec=https://treefmt.com/latest/reference/formatter-spec fail() { - echo "FAIL: $1 ($spec/#$2)" >&2 - exit 1 + echo "FAIL: $1 ($spec/#$2)" >&2 + exit 1 } mkdir -p shallow deep/x/y decoy invalid for f in "$fixtures"/unformatted/*; do - cp "$f" shallow/ - cp "$f" deep/x/y/ - cp "$f" decoy/ + cp "$f" shallow/ + cp "$f" deep/x/y/ + cp "$f" decoy/ done chmod -R u+w shallow deep decoy "${fmt[@]}" shallow/* deep/x/y/* || - fail "exited nonzero on valid input" 3-exit-nonzero-on-error + fail "exited nonzero on valid input" 3-exit-nonzero-on-error for f in "$fixtures"/unformatted/*; do - name=$(basename "$f") - cmp -s "$f" "shallow/$name" && - fail "$name was not modified" 2-write-to-changed-files - cmp -s "$f" "decoy/$name" || - fail "$name was modified although not passed as argument" 1-files-passed-as-arguments - diff -u "shallow/$name" "deep/x/y/$name" || - fail "$name formatted differently depending on its path; fine only if the formatter implements the stdin spec" 6-path-agnostic + name=$(basename "$f") + cmp -s "$f" "shallow/$name" && + fail "$name was not modified" 2-write-to-changed-files + cmp -s "$f" "decoy/$name" || + fail "$name was modified although not passed as argument" 1-files-passed-as-arguments + diff -u "shallow/$name" "deep/x/y/$name" || + fail "$name formatted differently depending on its path; fine only if the formatter implements the stdin spec" 6-path-agnostic done cp -r shallow formatted touch -d @0 shallow/* "${fmt[@]}" shallow/* || - fail "exited nonzero on formatted input" 3-exit-nonzero-on-error + fail "exited nonzero on formatted input" 3-exit-nonzero-on-error diff -ru formatted shallow || - fail "second run changed the output" 4-idempotent + fail "second run changed the output" 4-idempotent for f in shallow/*; do - [[ $(stat -c %Y "$f") == 0 ]] || - fail "$(basename "$f") was rewritten although unchanged" 2-write-to-changed-files + [[ $(stat -c %Y "$f") == 0 ]] || + fail "$(basename "$f") was rewritten although unchanged" 2-write-to-changed-files done if [[ -d $fixtures/invalid ]]; then - valid=(shallow/*) - for f in "$fixtures"/invalid/*; do - name=$(basename "$f") - cp "$f" "invalid/$name" - chmod u+w "invalid/$name" - if "${fmt[@]}" "invalid/$name"; then - fail "exited zero on invalid input $name" 3-exit-nonzero-on-error - fi - if "${fmt[@]}" "invalid/$name" "${valid[@]}"; then - fail "exited zero on invalid input $name followed by valid files" 3-exit-nonzero-on-error - fi - done + valid=(shallow/*) + for f in "$fixtures"/invalid/*; do + name=$(basename "$f") + cp "$f" "invalid/$name" + chmod u+w "invalid/$name" + if "${fmt[@]}" "invalid/$name"; then + fail "exited zero on invalid input $name" 3-exit-nonzero-on-error + fi + if "${fmt[@]}" "invalid/$name" "${valid[@]}"; then + fail "exited zero on invalid input $name followed by valid files" 3-exit-nonzero-on-error + fi + done fi diff --git a/run-tests.sh b/run-tests.sh index 8d2ef9c..f94fb7a 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -8,11 +8,11 @@ nix flake check ./tests --recreate-lock-file --show-trace echo echo Checking that the flake.parts docs build... nix build github:hercules-ci/flake.parts-website --override-input treefmt-nix . --show-trace --log-lines 1000 || { - echo - echo "Looks like the docs aren't quite ok yet." - echo "If there's a long stack trace, look for the keyword: option" - echo "Ping flake-parts / module system maintainer @roberth if the error is unclear." - # TODO After https://github.com/NixOS/nix/issues/7553 is resolved, review - # --show-trace option and error elobaration. - exit 1 + echo + echo "Looks like the docs aren't quite ok yet." + echo "If there's a long stack trace, look for the keyword: option" + echo "Ping flake-parts / module system maintainer @roberth if the error is unclear." + # TODO After https://github.com/NixOS/nix/issues/7553 is resolved, review + # --show-trace option and error elobaration. + exit 1 } diff --git a/supported-programs.sh b/supported-programs.sh index c3673cc..32df590 100755 --- a/supported-programs.sh +++ b/supported-programs.sh @@ -10,6 +10,6 @@ cd "$(dirname "$0")" programs=(programs/*.nix) for program in "${programs[@]}"; do - name=$(basename "$program" .nix) - echo "* [$name]($program)" + name=$(basename "$program" .nix) + echo "* [$name]($program)" done