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