Akron | 414ec95 | 2020-08-03 15:48:43 +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/:POSIX/; |
| 7 | use Mojo::File; |
| 8 | use Mojo::JSON qw/decode_json/; |
| 9 | use IO::Uncompress::Gunzip; |
| 10 | use Test::More; |
| 11 | use Test::Output; |
| 12 | use Data::Dumper; |
| 13 | use utf8; |
| 14 | |
| 15 | if ($ENV{SKIP_SCRIPT} || $ENV{SKIP_REAL}) { |
| 16 | plan skip_all => 'Skip script/real tests'; |
| 17 | }; |
| 18 | |
| 19 | |
| 20 | my $output = tmpnam(); |
| 21 | my $cache = tmpnam(); |
| 22 | |
| 23 | my $f = dirname(__FILE__); |
| 24 | my $script = catfile($f, '..', '..', '..', 'script', 'korapxml2krill'); |
| 25 | |
| 26 | # AGA with base info |
| 27 | my $input = catdir($f, '..', 'corpus', 'GOE2', 'AGA', '03828'); |
| 28 | ok(-d $input, 'Input directory found'); |
| 29 | |
| 30 | ok(!-f $output, 'Output does not exist'); |
| 31 | |
| 32 | my $call = join( |
| 33 | ' ', |
| 34 | 'perl', $script, |
| 35 | '--input' => $input, |
| 36 | '--output' => $output, |
| 37 | '--cache' => $cache, |
| 38 | '-t' => 'base#tokens_aggr', |
| 39 | '-bs' => 'DeReKo#Structure', |
| 40 | '-bp' => 'DeReKo#Structure', |
| 41 | '-bpb' => 'DeReKo#Structure', |
| 42 | '-l' => 'INFO' |
| 43 | ); |
| 44 | |
| 45 | stderr_like( |
| 46 | sub { |
| 47 | system($call); |
| 48 | }, |
| 49 | qr!The code took!, |
| 50 | $call |
| 51 | ); |
| 52 | ok(-f $output, 'Output does exist'); |
| 53 | ok((my $file = Mojo::File->new($output)->slurp), 'Slurp data'); |
| 54 | ok((my $json = decode_json $file), 'decode json'); |
| 55 | |
| 56 | is($json->{title}, 'Autobiographische Einzelheiten', 'title'); |
| 57 | is($json->{data}->{stream}->[0]->[-1], '~:base/s:pb$<i>529<i>0', 'Pagebreak annotation'); |
| 58 | |
| 59 | done_testing; |