-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtil.pm
47 lines (41 loc) · 1.13 KB
/
Util.pm
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
package t::Util;
BEGIN {
unless ($ENV{PLACK_ENV}) {
$ENV{PLACK_ENV} = 'test';
}
if ($ENV{PLACK_ENV} eq 'deployment') {
die "Do not run a test script on deployment environment";
}
}
use File::Spec;
use File::Basename;
use lib File::Spec->rel2abs(File::Spec->catdir(dirname(__FILE__), '..', 'extlib', 'lib', 'perl5'));
use lib File::Spec->rel2abs(File::Spec->catdir(dirname(__FILE__), '..', 'lib'));
use parent qw/Exporter/;
use Test::More 0.98;
our @EXPORT = qw(slurp);
{
# utf8 hack.
binmode Test::More->builder->$_, ":utf8" for qw/output failure_output todo_output/;
no warnings 'redefine';
my $code = \&Test::Builder::child;
*Test::Builder::child = sub {
my $builder = $code->(@_);
binmode $builder->output, ":utf8";
binmode $builder->failure_output, ":utf8";
binmode $builder->todo_output, ":utf8";
return $builder;
};
}
sub slurp {
my $fname = shift;
open my $fh, '<:encoding(UTF-8)', $fname or die "$fname: $!";
do { local $/; <$fh> };
}
# initialize database
use Tonkotsu;
{
my $c = Tonkotsu->new();
$c->setup();
}
1;