Skip to content

Commit

Permalink
test: adapt test to enable windows support
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielaRuecker authored and DanielaRuecker committed Aug 31, 2022
1 parent 06d03ec commit 3061173
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions ci/test
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,45 @@ set -o pipefail
################################################################################
. ci/functions.sh

run pre_commit_hooks/yamlfmt --help
run python3 pre_commit_hooks/yamlfmt.py --help
echo

run pre-commit try-repo . --files .pre-commit-config.yaml

while read -r file; do
run pre_commit_hooks/yamlfmt --mapping 4 --sequence 6 --offset 4 "${file}"
run python3 pre_commit_hooks/yamlfmt.py --mapping 4 --sequence 6 --offset 4 "${file}"
done < <(find . -regex '.*\.yaml')

echo "[INFO] Use with xargs"
find . -regex '.*\.yaml' -print0 |
xargs -0 pre_commit_hooks/yamlfmt -m 4 -s 6 -o 4
xargs -0 python3 pre_commit_hooks/yamlfmt.py -m 4 -s 6 -o 4
echo

run pre_commit_hooks/yamlfmt -m 2 -s 2 -o 0 .pre-commit-hooks.yaml
run python3 pre_commit_hooks/yamlfmt.py -m 2 -s 2 -o 0 .pre-commit-hooks.yaml

# Ensure we never break multidoc.
TMP_FILE="$(mktemp pre-commit-hook-yamlfmt-test.XXXXXXXXXXXXXXXXXXXX)"
run cp -f ci/multidoc-before.txt "${TMP_FILE}"
run pre_commit_hooks/yamlfmt --mapping 4 --sequence 6 --offset 4 "${TMP_FILE}"
run python3 pre_commit_hooks/yamlfmt.py --mapping 4 --sequence 6 --offset 4 "${TMP_FILE}"
run diff ci/multidoc-after.yaml "${TMP_FILE}"
# If the diff fails, the temp file is still there to inspect.
run rm -f "${TMP_FILE}"

# Test preserve quotes
TMP_FILE="$(mktemp pre-commit-hook-yamlfmt-test.XXXXXXXXXXXXXXXXXXXX)"
run cp -f ci/quotes-before.txt "${TMP_FILE}"
run pre_commit_hooks/yamlfmt --mapping 4 --sequence 6 --offset 4 --preserve-quotes "${TMP_FILE}"
run python3 pre_commit_hooks/yamlfmt.py --mapping 4 --sequence 6 --offset 4 --preserve-quotes "${TMP_FILE}"
run diff ci/quotes-after.txt "${TMP_FILE}"
# If the diff fails, the temp file is still there to inspect.
run rm -f "${TMP_FILE}"

# Test width setting
TMP_FILE="$(mktemp pre-commit-hook-yamlfmt-test.XXXXXXXXXXXXXXXXXXXX)"
run cp -f ci/test-long.txt "${TMP_FILE}"
run pre_commit_hooks/yamlfmt --width 250 "${TMP_FILE}"
run python3 pre_commit_hooks/yamlfmt.py --width 250 "${TMP_FILE}"
# Width=250, no change
run diff ci/test-long.txt "${TMP_FILE}"
run pre_commit_hooks/yamlfmt --width 79 "${TMP_FILE}"
run python3 pre_commit_hooks/yamlfmt.py --width 79 "${TMP_FILE}"
# Now we should see no lines > 81 (it has some offset in ruamel)
run grep -v -q '.\{82\}' "${TMP_FILE}"
run rm -f "${TMP_FILE}"
Expand Down

0 comments on commit 3061173

Please sign in to comment.