From b7fed4a7978db3b7bba1548fd0b4230424815024 Mon Sep 17 00:00:00 2001 From: Scott Bronson Date: Tue, 21 Jul 2020 13:15:31 -0700 Subject: [PATCH] split filename testing into its own testfile also add a test for girding an empty directory --- README.md | 7 ++--- t/01-generates-checksums.t | 54 ++++----------------------------- t/02-filenames.t | 61 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 53 deletions(-) create mode 100755 t/02-filenames.t diff --git a/README.md b/README.md index 2868689..1f8abfc 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/t/01-generates-checksums.t b/t/01-generates-checksums.t index 3af2981..6c9a3c1 100755 --- a/t/01-generates-checksums.t +++ b/t/01-generates-checksums.t @@ -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 diff --git a/t/02-filenames.t b/t/02-filenames.t new file mode 100755 index 0000000..f1502b1 --- /dev/null +++ b/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