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