Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 1 | use strict; |
| 2 | use warnings; |
| 3 | use Test::More; |
Akron | bd3adda | 2017-04-11 15:00:55 +0200 | [diff] [blame] | 4 | use Test::Output qw/stdout_from/; |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 5 | use File::Basename 'dirname'; |
| 6 | use File::Spec::Functions qw/catdir catfile/; |
Akron | 5fd2d8e | 2017-06-19 15:29:39 +0200 | [diff] [blame] | 7 | use File::Temp qw/:POSIX/; |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 8 | |
Akron | fab17d3 | 2020-07-31 14:38:29 +0200 | [diff] [blame^] | 9 | if ($ENV{SKIP_SCRIPT}) { |
| 10 | plan skip_all => 'Skip script tests'; |
| 11 | }; |
| 12 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 13 | my $f = dirname(__FILE__); |
| 14 | my $script = catfile($f, '..', '..', 'script', 'korapxml2krill'); |
| 15 | |
Akron | bd3adda | 2017-04-11 15:00:55 +0200 | [diff] [blame] | 16 | my $input_base = catdir($f, '..', 'corpus'); |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 17 | |
| 18 | # Temporary output |
| 19 | my $output = File::Temp->newdir(CLEANUP => 0); |
| 20 | |
Akron | 5fd2d8e | 2017-06-19 15:29:39 +0200 | [diff] [blame] | 21 | my $cache = tmpnam(); |
| 22 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 23 | my $call = join( |
| 24 | ' ', |
| 25 | 'perl', $script, |
| 26 | 'serial', |
Akron | bd3adda | 2017-04-11 15:00:55 +0200 | [diff] [blame] | 27 | '-t' => 'Base#tokens_aggr', |
| 28 | '-i' => '"archive.zip"', |
| 29 | '-i' => '"archives/wpd15*.zip"', |
Akron | 5fd2d8e | 2017-06-19 15:29:39 +0200 | [diff] [blame] | 30 | '--cache' => $cache, |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 31 | '-ib' => $input_base, |
Akron | bd3adda | 2017-04-11 15:00:55 +0200 | [diff] [blame] | 32 | '-o' => $output |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 33 | ); |
| 34 | |
| 35 | # Test without parameters |
Akron | bd3adda | 2017-04-11 15:00:55 +0200 | [diff] [blame] | 36 | my $stdout = stdout_from(sub { system($call) }); |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 37 | |
Akron | bd3adda | 2017-04-11 15:00:55 +0200 | [diff] [blame] | 38 | like($stdout, qr!Start serial processing of .+?wpd15\*\.zip!, 'Processing'); |
| 39 | like($stdout, qr!Start serial processing .+?archive.zip!, 'Processing'); |
| 40 | |
| 41 | like($stdout, qr!Processed .+?/archive/TEST-BSP-1\.json!, 'Archive file'); |
| 42 | like($stdout, qr!Processed .+?/archives-wpd15/WPD15-A00-00081\.json!, 'Archive file'); |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 43 | |
| 44 | done_testing; |
| 45 | __END__ |