commit 1c24f92d5ebb13f5c604e709d3822e9834cea4f8
parent a4d16b3c7af854ea44887d829731d1405cbb66f2
Author: lumidify <nobody@lumidify.org>
Date:   Wed, 25 Mar 2020 19:39:33 +0100
Improve test for check/addnew
Diffstat:
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/lumia.pl b/lumia.pl
@@ -296,7 +296,7 @@ sub write_special_cksums {
 # - if $after_dir_func is set, it is called after processing the
 #   files in each directory that has new files
 sub check_new_files {
-	my ($dir, $file_func, $before_dir_func, $after_dir_func) = @_;
+	my ($top_dir, $file_func, $before_dir_func, $after_dir_func) = @_;
 	my $iter = make_file_iter sub {1}, sub {
 		my $dir = shift;
 		my $dh;
@@ -340,7 +340,7 @@ sub check_new_files {
 			$after_dir_func->($dir);
 		}
 		return \@dirs;
-	}, $dir;
+	}, $top_dir;
 	# Is this a horrible hack? I dunno, but it sure is sweet...
 	while ($iter->()) {}
 }
@@ -976,6 +976,8 @@ if ($cmd eq "mv") {
 	die "Invalid number of arguments\n" if @ARGV > 1;
 	my $dir = @ARGV ? $ARGV[0] : ".";
 	update_special $dir;
+} else {
+	pod2usage(-exitval => 1, -verbose => 1);
 }
 
 __END__
diff --git a/tests/addcknew.sh b/tests/addcknew.sh
@@ -22,5 +22,12 @@ touch a/fred
 ../../lumia.pl addnew a
 ../../lumia.pl check | sort
 
+echo
+# keep checksum files of subdirectories
+../../lumia.pl clean -q
+touch a/bob
+../../lumia.pl addnew a | sort
+../../lumia.pl checknew | sort
+
 cd ..
 rm -r tmp
diff --git a/tests/addcknew.txt b/tests/addcknew.txt
@@ -21,3 +21,13 @@ OK ./c/.lumidify_archive_dirs
 OK ./f1
 OK ./f2
 OK ./f3
+
+Added "a/bob"
+Added "a/fred"
+./-bob
+./a
+./b
+./c
+./f1
+./f2
+./f3