-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from deadc0de6/fix-3
Fix nested dirs with same names
- Loading branch information
Showing
3 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/usr/bin/env bash | ||
# author: deadc0de6 (https://github.com/deadc0de6) | ||
# Copyright (c) 2024, deadc0de6 | ||
# | ||
# test for nested directories with same names | ||
# for https://github.com/deadc0de6/gocatcli/issues/3 | ||
# | ||
|
||
## start-test-cookie | ||
set -eu -o errtrace -o pipefail | ||
cur=$(cd "$(dirname "${0}")" && pwd) | ||
bin="${cur}/../bin/gocatcli" | ||
[ ! -e "${bin}" ] && echo "\"${bin}\" not found" && exit 1 | ||
# shellcheck disable=SC1091 | ||
source "${cur}"/helpers | ||
## end-test-cookie | ||
|
||
###################################### | ||
## the test | ||
|
||
tmpd=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d) | ||
tmpx=$(mktemp -d --suffix='-dotdrop-tests' || mktemp -d) | ||
clear_on_exit "${tmpd}" | ||
clear_on_exit "${tmpx}" | ||
|
||
catalog="${tmpd}/catalog" | ||
out="${tmpd}/output.txt" | ||
|
||
# create hierarchy | ||
top="${tmpx}/top" | ||
sup="${top}/artist" | ||
sub="${sup}/artist" | ||
subf="${sub}/sub-file" | ||
supf="${sup}/sup-file" | ||
topf="${top}/top-file" | ||
mkdir -p "${sub}" | ||
echo "sub-file" > "${subf}" | ||
echo "sup-file" > "${supf}" | ||
echo "top-file" > "${topf}" | ||
|
||
# index | ||
echo ">>> index dir <<<" | ||
"${bin}" index -a -C --debug -c "${catalog}" --ignore=".git" "${top}" top | ||
[ ! -e "${catalog}" ] && echo "catalog not created" && exit 1 | ||
|
||
# ls | ||
echo ">>> ls catalog <<<" | ||
"${bin}" -c "${catalog}" ls -a -r | sed -e 's/\x1b\[[0-9;]*m//g' | sed 's/[[:space:]]*$//' > "${out}" | ||
|
||
cat > "${tmpx}/expected" << _EOF | ||
storage top | ||
artist | ||
artist | ||
sub-file | ||
sup-file | ||
top-file | ||
_EOF | ||
|
||
if hash delta >/dev/null 2>&1; then | ||
delta "${tmpx}/expected" "${out}" | ||
else | ||
diff -w --suppress-common-lines "${tmpx}/expected" "${out}" | ||
fi | ||
|
||
echo "test $(basename "${0}") OK!" | ||
exit 0 |