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