Add initial support for custom sniffing
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user