Modify test.sh for macOS, fixes #44

This commit is contained in:
sharkdp 2017-06-15 15:46:43 +02:00 committed by David Peter
parent eb728756ed
commit d8d0cf5d6e

View file

@ -28,7 +28,7 @@ expect() {
echo "$expected_output" > "$tmp_expected" echo "$expected_output" > "$tmp_expected"
"$fd" "$@" | sort > "$tmp_output" "$fd" "$@" | sort -f > "$tmp_output"
echo -ne " ${bold}${reset} Testing 'fd $*' ... " echo -ne " ${bold}${reset} Testing 'fd $*' ... "
@ -42,7 +42,7 @@ expect() {
echo -ne "\nShowing diff between ${red}expected${reset} and " echo -ne "\nShowing diff between ${red}expected${reset} and "
echo -e "${green}actual${reset} output:\n" echo -e "${green}actual${reset} output:\n"
diff -C3 --label expected --label actual --color \ diff -C3 --label expected --label actual \
"$tmp_expected" "$tmp_output" || true "$tmp_expected" "$tmp_output" || true
rm -f "$tmp_expected" "$tmp_output" rm -f "$tmp_expected" "$tmp_output"
@ -62,7 +62,7 @@ mkdir -p one/two/three
touch a.foo touch a.foo
touch one/b.foo touch one/b.foo
touch one/two/c.foo touch one/two/c.foo
touch one/two/C.Foo touch one/two/C.Foo2
touch one/two/three/d.foo touch one/two/three/d.foo
mkdir one/two/three/directory_foo mkdir one/two/three/directory_foo
touch ignored.foo touch ignored.foo
@ -81,7 +81,7 @@ expect "one/two/three/d.foo" d.foo
expect "a.foo expect "a.foo
one/b.foo one/b.foo
one/two/c.foo one/two/c.foo
one/two/C.Foo one/two/C.Foo2
one/two/three/d.foo one/two/three/d.foo
one/two/three/directory_foo" foo one/two/three/directory_foo" foo
expect "a.foo expect "a.foo
@ -89,7 +89,7 @@ one
one/b.foo one/b.foo
one/two one/two
one/two/c.foo one/two/c.foo
one/two/C.Foo one/two/C.Foo2
one/two/three one/two/three
one/two/three/d.foo one/two/three/d.foo
one/two/three/directory_foo one/two/three/directory_foo
@ -98,7 +98,7 @@ symlink" # run 'fd' without arguments
suite "Explicit root path" suite "Explicit root path"
expect "one/b.foo expect "one/b.foo
one/two/c.foo one/two/c.foo
one/two/C.Foo one/two/C.Foo2
one/two/three/d.foo one/two/three/d.foo
one/two/three/directory_foo" foo one one/two/three/directory_foo" foo one
expect "one/two/three/d.foo expect "one/two/three/d.foo
@ -108,7 +108,7 @@ cd one/two
expect "../../a.foo expect "../../a.foo
../b.foo ../b.foo
c.foo c.foo
C.Foo C.Foo2
three/d.foo three/d.foo
three/directory_foo" foo ../../ three/directory_foo" foo ../../
) )
@ -117,7 +117,7 @@ suite "Regex searches"
expect "a.foo expect "a.foo
one/b.foo one/b.foo
one/two/c.foo one/two/c.foo
one/two/C.Foo" '[a-c].foo' one/two/C.Foo2" '[a-c].foo'
expect "a.foo expect "a.foo
one/b.foo one/b.foo
one/two/c.foo" --case-sensitive '[a-c].foo' one/two/c.foo" --case-sensitive '[a-c].foo'
@ -126,14 +126,14 @@ one/two/c.foo" --case-sensitive '[a-c].foo'
suite "Smart case" suite "Smart case"
expect "one/two/c.foo expect "one/two/c.foo
one/two/C.Foo" c.foo one/two/C.Foo2" c.foo
expect "one/two/C.Foo" C.Foo expect "one/two/C.Foo2" C.Foo
expect "one/two/C.Foo" Foo expect "one/two/C.Foo2" Foo
suite "Case-sensitivity (--case-sensitive)" suite "Case-sensitivity (--case-sensitive)"
expect "one/two/c.foo" --case-sensitive c.foo expect "one/two/c.foo" --case-sensitive c.foo
expect "one/two/C.Foo" --case-sensitive C.Foo expect "one/two/C.Foo2" --case-sensitive C.Foo
suite "Full path search (--full-path)" suite "Full path search (--full-path)"
@ -143,11 +143,11 @@ expect "a.foo" --full-path '^a\.foo$'
suite "Hidden files (--hidden)" suite "Hidden files (--hidden)"
expect "a.foo expect ".hidden.foo
.hidden.foo a.foo
one/b.foo one/b.foo
one/two/c.foo one/two/c.foo
one/two/C.Foo one/two/C.Foo2
one/two/three/d.foo one/two/three/d.foo
one/two/three/directory_foo" --hidden foo one/two/three/directory_foo" --hidden foo
@ -157,25 +157,25 @@ expect "a.foo
ignored.foo ignored.foo
one/b.foo one/b.foo
one/two/c.foo one/two/c.foo
one/two/C.Foo one/two/C.Foo2
one/two/three/d.foo one/two/three/d.foo
one/two/three/directory_foo" --no-ignore foo one/two/three/directory_foo" --no-ignore foo
expect "a.foo expect ".hidden.foo
.hidden.foo a.foo
ignored.foo ignored.foo
one/b.foo one/b.foo
one/two/c.foo one/two/c.foo
one/two/C.Foo one/two/C.Foo2
one/two/three/d.foo one/two/three/d.foo
one/two/three/directory_foo" --hidden --no-ignore foo one/two/three/directory_foo" --hidden --no-ignore foo
suite "Symlinks (--follow)" suite "Symlinks (--follow)"
expect "one/two/c.foo expect "one/two/c.foo
one/two/C.Foo one/two/C.Foo2
symlink/c.foo symlink/c.foo
symlink/C.Foo" --follow c.foo symlink/C.Foo2" --follow c.foo
suite "Maximum depth (--max-depth)" suite "Maximum depth (--max-depth)"
@ -184,7 +184,7 @@ one
one/b.foo one/b.foo
one/two one/two
one/two/c.foo one/two/c.foo
one/two/C.Foo one/two/C.Foo2
one/two/three one/two/three
symlink" --max-depth 3 symlink" --max-depth 3
expect "a.foo expect "a.foo
@ -196,25 +196,28 @@ expect "a.foo
one one
symlink" --max-depth 1 symlink" --max-depth 1
abs_path=$(python -c "import os; print(os.path.realpath('$root'))")
suite "Absolute paths (--absolute-path)" suite "Absolute paths (--absolute-path)"
expect "$root/a.foo expect "$abs_path/a.foo
$root/one/b.foo $abs_path/one/b.foo
$root/one/two/c.foo $abs_path/one/two/c.foo
$root/one/two/C.Foo $abs_path/one/two/C.Foo2
$root/one/two/three/d.foo $abs_path/one/two/three/d.foo
$root/one/two/three/directory_foo" --absolute-path foo $abs_path/one/two/three/directory_foo" --absolute-path foo
expect "$root/a.foo expect "$abs_path/a.foo
$root/one/b.foo $abs_path/one/b.foo
$root/one/two/c.foo $abs_path/one/two/c.foo
$root/one/two/C.Foo $abs_path/one/two/C.Foo2
$root/one/two/three/d.foo $abs_path/one/two/three/d.foo
$root/one/two/three/directory_foo" foo "$root" $abs_path/one/two/three/directory_foo" foo "$abs_path"
suite "Invalid UTF-8" if [[ "$OSTYPE" == "linux-gnu" ]]; then
touch "$(printf 'test-invalid-utf8-\xc3.txt')" suite "Invalid UTF-8"
expect "$(printf 'test-invalid-utf8-\ufffd.txt')" test-invalid-utf8 touch "$(printf 'test-invalid-utf8-\xc3.txt')"
expect "$(printf 'test-invalid-utf8-\ufffd.txt')" test-invalid-utf8
fi
# All done # All done
echo echo