>> add script for manual testing
> replace path sorter test > will use this instead of wrriting more tests
This commit is contained in:
parent
52c7f8bce6
commit
923b5aa1a4
2 changed files with 76 additions and 32 deletions
32
owl_test.go
32
owl_test.go
|
|
@ -70,35 +70,3 @@ func TestRestrictRuneset(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSortedPaths(t *testing.T) {
|
||||
paths := []string{
|
||||
"./testdata/Tawnee: The Game",
|
||||
"./testdata/birds:/pengiuns?",
|
||||
"./testdata/birds:/pengiuns?/emperor",
|
||||
"./testdata/birds:/pengiuns?/pingu?",
|
||||
"./testdata/birds:",
|
||||
}
|
||||
want := []string{
|
||||
"./testdata/birds:/pengiuns?/emperor",
|
||||
"./testdata/birds:/pengiuns?/pingu?",
|
||||
"./testdata/birds:/pengiuns?",
|
||||
"./testdata/Tawnee: The Game",
|
||||
"./testdata/birds:",
|
||||
}
|
||||
have := sortedPaths(paths)
|
||||
if len(have) > len(want) {
|
||||
t.Fatal("Sorted list is bigger than original")
|
||||
} else if len(have) < len(want) {
|
||||
t.Fatal("Sorted list is smaller than original")
|
||||
}
|
||||
for index, path := range have {
|
||||
if index >= len(want) || path != want[index] {
|
||||
t.Fatalf(
|
||||
"Want: %s\nHave: %s\n",
|
||||
sliceToString(want),
|
||||
sliceToString(have),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
76
test.bash
Executable file
76
test.bash
Executable file
|
|
@ -0,0 +1,76 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Exit on error
|
||||
set -e
|
||||
# Remove all the test files when we're done
|
||||
trap owltest_teardown EXIT
|
||||
|
||||
# Check PWD
|
||||
if [ "$(basename $PWD)" != owl ]; then
|
||||
echo 'Run this from project top level, i.e. "owl"'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export OWL_START=$PWD
|
||||
export OWL_TESTDATA=$PWD/testdata
|
||||
|
||||
# Runes that I don't want to write
|
||||
export mouse_emoji=$'\U0001F401'
|
||||
export germany_emoji=$'\U0001F1E9\U0001F1EA'
|
||||
export bird_emoji=$'\U0001f426'
|
||||
# 猫头鹰
|
||||
export chinese_simplfied_owl=$'\u732B\u5934\u9E70'
|
||||
|
||||
owltest_setup() {
|
||||
mkdir "$OWL_TESTDATA"
|
||||
cd "$OWL_TESTDATA"
|
||||
mkdir -p 'birds:/pengu?ns' 'ascii_dir'
|
||||
touch \
|
||||
'no-change-needed' \
|
||||
'So * many* *** *c*veats' \
|
||||
'::>?' \
|
||||
'<>??' \
|
||||
'birds:/tawny: the game' \
|
||||
'birds:/pengu?ns/pingu?' \
|
||||
'birds:/pengu?ns/rockhopper' \
|
||||
'birds:/pengu?ns/rockhopper?' \
|
||||
"Mouse? ${mouse_emoji}" \
|
||||
"Deustchland, Deutschland! ${germany_emoji}" \
|
||||
"${chinese_simplfied_owl}" \
|
||||
'Question? Why' \
|
||||
'QUESTION: WHY'
|
||||
}
|
||||
|
||||
owltest_teardown() {
|
||||
cd "$OWL_START"
|
||||
rm -r "$OWL_TESTDATA"
|
||||
}
|
||||
|
||||
owltest_reset() {
|
||||
owltest_teardown
|
||||
owltest_setup
|
||||
}
|
||||
|
||||
owl() {
|
||||
$OWL_START/owl $@
|
||||
}
|
||||
|
||||
unicode_rune() {
|
||||
printf "\U$(printf '%08s' $1)\n"
|
||||
}
|
||||
|
||||
# Help message
|
||||
cat <<-EOF
|
||||
Testing script; use this to:
|
||||
- use the owl executable in this directory as just 'owl'
|
||||
- have a set of files and directories to test out owl with
|
||||
This will be a lot easier if you have 'tree' installed; see README.md
|
||||
for details.
|
||||
|
||||
You will now be in ${OWL_TESTDATA}; cd out and delete this directory to
|
||||
clean up after a test. Or run owltest_reset to do the same in-place.
|
||||
EOF
|
||||
|
||||
export -f owltest_setup owltest_reset owltest_teardown owl unicode_rune
|
||||
owltest_setup
|
||||
bash -i
|
||||
Loading…
Add table
Add a link
Reference in a new issue