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")) { |
Marc Kupietz | d845583 | 2021-02-11 17:30:29 +0100 | [diff] [blame] | 27 | my $conllu_fname = $base_fname =~ s/(.*)\.zip/$1.conllu/r; |
Marc Kupietz | 628893e | 2021-02-12 15:50:29 +0100 | [diff] [blame^] | 28 | next if (!-e $conllu_fname); |
Marc Kupietz | d845583 | 2021-02-11 17:30:29 +0100 | [diff] [blame] | 29 | |
| 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); |
| 36 | script_runs([ 'script/korapxml2conllu', $base_fname ], "Runs with input"); |
| 37 | script_stdout_is $expected, "Converts $base_fname correctly"; |
| 38 | } |
| 39 | |
Marc Kupietz | bb739b0 | 2020-09-22 16:49:34 +0200 | [diff] [blame] | 40 | done_testing; |