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 | |
| 17 | print $fh <<CFG; |
| 18 | overwrite 0 |
| 19 | token OpenNLP#tokens |
| 20 | base-sentences DeReKo#Structure |
| 21 | base-paragraphs DeReKo#Structure |
| 22 | base-pagebreaks DeReKo#Structure |
| 23 | jobs -1 |
| 24 | meta I5 |
| 25 | gzip 1 |
| 26 | log DEBUG |
| 27 | CFG |
| 28 | |
| 29 | close($fh); |
| 30 | |
| 31 | # Path for script |
| 32 | my $script = catfile($f, '..', '..', 'script', 'korapxml2krill'); |
| 33 | |
| 34 | # Path for input |
| 35 | my $input = "'".catfile($f, '..', 'corpus', 'archives', 'wpd15*.zip') . "'"; |
| 36 | |
| 37 | # Temporary output |
| 38 | my $output = File::Temp->newdir(CLEANUP => 0); |
| 39 | |
| 40 | my $call = join( |
| 41 | ' ', |
| 42 | 'perl', $script, |
| 43 | 'archive', |
| 44 | '--config' => $cfg_file, |
| 45 | '--input' => $input, |
| 46 | '--output' => $output |
| 47 | ); |
| 48 | |
| 49 | like($call, qr!config!, 'Call string'); |
| 50 | |
| 51 | my $stdout = combined_from(sub { system($call) }); |
| 52 | |
| 53 | like($stdout, qr!Reading config from!, 'Config'); |
| 54 | |
| 55 | # Processed using gzip |
| 56 | like($stdout, qr!Processed .+?WPD15-A00-00081\.json\.gz!, 'Gzip'); |
| 57 | |
| 58 | # Check log level |
| 59 | like($stdout, qr!Unable to parse KorAP::XML::Annotation::Glemm::Morpho!, 'Check log level'); |
| 60 | |
| 61 | # Check wildcard input |
| 62 | like($stdout, qr!Input rewritten to .+?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'); |
| 63 | |
| 64 | like($stdout, qr!Run using \d+ jobs on \d+ cores!, 'Jobs'); |
| 65 | |
| 66 | done_testing; |
| 67 | __END__ |