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 | |
| 9 | my $f = dirname(__FILE__); |
| 10 | my $script = catfile($f, '..', '..', 'script', 'korapxml2krill'); |
| 11 | |
Akron | bd3adda | 2017-04-11 15:00:55 +0200 | [diff] [blame] | 12 | my $input_base = catdir($f, '..', 'corpus'); |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 13 | |
| 14 | # Temporary output |
| 15 | my $output = File::Temp->newdir(CLEANUP => 0); |
| 16 | |
Akron | 5fd2d8e | 2017-06-19 15:29:39 +0200 | [diff] [blame] | 17 | my $cache = tmpnam(); |
| 18 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 19 | my $call = join( |
| 20 | ' ', |
| 21 | 'perl', $script, |
| 22 | 'serial', |
Akron | bd3adda | 2017-04-11 15:00:55 +0200 | [diff] [blame] | 23 | '-t' => 'Base#tokens_aggr', |
| 24 | '-i' => '"archive.zip"', |
| 25 | '-i' => '"archives/wpd15*.zip"', |
Akron | 5fd2d8e | 2017-06-19 15:29:39 +0200 | [diff] [blame] | 26 | '--cache' => $cache, |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 27 | '-ib' => $input_base, |
Akron | bd3adda | 2017-04-11 15:00:55 +0200 | [diff] [blame] | 28 | '-o' => $output |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 29 | ); |
| 30 | |
| 31 | # Test without parameters |
Akron | bd3adda | 2017-04-11 15:00:55 +0200 | [diff] [blame] | 32 | my $stdout = stdout_from(sub { system($call) }); |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 33 | |
Akron | bd3adda | 2017-04-11 15:00:55 +0200 | [diff] [blame] | 34 | like($stdout, qr!Start serial processing of .+?wpd15\*\.zip!, 'Processing'); |
| 35 | like($stdout, qr!Start serial processing .+?archive.zip!, 'Processing'); |
| 36 | |
| 37 | like($stdout, qr!Processed .+?/archive/TEST-BSP-1\.json!, 'Archive file'); |
| 38 | like($stdout, qr!Processed .+?/archives-wpd15/WPD15-A00-00081\.json!, 'Archive file'); |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 39 | |
| 40 | done_testing; |
| 41 | __END__ |