blob: 666e2c5d1f9abbf2434482820dbb5541b39a20c7 [file] [log] [blame]
Akron486f9ab2017-04-22 23:25:19 +02001#/usr/bin/env perl
2use strict;
3use warnings;
4use File::Basename 'dirname';
5use File::Spec::Functions qw/catdir catfile/;
6use File::Temp qw/tempdir/;
7use Mojo::File;
8use Mojo::Util qw/quote/;
9use Mojo::JSON qw/decode_json/;
10use IO::Uncompress::Gunzip;
11use Test::More;
12use Test::Output qw/:stdout :stderr :functions/;
13use Data::Dumper;
14use KorAP::XML::Archive;
15use utf8;
16
17my $f = dirname(__FILE__);
18my $script = catfile($f, '..', '..', 'script', 'korapxml2krill');
19
20my $call = join(
21 ' ',
22 'perl', $script,
23 'archive'
24);
25
26unless (KorAP::XML::Archive::test_unzip) {
27 plan skip_all => 'unzip not found';
28};
29
30# Test without parameters
31stdout_like(
32 sub {
33 system($call);
34 },
35 qr!archive.+?\$ korapxml2krill!s,
36 $call
37);
38
39my $input = catfile($f, '..', 'corpus', 'archive.zip');
40ok(-f $input, 'Input archive found');
41
42my $output = File::Temp->new;
43
44ok(-f $output, 'Output directory exists');
45
46my $input_quotes = "'".catfile($f, '..', 'corpus', 'archives', 'wpd15*.zip') . "'";
47
48$call = join(
49 ' ',
50 'perl', $script,
51 'archive',
52 '--input' => $input_quotes,
53 '--output' => $output . '.tar',
54 '-t' => 'Base#tokens_aggr',
55 '--to-tar'
56);
57
58# Test without parameters
59my $combined = combined_from( sub { system($call) });
60
Akronda3097e2017-04-23 19:53:57 +020061like($combined, 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, 'Input is fine');
Akron486f9ab2017-04-22 23:25:19 +020062
Akronda3097e2017-04-23 19:53:57 +020063like($combined, qr!Writing to file .+?\.tar!, 'Write out');
64like($combined, qr!Wrote to tar archive!, 'Write out');
Akron486f9ab2017-04-22 23:25:19 +020065
66
67
68done_testing;
69__END__