Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 1 | #/usr/bin/env perl |
| 2 | use strict; |
| 3 | use warnings; |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 4 | use File::Basename 'dirname'; |
| 5 | use File::Spec::Functions qw/catdir catfile/; |
Akron | 5fd2d8e | 2017-06-19 15:29:39 +0200 | [diff] [blame^] | 6 | use File::Temp qw/:POSIX tempfile/; |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 7 | use Mojo::File; |
| 8 | use Test::More; |
| 9 | use Test::Output qw/combined_from/; |
| 10 | use Data::Dumper; |
| 11 | |
| 12 | my $f = dirname(__FILE__); |
| 13 | |
| 14 | my ($fh, $cfg_file) = tempfile(); |
| 15 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 16 | my $input_base = catdir($f, '..', 'corpus', 'archives'); |
| 17 | |
| 18 | print $fh <<"CFG"; |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 19 | overwrite 0 |
| 20 | token OpenNLP#tokens |
| 21 | base-sentences DeReKo#Structure |
| 22 | base-paragraphs DeReKo#Structure |
| 23 | base-pagebreaks DeReKo#Structure |
| 24 | jobs -1 |
| 25 | meta I5 |
| 26 | gzip 1 |
| 27 | log DEBUG |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 28 | input-base $input_base |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 29 | CFG |
| 30 | |
| 31 | close($fh); |
| 32 | |
| 33 | # Path for script |
| 34 | my $script = catfile($f, '..', '..', 'script', 'korapxml2krill'); |
| 35 | |
| 36 | # Path for input |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 37 | my $input = "'".catfile('wpd15*.zip') . "'"; |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 38 | |
| 39 | # Temporary output |
| 40 | my $output = File::Temp->newdir(CLEANUP => 0); |
| 41 | |
Akron | 5fd2d8e | 2017-06-19 15:29:39 +0200 | [diff] [blame^] | 42 | my $cache = tmpnam(); |
| 43 | |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 44 | my $call = join( |
| 45 | ' ', |
| 46 | 'perl', $script, |
| 47 | 'archive', |
| 48 | '--config' => $cfg_file, |
| 49 | '--input' => $input, |
Akron | 5fd2d8e | 2017-06-19 15:29:39 +0200 | [diff] [blame^] | 50 | '--output' => $output, |
| 51 | '--cache' => $cache |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 52 | ); |
| 53 | |
| 54 | like($call, qr!config!, 'Call string'); |
| 55 | |
| 56 | my $stdout = combined_from(sub { system($call) }); |
| 57 | |
| 58 | like($stdout, qr!Reading config from!, 'Config'); |
| 59 | |
| 60 | # Processed using gzip |
| 61 | like($stdout, qr!Processed .+?WPD15-A00-00081\.json\.gz!, 'Gzip'); |
| 62 | |
| 63 | # Check log level |
| 64 | like($stdout, qr!Unable to parse KorAP::XML::Annotation::Glemm::Morpho!, 'Check log level'); |
| 65 | |
| 66 | # Check wildcard input |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 67 | like($stdout, qr!Input is .+?wpd15-single\.zip,.+?wpd15-single\.malt\.zip,.+?wpd15-single\.corenlp\.zip,.+?wpd15-single\.opennlp\.zip,.+?wpd15-single\.mdparser\.zip,.+?wpd15-single\.tree_tagger\.zip!is, 'Wildcards'); |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 68 | |
| 69 | like($stdout, qr!Run using \d+ jobs on \d+ cores!, 'Jobs'); |
| 70 | |
| 71 | done_testing; |
| 72 | __END__ |