Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Chris Fields
committed
Jan 18, 2012
1 parent
88699db
commit f8e2408
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- Komodo Project File - DO NOT EDIT --> | ||
<project id="07a1c0fe-573a-6644-bfaf-a6c919e09a69" kpf_version="5" name="eutils.komodoproject"> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package TestHelper; | ||
use strict; | ||
use warnings; | ||
|
||
require Exporter; | ||
our @ISA = qw(Exporter); | ||
our @EXPORT_OK = qw(test_output_file test_input_file); | ||
|
||
=head2 test_output_file | ||
Title : test_output_file | ||
Usage : my $output_file = test_output_file(); | ||
Function: Get the full path of a file suitable for writing to. | ||
When your test script ends, the file will be automatically deleted. | ||
Returns : string (file path) | ||
Args : none | ||
=cut | ||
|
||
sub test_output_file { | ||
die "test_output_file takes no args\n" if @_; | ||
my $tmp = File::Temp->new(); | ||
close($tmp); # Windows needs this | ||
return $tmp->filename; | ||
} | ||
|
||
=head2 test_output_dir | ||
Title : test_output_dir | ||
Usage : my $output_dir = test_output_dir(); | ||
Function: Get the full path of a directory suitable for storing temporary files | ||
in. | ||
When your test script ends, the directory and its contents will be | ||
automatically deleted. | ||
Returns : string (path) | ||
Args : none | ||
=cut | ||
|
||
sub test_output_dir { | ||
die "test_output_dir takes no args\n" if @_; | ||
|
||
return tempdir(CLEANUP => 1); | ||
} | ||
|
||
=head2 test_input_file | ||
Title : test_input_file | ||
Usage : my $input_file = test_input_file(); | ||
Function: Get the path of a desired input file stored in the standard location | ||
(currently t/data), but correct for all platforms. | ||
Returns : string (file path) | ||
Args : list of strings (ie. at least the input filename, preceded by the | ||
names of any subdirectories within t/data) | ||
eg. for the file t/data/in.file pass 'in.file', for the file | ||
t/data/subdir/in.file, pass ('subdir', 'in.file') | ||
=cut | ||
|
||
sub test_input_file { | ||
return File::Spec->catfile('t', 'data', @_); | ||
} | ||
|
||
1; |