Add initial support for custom sniffing

This commit is contained in:
Michael Wolf
2023-09-30 15:33:25 -06:00
parent 3034cd23e8
commit ce634e496c
3 changed files with 77 additions and 0 deletions

View File

@@ -74,5 +74,41 @@ testWfRoot() {
assertEquals "$expected" "$got"
}
testNoCustomSniffer001() {
dir=$(mktemp -d --tmpdir would-reformat-testProjectRoot001.XXXXXX)
cd "$dir" || exit
git init >/dev/null 2>&1
"$DIR"/../install.sh 2>&2 >/dev/null
touch perl-file.pl
touch typescript-file.ts
out1=$(sniff_file_type "$(pwd)"/perl-file.pl)
out2=$(sniff_file_type "$(pwd)"/typescript-file.ts)
assertEquals "perl" "$out1"
assertEquals "typescript" "$out2"
}
testCustomSniffer001() {
dir=$(mktemp -d --tmpdir would-reformat-testProjectRoot001.XXXXXX)
cd "$dir" || exit
git init >/dev/null 2>&1
"$DIR"/../install.sh 2>&2 >/dev/null
mkdir -p .would-reformat || exit 1
cp "$(wf_root)"/examples/custom-sniffer ./.would-reformat/custom-sniffer || exit 1
chmod +x ./.would-reformat/custom-sniffer || exit 1
touch prolog-file.pl
touch qt-translation-file.ts
out1=$(sniff_file_type "$(pwd)"/prolog-file.pl)
out2=$(sniff_file_type "$(pwd)"/qt-translation-file.ts)
assertEquals "prolog" "$out1"
assertEquals "qt-translation" "$out2"
}
# shellcheck disable=SC1091
source shunit2