Marc Kupietz | bb739b0 | 2020-09-22 16:49:34 +0200 | [diff] [blame] | 1 | use strict; |
| 2 | use warnings; |
| 3 | use Test::More; |
| 4 | use Test::Script; |
| 5 | |
| 6 | script_runs([ 'script/korapxml2conllu', '-h' ], { exit => 255 }); |
| 7 | script_stderr_like "Description", "Can print help message"; |
| 8 | |
| 9 | for 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 Kupietz | d845583 | 2021-02-11 17:30:29 +0100 | [diff] [blame] | 13 | my $conllu_fname = $base_fname =~ s/(.*)\.zip/$1.morpho.conllu/r; |
Marc Kupietz | bb739b0 | 2020-09-22 16:49:34 +0200 | [diff] [blame] | 14 | 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); |
| 22 | script_runs([ 'script/korapxml2conllu', $morpho_fname ], "Runs with input"); |
| 23 | script_stdout_is $expected, "Converts $morpho_fname correctly"; |
| 24 | } |
Marc Kupietz | d845583 | 2021-02-11 17:30:29 +0100 | [diff] [blame] | 25 | |
| 26 | for my $base_fname (glob("t/data/*\.zip")) { |
| 27 | next if($base_fname = ~ /\..*}./); # skip tagged files like goe.tree_tagger.zip |
| 28 | |
| 29 | my $conllu_fname = $base_fname =~ s/(.*)\.zip/$1.conllu/r; |
| 30 | die "cannot find $conllu_fname" if (!-e $conllu_fname); |
| 31 | |
| 32 | my $expected; |
| 33 | open(my $fh, '<', $conllu_fname) or die "cannot open file $conllu_fname"; { |
| 34 | local $/; |
| 35 | $expected = <$fh>; |
| 36 | } |
| 37 | close($fh); |
| 38 | script_runs([ 'script/korapxml2conllu', $base_fname ], "Runs with input"); |
| 39 | script_stdout_is $expected, "Converts $base_fname correctly"; |
| 40 | } |
| 41 | |
Marc Kupietz | bb739b0 | 2020-09-22 16:49:34 +0200 | [diff] [blame] | 42 | done_testing; |