blob: 1077bc04de1cec8500c343406ceb9b75b61110fd [file] [log] [blame]
Marc Kupietzbb739b02020-09-22 16:49:34 +02001use strict;
2use warnings;
3use Test::More;
4use Test::Script;
5
6script_runs([ 'script/korapxml2conllu', '-h' ], { exit => 255 });
7script_stderr_like "Description", "Can print help message";
8
9for my $morpho_fname (glob("t/data/*\.*\.zip")) {
10 my $base_fname = $morpho_fname =~ s/(.*)\..*\.zip/$1.zip/r;
11 die "cannot find $base_fname" if (!-e $base_fname);
12
Marc Kupietzd8455832021-02-11 17:30:29 +010013 my $conllu_fname = $base_fname =~ s/(.*)\.zip/$1.morpho.conllu/r;
Marc Kupietzbb739b02020-09-22 16:49:34 +020014 die "cannot find $conllu_fname" if (!-e $conllu_fname);
15
16 my $expected;
17 open(my $fh, '<', $conllu_fname) or die "cannot open file $conllu_fname"; {
18 local $/;
19 $expected = <$fh>;
20 }
21 close($fh);
Marc Kupietz13994d12021-02-12 17:25:36 +010022 script_runs([ 'script/korapxml2conllu', $morpho_fname ], "Runs korapxml2conllu with pos and lemma annotated input");
Marc Kupietzbb739b02020-09-22 16:49:34 +020023 script_stdout_is $expected, "Converts $morpho_fname correctly";
24}
Marc Kupietzd8455832021-02-11 17:30:29 +010025
26for my $base_fname (glob("t/data/*\.zip")) {
Marc Kupietzd8455832021-02-11 17:30:29 +010027 my $conllu_fname = $base_fname =~ s/(.*)\.zip/$1.conllu/r;
Marc Kupietz628893e2021-02-12 15:50:29 +010028 next if (!-e $conllu_fname);
Marc Kupietzd8455832021-02-11 17:30:29 +010029
30 my $expected;
31 open(my $fh, '<', $conllu_fname) or die "cannot open file $conllu_fname"; {
32 local $/;
33 $expected = <$fh>;
34 }
35 close($fh);
Marc Kupietz13994d12021-02-12 17:25:36 +010036 script_runs([ 'script/korapxml2conllu', $base_fname ], "Runs korapxml2conllu with base input");
37 script_stdout_is $expected, "Converts $base_fname correctly to CoNLL-U";
Marc Kupietzd8455832021-02-11 17:30:29 +010038}
39
Marc Kupietzbb739b02020-09-22 16:49:34 +020040done_testing;