Permalink
Browse files

Get tests passing again and use tempdir() correctly

  • Loading branch information...
1 parent 4bf3f89 commit 6f0e0a6be87081c749632621e7a9ff4fd0d86456 @leto leto committed Nov 21, 2011
Showing with 12 additions and 4 deletions.
  1. +1 −1 bin/new_parrot_language.pl
  2. +11 −3 lib/App/Parrot/Create.pm
@@ -162,7 +162,7 @@ sub start_new_file {
mkpath( [ $filedir ], 0, 0777 );
}
print "creating $filepath\n";
- open $fh, '>', $filepath;
+ open $fh, '>', $filepath or die $!;
return;
}
View
@@ -1,6 +1,10 @@
package App::Parrot::Create;
use Dancer ':syntax';
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
+use File::Temp qw/tempfile tempdir/;
+use File::Spec::Functions;
+use File::Path qw/make_path/;
+use autodie qw/:all/;
our $VERSION = '0.1';
@@ -13,17 +17,21 @@ post '/submit' => sub {
$name =~ s/[^A-z]*//g;
- my $time = time;
- my $tmp_base = "/tmp/app-parrot-create";
+ my $time = time;
+ my $tmp_base = tempdir( "app-parrot-create-XXXXXXX", TMPDIR => 1,
+ # CLEANUP => 1
+ );
my $dir = "$tmp_base/$time/$name";
+ debug("Going to run bin/new_parrot_language.pl $name $dir");
my @args = ($^X,"bin/new_parrot_language.pl",$name, $dir);
system @args;
my $zip = Archive::Zip->new();
my $dir_member = $zip->addDirectory("$dir/");
- unless ( $zip->writeToFileNamed("$dir.zip") == AZ_OK ) {
+ debug("Going to write a zip file to $dir.zip");
+ unless ( $zip->writeToFileNamed("/tmp/$time-$name.zip") == AZ_OK ) {
die 'write error';
}

0 comments on commit 6f0e0a6

Please sign in to comment.