Akron | 486f9ab | 2017-04-22 23:25:19 +0200 | [diff] [blame] | 1 | #/usr/bin/env perl |
| 2 | use strict; |
| 3 | use warnings; |
| 4 | use File::Basename 'dirname'; |
| 5 | use File::Spec::Functions qw/catdir catfile/; |
| 6 | use File::Temp qw/tempdir/; |
| 7 | use Mojo::File; |
| 8 | use Mojo::Util qw/quote/; |
| 9 | use Mojo::JSON qw/decode_json/; |
| 10 | use IO::Uncompress::Gunzip; |
| 11 | use Test::More; |
| 12 | use Test::Output qw/:stdout :stderr :functions/; |
| 13 | use Data::Dumper; |
| 14 | use KorAP::XML::Archive; |
| 15 | use utf8; |
| 16 | |
| 17 | my $f = dirname(__FILE__); |
| 18 | my $script = catfile($f, '..', '..', 'script', 'korapxml2krill'); |
| 19 | |
| 20 | my $call = join( |
| 21 | ' ', |
| 22 | 'perl', $script, |
| 23 | 'archive' |
| 24 | ); |
| 25 | |
| 26 | unless (KorAP::XML::Archive::test_unzip) { |
| 27 | plan skip_all => 'unzip not found'; |
| 28 | }; |
| 29 | |
| 30 | # Test without parameters |
| 31 | stdout_like( |
| 32 | sub { |
| 33 | system($call); |
| 34 | }, |
| 35 | qr!archive.+?\$ korapxml2krill!s, |
| 36 | $call |
| 37 | ); |
| 38 | |
| 39 | my $input = catfile($f, '..', 'corpus', 'archive.zip'); |
| 40 | ok(-f $input, 'Input archive found'); |
| 41 | |
| 42 | my $output = File::Temp->new; |
| 43 | |
| 44 | ok(-f $output, 'Output directory exists'); |
| 45 | |
| 46 | my $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 |
| 59 | my $combined = combined_from( sub { system($call) }); |
| 60 | |
Akron | da3097e | 2017-04-23 19:53:57 +0200 | [diff] [blame^] | 61 | like($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'); |
Akron | 486f9ab | 2017-04-22 23:25:19 +0200 | [diff] [blame] | 62 | |
Akron | da3097e | 2017-04-23 19:53:57 +0200 | [diff] [blame^] | 63 | like($combined, qr!Writing to file .+?\.tar!, 'Write out'); |
| 64 | like($combined, qr!Wrote to tar archive!, 'Write out'); |
Akron | 486f9ab | 2017-04-22 23:25:19 +0200 | [diff] [blame] | 65 | |
| 66 | |
| 67 | |
| 68 | done_testing; |
| 69 | __END__ |