Skip to content

Commit

Permalink
split filename testing into its own testfile
Browse files Browse the repository at this point in the history
also add a test for girding an empty directory
  • Loading branch information
bronson committed Jul 21, 2020
1 parent 4891e06 commit b7fed4a
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 53 deletions.
7 changes: 3 additions & 4 deletions README.md
Expand Up @@ -95,11 +95,10 @@ including md5 and cksum.
* How should Gird handle hidden files and directories? (right now it ignores them)
* Show progress: what directory we're in
* gird --verbose and gird --silent
* .sha1sums is probably not a good name. Call it Girdfile?
* If so, we can also stick other data and comments in the file.
* Add explicit arguments for gird --add and gird --verify
* Also add a --force to tell add and verify to keep processing even if you see inconsistencies
* Add a -j option to fork multiple jobs?
* make installation easier/better/more explicit
* Consider using Blake https://blake2.net. It's fast!
* Check on differences between sharness and git. Does Git suffer the same issues?
* Check on differences between sharness and git (heredoc/process substitution issues).
* Does Git suffer the same issues or is it just sharness?
* make installation easier/better/more explicit
54 changes: 5 additions & 49 deletions t/01-generates-checksums.t
Expand Up @@ -13,57 +13,13 @@ test_expect_success "Simple recursive checksum" "
rm -rf test-tree
"

filename=" a b c "
test_expect_success "Handles spaces in filenames" "
touch \"$filename\" &&
# It appears that heredocs are fundamentally incompatible with sharness.
# test_cmp <(echo -n) Girdsums
test_expect_success "Running in empty dir" "
gird &&
echo \"da39a3ee5e6b4b0d3255bfef95601890afd80709 ./$filename\" > tt &&
>tt &&
test_cmp tt Girdsums &&
rm tt \"$filename\" Girdsums
"

# Probably need to disable this test on Windows
# TODO: yikes, is this a sharness problem?
# This test works when run directly but not when run by `prove`.
# The \\\\\\\\ works but it can't possibly be intentional.
#
# filename="\b"
# test_expect_success "Handles backslashes in filenames" "
# touch \"$filename\" &&
# gird &&
# echo \"\\da39a3ee5e6b4b0d3255bfef95601890afd80709 ./\\\\\\\\b\" > tt &&
# test_cmp tt Girdsums &&
# rm tt \"$filename\" Girdsums
# "

filename="'a'"
test_expect_success "Handles single quotes in filenames" "
touch \"$filename\" &&
gird &&
echo \"da39a3ee5e6b4b0d3255bfef95601890afd80709 ./$filename\" > tt &&
test_cmp tt Girdsums &&
rm tt \"$filename\" Girdsums
"

filename='\"a\"'
test_expect_success "Handles double quotes in filenames" "
touch \"$filename\" &&
gird &&
echo \"da39a3ee5e6b4b0d3255bfef95601890afd80709 ./$filename\" > tt &&
test_cmp tt Girdsums &&
rm tt \"$filename\" Girdsums
"

evil='a;b>c|d&&e\$f()g!h'
# Can't use a heredoc to remove the need for the tt file.
# It works when running directly, fails when running in `prove`.
# diff -u <(echo \"da39a3ee5e6b4b0d3255bfef95601890afd80709 ./$evil\") Girdsums &&
test_expect_success "Handles evil filename characters" "
touch \"$evil\" &&
gird &&
echo \"da39a3ee5e6b4b0d3255bfef95601890afd80709 ./$evil\" > tt &&
test_cmp tt Girdsums &&
rm tt \"$evil\" Girdsums
rm tt Girdsums
"

test_done
61 changes: 61 additions & 0 deletions t/02-filenames.t
@@ -0,0 +1,61 @@
#!/bin/sh

test_description="Ensures recursive checksumming works"

. sharness.sh

filename=" a b c "
test_expect_success "Handles spaces in filenames" "
touch \"$filename\" &&
gird &&
echo \"da39a3ee5e6b4b0d3255bfef95601890afd80709 ./$filename\" > tt &&
test_cmp tt Girdsums &&
rm tt \"$filename\" Girdsums
"

# Probably need to disable this test on Windows
# TODO: yikes, is this a sharness problem?
# This test works when run directly but not when run by `prove`.
# The \\\\\\\\ works but it can't possibly be intentional.
#
# filename="\b"
# test_expect_success "Handles backslashes in filenames" "
# touch \"$filename\" &&
# gird &&
# echo \"\\da39a3ee5e6b4b0d3255bfef95601890afd80709 ./\\\\\\\\b\" > tt &&
# test_cmp tt Girdsums &&
# rm tt \"$filename\" Girdsums
# "

filename="'a'"
test_expect_success "Handles single quotes in filenames" "
touch \"$filename\" &&
gird &&
echo \"da39a3ee5e6b4b0d3255bfef95601890afd80709 ./$filename\" > tt &&
test_cmp tt Girdsums &&
rm tt \"$filename\" Girdsums
"

filename='\"a\"'
test_expect_success "Handles double quotes in filenames" "
touch \"$filename\" &&
gird &&
echo \"da39a3ee5e6b4b0d3255bfef95601890afd80709 ./$filename\" > tt &&
test_cmp tt Girdsums &&
rm tt \"$filename\" Girdsums
"

evil='a;b>c|d&&e\$f()g!h'
# Can't use a heredoc to remove the need for the tt file.
# It works when running directly, fails when running in `prove`.
# diff -u <(echo \"da39a3ee5e6b4b0d3255bfef95601890afd80709 ./$evil\") Girdsums &&
# Ah, the issue appears to be the process substitution. See the 'Running in empty dir' test.
test_expect_success "Handles evil filename characters" "
touch \"$evil\" &&
gird &&
echo \"da39a3ee5e6b4b0d3255bfef95601890afd80709 ./$evil\" > tt &&
test_cmp tt Girdsums &&
rm tt \"$evil\" Girdsums
"

test_done

0 comments on commit b7fed4a

Please sign in to comment.