lumia

Archive checksum manager
git clone git://lumidify.org/git/lumia.git
Log | Files | Refs

commit f4363929567890c7ecd33b46af3210f988779242
parent 4fbf400a3cf553ee8119f3d27072c235657102c0
Author: lumidify <nobody@lumidify.org>
Date:   Tue, 24 Mar 2020 16:29:52 +0100

Add test for cp

Diffstat:
Mlumia.pl | 9++++++++-
Mtests/alltests.sh | 1+
Atests/cp.sh | 29+++++++++++++++++++++++++++++
Atests/cp.txt | 48++++++++++++++++++++++++++++++++++++++++++++++++
Mtests/filenames.sh | 12++++++++++++
Mtests/filenames.txt | 28++++++++++++++++++++++++++++
6 files changed, 126 insertions(+), 1 deletion(-)

diff --git a/lumia.pl b/lumia.pl @@ -1325,7 +1325,7 @@ would if they were programmed more efficiently. Too bad. This program was written on OpenBSD. It will probably work on most other reasonably POSIX-Compliant systems, although I cannot guarantee anything. -$CKSUM_CMD may need to be modified at the top of the file. The file +$CKSUM_CMD may need to be modified at the top of lumia.pl. The file operation commands are called directly with system(), so those need to be available. @@ -1344,6 +1344,13 @@ filenames properly is difficult. There are probably many other edge cases, especially in the B<mv>, B<cp>, and B<rm> commands. Please notify me if you find an issue. +Operations on files containing newlines may cause Perl to print a warning +"Unsuccessful stat on filename containing newline" even though nothing is +wrong since (as described in B<mv> and B<rm>) existence of the file is +checked afterwards. I didn't feel like disabling warnings, and no normal +person should be working with files containing newlines anyways, so that's +the way it is. + =head1 EXIT STATUS Always 0, unless the arguments given were invalid. We don't do errors around here. diff --git a/tests/alltests.sh b/tests/alltests.sh @@ -2,3 +2,4 @@ ./runtest.sh filenames ./runtest.sh mv +./runtest.sh cp diff --git a/tests/cp.sh b/tests/cp.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +mkdir tmp +cd tmp + +mkdir a +mkdir b +mkdir c + +touch f1 +touch f2 +touch f3 + +../../lumia.pl addnew | sort +../../lumia.pl cp -v f1 bob +../../lumia.pl cp f2 a +../../lumia.pl cp f* b +../../lumia.pl check | sort +echo "a" > f4 +../../lumia.pl addnew +echo "n" | ../../lumia.pl cp f4 a/f2 +cat a/.lumidify_archive_cksums +../../lumia.pl check a | sort +../../lumia.pl cp -vf f4 a/f2 +cat a/.lumidify_archive_cksums +../../lumia.pl check | sort + +cd .. +rm -r tmp diff --git a/tests/cp.txt b/tests/cp.txt @@ -0,0 +1,48 @@ +Added "./a" +Added "./b" +Added "./c" +Added "./f1" +Added "./f2" +Added "./f3" +./f1 -> bob +OK ./.lumidify_archive_cksums +OK ./.lumidify_archive_dirs +OK ./a/.lumidify_archive_cksums +OK ./a/.lumidify_archive_dirs +OK ./a/f2 +OK ./b/.lumidify_archive_cksums +OK ./b/.lumidify_archive_dirs +OK ./b/f1 +OK ./b/f2 +OK ./b/f3 +OK ./bob +OK ./c/.lumidify_archive_cksums +OK ./c/.lumidify_archive_dirs +OK ./f1 +OK ./f2 +OK ./f3 +Added "./f4" +WARNING: "a/f2" exists already. Do you want to replace it? (y/n) Not overwriting "a/f2" +4294967295 0 "f2" +OK a/.lumidify_archive_cksums +OK a/.lumidify_archive_dirs +OK a/f2 +./f4 -> a/f2 +2418082923 2 "f2" +OK ./.lumidify_archive_cksums +OK ./.lumidify_archive_dirs +OK ./a/.lumidify_archive_cksums +OK ./a/.lumidify_archive_dirs +OK ./a/f2 +OK ./b/.lumidify_archive_cksums +OK ./b/.lumidify_archive_dirs +OK ./b/f1 +OK ./b/f2 +OK ./b/f3 +OK ./bob +OK ./c/.lumidify_archive_cksums +OK ./c/.lumidify_archive_dirs +OK ./f1 +OK ./f2 +OK ./f3 +OK ./f4 diff --git a/tests/filenames.sh b/tests/filenames.sh @@ -18,4 +18,16 @@ cat 'tmp/ a/.lumidify_archive_cksums' | sort cat 'tmp/ a/.lumidify_archive_cksums' | sort ../lumia.pl check tmp/-b | sort ../lumia.pl check tmp | sort +cd tmp +../../lumia.pl cp -- -b -e +../../lumia.pl check | sort +# this is sent to /dev/null because Perl produces a +# warning (see BUGS in the perldoc) which shows the +# line number and thus would change frequently +../../lumia.pl mv -- '-c + +' '-f' > /dev/null 2>&1 +../../lumia.pl check | sort + +cd .. rm -rf tmp diff --git a/tests/filenames.txt b/tests/filenames.txt @@ -36,3 +36,31 @@ OK tmp/-c OK tmp/-c OK tmp/.lumidify_archive_cksums OK tmp/.lumidify_archive_dirs + + +/.lumidify_archive_cksums +/.lumidify_archive_dirs +OK ./ a/.lumidify_archive_cksums +OK ./ a/.lumidify_archive_dirs +OK ./-b/$\%") +OK ./-b/.lumidify_archive_cksums +OK ./-b/.lumidify_archive_dirs +OK ./-c +OK ./-c +OK ./-e/$\%") +OK ./-e/.lumidify_archive_cksums +OK ./-e/.lumidify_archive_dirs +OK ./.lumidify_archive_cksums +OK ./.lumidify_archive_dirs +OK ./ a/.lumidify_archive_cksums +OK ./ a/.lumidify_archive_dirs +OK ./-b/$\%") +OK ./-b/.lumidify_archive_cksums +OK ./-b/.lumidify_archive_dirs +OK ./-e/$\%") +OK ./-e/.lumidify_archive_cksums +OK ./-e/.lumidify_archive_dirs +OK ./-f/.lumidify_archive_cksums +OK ./-f/.lumidify_archive_dirs +OK ./.lumidify_archive_cksums +OK ./.lumidify_archive_dirs