1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
package t::test;
use strict;
use warnings;
use utf8;
use Path::Class;
use lib file(__FILE__)->dir->parent->subdir('lib')->stringify;
use FindBin;
use File::Spec::Functions qw/catfile/;
use File::Temp qw(tempdir);
use File::Copy::Recursive;
# use Exporter::Lite ();
our @EXPORT = qw(
create_hello_world
);
sub import {
my ($class) = @_;
strict->import;
utf8->import;
warnings->import;
my ($package, $file) = caller;
my $code = qq[
package $package;
use strict;
use warnings;
use utf8;
use parent qw(Test::Class);
use Test::More;
use Test::Fatal;
use Test::Deep;
use Test::Mock::Guard;
use Path::Class;
END { $package->runtests }
];
eval $code;
die $@ if $@;
}
sub prepare_test_code {
my ($name) = @_;
my $base_directory = catfile($FindBin::Bin, 'data', $name);
my $tmpdir = tempdir;
unless (-d $base_directory) {
die "$name is not defined";
}
File::Copy::Recursive::dircopy($base_directory, $tmpdir);
$tmpdir;
}
sub prepare_as_git_repository {
my ($directory) = @_;
# TODO: replace with https://metacpan.org/pod/Test::Git
system "cd $directory && git init --quiet && git config user.email 'test at example.com' && git config user.name 'Tester' && git add * && git commit --quiet -m 'init'";
}
1;
|