Support --quiet flag (fixes #15)
Change-Id: I2675131953f1ac455c85862278df9a702ad5d523
diff --git a/t/annotation/mdp_dependency.t b/t/annotation/mdp_dependency.t
index f7f29a2..d5bdd97 100644
--- a/t/annotation/mdp_dependency.t
+++ b/t/annotation/mdp_dependency.t
@@ -33,7 +33,7 @@
my $dir = tempdir();
my $f_path = 'WPD15/A00/00081';
-$archive->extract_sigle([$f_path], $dir);
+$archive->extract_sigle(0, [$f_path], $dir);
ok(my $doc = KorAP::XML::Krill->new( path => $dir . '/' . $f_path));
diff --git a/t/archive.t b/t/archive.t
index 71bedce..77026d7 100644
--- a/t/archive.t
+++ b/t/archive.t
@@ -6,6 +6,7 @@
use File::Basename 'dirname';
use File::Spec::Functions qw/catfile catdir/;
use File::Temp qw/tempdir/;
+use Test::Output qw/:stdout :stderr :functions/;
use KorAP::XML::Archive;
@@ -36,7 +37,12 @@
{
local $SIG{__WARN__} = sub {};
- ok($archive->extract_sigle(['TEST/BSP/8'], $dir), 'Wrong path');
+ my $stdout = stdout_from(
+ sub {
+ ok($archive->extract_sigle(0, ['TEST/BSP/8'], $dir), 'Wrong path');
+ }
+ );
+ like($stdout, qr!Extract unzip!);
};
ok(-d catdir($dir, 'TEST'), 'Test corpus directory exists');
@@ -64,9 +70,15 @@
{
local $SIG{__WARN__} = sub {};
- ok($archive->extract_sigle(['REI/RB*', 'REI/BNG/00071'], $dir), 'Fine');
+ my $stdout = stdout_from(
+ sub {
+ ok($archive->extract_sigle(1, ['REI/RB*', 'REI/BNG/00071'], $dir), 'Fine');
+ }
+ );
+ is($stdout, '');
};
+
ok(-d catdir($dir, 'REI'), 'Test corpus directory exists');
ok(-d catdir($dir, 'REI','BNG'), 'Test corpus directory exists');
ok(-d catdir($dir, 'REI','BNG','00071'), 'Test corpus directory exists');
diff --git a/t/multiple_archives.t b/t/multiple_archives.t
index 7e2a0e7..e57bf1e 100644
--- a/t/multiple_archives.t
+++ b/t/multiple_archives.t
@@ -60,7 +60,7 @@
my $dir = tempdir(CLEANUP => 1);
{
local $SIG{__WARN__} = sub {};
- ok($archive->extract_sigle([$list[0]], $dir), 'Wrong path');
+ ok($archive->extract_sigle(0, [$list[0]], $dir), 'Wrong path');
};
ok(-d catdir($dir, 'WPD15'), 'Test corpus directory exists');
diff --git a/t/script/archive.t b/t/script/archive.t
index 1bb4f92..0f57183 100644
--- a/t/script/archive.t
+++ b/t/script/archive.t
@@ -238,6 +238,30 @@
ok(-f $json, 'Json file exists');
+# Test quiet
+
+# my $input = catfile($f, '..', 'corpus', 'archive.zip');
+# ok(-f $input, 'Input archive found');
+
+$call = join(
+ ' ',
+ 'perl', $script,
+ 'archive',
+ '--input' => '' . $input,
+ '--quiet',
+ '--output' => $output,
+ '--sigle' => 'TEST/BSP/2',
+ '--sigle' => 'TEST/BSP/5',
+ '-t' => 'Base#tokens_aggr',
+ '-m' => 'Sgbr'
+);
+
+{
+ local $SIG{__WARN__} = sub {};
+ my $out = stdout_from(sub { system($call); });
+
+ is($out, "\n", $call);
+};
done_testing;
__END__