blob: 00e5559a841ac348a17d9d114d9d0cc736c7da01 [file] [log] [blame]
Akron63f20d42017-04-10 23:40:29 +02001use strict;
2use warnings;
3use Test::More;
Akronbd3adda2017-04-11 15:00:55 +02004use Test::Output qw/stdout_from/;
Akron63f20d42017-04-10 23:40:29 +02005use File::Basename 'dirname';
6use File::Spec::Functions qw/catdir catfile/;
Akron5fd2d8e2017-06-19 15:29:39 +02007use File::Temp qw/:POSIX/;
Akron2d401662021-03-17 11:32:18 +01008use KorAP::XML::Archive;
Akron63f20d42017-04-10 23:40:29 +02009
Akronfab17d32020-07-31 14:38:29 +020010if ($ENV{SKIP_SCRIPT}) {
11 plan skip_all => 'Skip script tests';
12};
13
Akron2d401662021-03-17 11:32:18 +010014unless (KorAP::XML::Archive::test_unzip) {
15 plan skip_all => 'unzip not found';
16};
17
Akron63f20d42017-04-10 23:40:29 +020018my $f = dirname(__FILE__);
19my $script = catfile($f, '..', '..', 'script', 'korapxml2krill');
20
Akronbd3adda2017-04-11 15:00:55 +020021my $input_base = catdir($f, '..', 'corpus');
Akron63f20d42017-04-10 23:40:29 +020022
23# Temporary output
24my $output = File::Temp->newdir(CLEANUP => 0);
25
Akron5fd2d8e2017-06-19 15:29:39 +020026my $cache = tmpnam();
27
Akron63f20d42017-04-10 23:40:29 +020028my $call = join(
29 ' ',
30 'perl', $script,
31 'serial',
Akronbd3adda2017-04-11 15:00:55 +020032 '-t' => 'Base#tokens_aggr',
33 '-i' => '"archive.zip"',
34 '-i' => '"archives/wpd15*.zip"',
Akron5fd2d8e2017-06-19 15:29:39 +020035 '--cache' => $cache,
Akron63f20d42017-04-10 23:40:29 +020036 '-ib' => $input_base,
Akronbd3adda2017-04-11 15:00:55 +020037 '-o' => $output
Akron63f20d42017-04-10 23:40:29 +020038);
39
40# Test without parameters
Akronbd3adda2017-04-11 15:00:55 +020041my $stdout = stdout_from(sub { system($call) });
Akron63f20d42017-04-10 23:40:29 +020042
Akronbd3adda2017-04-11 15:00:55 +020043like($stdout, qr!Start serial processing of .+?wpd15\*\.zip!, 'Processing');
44like($stdout, qr!Start serial processing .+?archive.zip!, 'Processing');
45
46like($stdout, qr!Processed .+?/archive/TEST-BSP-1\.json!, 'Archive file');
47like($stdout, qr!Processed .+?/archives-wpd15/WPD15-A00-00081\.json!, 'Archive file');
Akron63f20d42017-04-10 23:40:29 +020048
49done_testing;
50__END__