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