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