Fixing behaviour for existing output directories

Change-Id: Ia60b88eec53a24d2344016cd9f1dc6626f90db16
diff --git a/script/korapxml2krill b/script/korapxml2krill
index 2ac6ddb..00e9216 100644
--- a/script/korapxml2krill
+++ b/script/korapxml2krill
@@ -367,7 +367,7 @@
     my $new_out = catdir($output, get_file_name_from_glob($_));
 
     # Create new path
-    unless (make_path($new_out)) {
+    if (make_path($new_out) == 0 && !-d $new_out) {
       $log->error("Can\'t create path $new_out");
       exit(0);
     };
@@ -525,8 +525,7 @@
 sub get_file_name_from_glob ($) {
   my $glob = shift;
   $glob =~ s/\.zip$//;          # Remove file extension
-  $glob =~ s{\/([^\/]+?)$}{$1}; # Remove path unix style
-  $glob =~ s{\\([^\\]+?)$}{$1}; # Remove path windows style
+  $glob =~ s![\\\/]!-!g;        # Transform paths
   $glob =~ s/[\*\?]//g;         # Remove arbitrary fills
   $glob =~ s/[\{\}\[\]]/-/g;    # Remove class and multiple brackets
   $glob =~ s/\-\-+/-/g;         # Remove sequences of binding characters
diff --git a/t/script/serial.t b/t/script/serial.t
index 70febc3..6fb883f 100644
--- a/t/script/serial.t
+++ b/t/script/serial.t
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Test::Output;
+use Test::Output qw/stdout_from/;
 use File::Basename 'dirname';
 use File::Spec::Functions qw/catdir catfile/;
 use File::Temp qw/tempdir/;
@@ -9,7 +9,7 @@
 my $f = dirname(__FILE__);
 my $script = catfile($f, '..', '..', 'script', 'korapxml2krill');
 
-my $input_base = catdir($f, '..', 'corpus', 'archives');
+my $input_base = catdir($f, '..', 'corpus');
 
 # Temporary output
 my $output = File::Temp->newdir(CLEANUP => 0);
@@ -18,22 +18,21 @@
   ' ',
   'perl', $script,
   'serial',
-  '-i' => '"ngafy*.zip"',
-  '-i' => '"tree*.zip"',
+  '-t' => 'Base#tokens_aggr',
+  '-i' => '"archive.zip"',
+  '-i' => '"archives/wpd15*.zip"',
   '-ib' => $input_base,
-  '-o' => $output,
-  '-l' => 'WARN'
+  '-o' => $output
 );
 
 # Test without parameters
-combined_like(
-  sub {
-    system($call);
-  },
-  qr!Start serial processing of ngafy\*\.zip!s,
-  $call
-);
+my $stdout = stdout_from(sub { system($call) });
 
+like($stdout, qr!Start serial processing of .+?wpd15\*\.zip!, 'Processing');
+like($stdout, qr!Start serial processing .+?archive.zip!, 'Processing');
+
+like($stdout, qr!Processed .+?/archive/TEST-BSP-1\.json!, 'Archive file');
+like($stdout, qr!Processed .+?/archives-wpd15/WPD15-A00-00081\.json!, 'Archive file');
 
 done_testing;
 __END__