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