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