# HG changeset patch # User Matthias Förste # Date 1437659840 -7200 # Node ID 531e14cda4fa7b83d5af568e82305c56129afa27 # Parent 53fc675aed0e1341be8bdab3053573bfbe043ef3 adjusted tests according to latest changes diff -r 53fc675aed0e -r 531e14cda4fa test --- a/test Thu Jul 23 15:56:15 2015 +0200 +++ b/test Thu Jul 23 15:57:20 2015 +0200 @@ -12,15 +12,17 @@ my $num_non_proe = 101; my @nums_before = (0, 1, 2, 7, 13, 17, 23, 42, '0815', 4711); -use Test::Simple tests => 23; -#use Test::More tests => 23; +use Test::Simple tests => 53; my $files = { in_workdir => [ map "$stem.$_", @nums_before ], in_subdir => [ map "$subdir/$stem.$_", @nums_before ], empty => "$subdir/$stem.$num_empty", - non_proe => "$subdir/$stem.$num_non_proe" + non_proe => "$subdir/$stem.$num_non_proe", + errors_lst => [ map "errors.lst.$_", @nums_before ], + trail_txt => [ map "trail.txt.$_", @nums_before ], + info_trf => [ map "info.trf.$_", @nums_before ] }; @@ -28,13 +30,16 @@ prepare({ dirs => [$subdir], files => $files, proe_first_line => $proe_first_line }); ok(qx/$purge_cmd/, "Running '$purge_cmd'"); -my @iw = @{$files->{in_workdir}}; -my @is = @{$files->{in_subdir}}; +my (@absent, @present); +@present = @{$files}{qw(empty non_proe)}; +for (qw(in_workdir in_subdir errors_lst trail_txt info_trf)) { + push @present, splice @{$files->{$_}}, -3, 3; + push @absent, @{$files->{$_}}; +} +for (@present) { ok(-f $_, "Checking for presence of file '$_'"); } +for (@absent) { ok(! -e $_, "Checking for absence of '$_'"); } -for (@iw[$#iw-2 .. $#iw], @is[$#is-2 .. $#is], $files->{empty}, $files->{non_proe}) { ok(-f $_, "Checking for presence of file '$_'"); } -for (@iw[0 .. $#iw-3], @is[0 .. $#iw-3]) { ok(! -e $_, "Checking for absence of '$_'"); } - -for (@iw[$#iw-2 .. $#iw], @is[$#is-2 .. $#is], $files->{empty}, $files->{non_proe}, "y/abc") { unlink || warn "Can't unlink '$_': $!" if -f; } +for (@present, "y/abc") { unlink || warn "Can't unlink '$_': $!" if -f; } rmdir $subdir or warn "Can't rmdir '$subdir': $!"; # $opts = { @@ -44,6 +49,9 @@ # in_subdir => ['path1', 'path2', ..], # empty => 'path_to_an_empty_file', # non_proe => 'path_to_a_nonempty_nonproe_file' +# errors_lst => [ 'errors.lst.n1', 'errors.lst.n2', ..], +# trail_txt => [ 'trail.txt.n1', 'trail.txt.n2', ..], +# info_trf => [ 'info.trf.n1', 'info.trf.n2', ..] # }, # proe_first_line => 'something that should appear in the first line of a file to match' # } @@ -53,12 +61,12 @@ for (@{$opts->{dirs}}) { mkdir $_ or warn "Can't mkdir '$_': $!"; } - for (@{$opts->{files}->{in_workdir}}, @{$opts->{files}->{in_subdir}}) { + for (map { @{$_} } @{$opts->{files}}{qw(in_workdir in_subdir errors_lst trail_txt info_trf)}) { - open F, '>', $_ or warn "Can't open F, '>', '$_': $!"; - print F $proe_first_line; - close F; - + open F, '>', $_ or warn "Can't open F, '>', '$_': $!"; + print F $proe_first_line; + close F; + } my $empty = $opts->{files}->{empty};