blob: 8acba8331a8cfe72824aa71d8c33cf2fe41d29b6 [file] [log] [blame]
Akron414ec952020-08-03 15:48:43 +02001#/usr/bin/env perl
2use strict;
3use warnings;
4use File::Basename 'dirname';
5use File::Spec::Functions qw/catdir catfile/;
6use File::Temp qw/:POSIX/;
7use Mojo::File;
8use Mojo::JSON qw/decode_json/;
9use IO::Uncompress::Gunzip;
10use Test::More;
11use Test::Output;
12use Data::Dumper;
13use utf8;
14
15if ($ENV{SKIP_SCRIPT} || $ENV{SKIP_REAL}) {
16 plan skip_all => 'Skip script/real tests';
17};
18
19
20my $output = tmpnam();
21my $cache = tmpnam();
22
23my $f = dirname(__FILE__);
24my $script = catfile($f, '..', '..', '..', 'script', 'korapxml2krill');
25
26# AGA with base info
27my $input = catdir($f, '..', 'corpus', 'GOE2', 'AGA', '03828');
28ok(-d $input, 'Input directory found');
29
30ok(!-f $output, 'Output does not exist');
31
32my $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
45stderr_like(
46 sub {
47 system($call);
48 },
49 qr!The code took!,
50 $call
51);
52ok(-f $output, 'Output does exist');
53ok((my $file = Mojo::File->new($output)->slurp), 'Slurp data');
54ok((my $json = decode_json $file), 'decode json');
55
56is($json->{title}, 'Autobiographische Einzelheiten', 'title');
57is($json->{data}->{stream}->[0]->[-1], '~:base/s:pb$<i>529<i>0', 'Pagebreak annotation');
58
59done_testing;