1 package VPIT::TestHelpers;
7 load_or_skip => \&load_or_skip,
8 skip_all => \&skip_all,
13 while (my ($name, $code) = each %exports) {
15 *{$pkg.'::'.$name} = $code;
22 Test::More::plan(skip_all => $msg);
27 Test::More::diag($_) for @_;
34 my ($pkg, $ver, $imports, $desc) = @_;
35 my $spec = $ver && $ver !~ /^[0._]*$/ ? "$pkg $ver" : $pkg;
37 if (eval "use $spec (); 1") {
38 $ver = do { no strict 'refs'; ${"${pkg}::VERSION"} };
39 $ver = 'undef' unless defined $ver;
41 my @imports = @$imports;
42 my $caller = (caller 0)[0];
44 my $res = eval <<"IMPORTER";
47 BEGIN { \$pkg->import(\@imports) }
50 skip_all "Could not import '@imports' from $pkg $ver: $@" unless $res;
52 diag "Using $pkg $ver";
54 skip_all "$spec $desc";
58 package VPIT::TestHelpers::Guard;
61 my ($class, $code) = @_;
63 bless { code => $code }, $class;
66 sub DESTROY { $_[0]->{code}->() }