Fixed output of version and help screens
Change-Id: I6e69b8ef83135f25cb0830d0fa212d84623f8a6d
diff --git a/Changes b/Changes
index 065409b..499883c 100644
--- a/Changes
+++ b/Changes
@@ -11,6 +11,7 @@
- Added script test.
- Fixed setting multiple annotations in
script.
+ - Fixed output of version and help messages.
0.17 2016-03-22
- Rewrite siglen to use slashes as separators.
diff --git a/MANIFEST b/MANIFEST
index 4529427..2496911 100755
--- a/MANIFEST
+++ b/MANIFEST
@@ -48,7 +48,6 @@
lib/KorAP/XML/Annotation/XIP/Sentences.pm
t/archive.t
t/batch_file.t
-t/script.t
t/meta.t
t/meta_caching.t
t/multiple_archives.t
@@ -99,6 +98,7 @@
t/sgbr/pos.t
t/sgbr/token.t
t/script/single.t
+t/script/usage.t
t/corpus/archive.zip
t/corpus/BZK/header.xml
t/corpus/GOE/header.xml
diff --git a/script/korapxml2krill b/script/korapxml2krill
index e668f07..250c68d 100644
--- a/script/korapxml2krill
+++ b/script/korapxml2krill
@@ -105,12 +105,14 @@
-sections => 'NAME|SYNOPSIS|ARGUMENTS|OPTIONS',
-verbose => 99,
-msg => $VERSION_MSG,
+ -output => '-'
);
},
'version|v' => sub {
pod2usage(
-verbose => 0,
- -msg => $VERSION_MSG
+ -msg => $VERSION_MSG,
+ -output => '-'
)
}
);
@@ -119,6 +121,7 @@
-sections => 'NAME|SYNOPSIS|ARGUMENTS|OPTIONS',
-verbose => 99,
-msg => $VERSION_MSG,
+ -output => '-',
-exit => 1
);
diff --git a/t/script/single.t b/t/script/single.t
index cda1b57..0aec043 100644
--- a/t/script/single.t
+++ b/t/script/single.t
@@ -13,13 +13,6 @@
my $f = dirname(__FILE__);
my $script = catfile($f, '..', '..', 'script', 'korapxml2krill');
-ok(-f $script, 'Script found');
-
-stdout_like(
- sub { system('perl', $script) },
- qr!Usage.+?korapxml2krill!s,
- 'Usage output'
-);
my $input = catdir($f, '..', 'annotation', 'corpus', 'doc', '0001');
ok(-d $input, 'Input directory found');
@@ -127,12 +120,42 @@
like($json->{data}->{text}, qr/^Zum letzten kulturellen/, 'Foundries');
is($json->{data}->{stream}->[0]->[0], '-:tokens$<i>20', 'Tokens');
-# Test overwrite!!!
+
+# Check overwrite
+$call = join(
+ ' ',
+ 'perl', $script,
+ '--input' => $input,
+ '--output' => $output,
+ '-t' => 'CoreNLP#Tokens',
+ '-s' => '#all',
+ '-a' => 'DeReKo#Structure',
+ '-a' => 'Mate#Dependency',
+ '-l' => 'DEBUG'
+);
+
+ok(-f $output, 'Output does exist');
+stderr_like(
+ sub {
+ system($call);
+ },
+ qr!already exists!,
+ $call
+);
+
+$call .= ' -w ';
+
+stderr_unlike(
+ sub {
+ system($call);
+ },
+ qr!already exists!,
+ $call
+);
+
+
# Test meta
# Test sigle!
-# Test help
-# Test version
-
done_testing;
__END__
diff --git a/t/script/usage.t b/t/script/usage.t
new file mode 100644
index 0000000..170eccb
--- /dev/null
+++ b/t/script/usage.t
@@ -0,0 +1,37 @@
+#/usr/bin/env perl
+use strict;
+use warnings;
+use File::Basename 'dirname';
+use File::Spec::Functions qw/catdir catfile/;
+use File::Temp qw/ :POSIX /;
+use Mojo::Util qw/slurp/;
+use Mojo::JSON qw/decode_json/;
+use IO::Uncompress::Gunzip;
+use Test::More;
+use Test::Output;
+use Data::Dumper;
+
+my $f = dirname(__FILE__);
+my $script = catfile($f, '..', '..', 'script', 'korapxml2krill');
+ok(-f $script, 'Script found');
+
+stdout_like(
+ sub { system('perl', $script) },
+ qr!Usage.+?korapxml2krill!s,
+ 'Usage output'
+);
+
+stdout_like(
+ sub { system('perl', $script, '--help') },
+ qr!Usage.+?korapxml2krill!s,
+ 'Usage output'
+);
+
+stdout_like(
+ sub { system('perl', $script, '--version') },
+ qr!Version \d+\.\d+!s,
+ 'Version output'
+);
+
+done_testing;
+__END__