Debian Codegraph @

cassandane/Cassandane/Tiny/Loader.pm

raw
1 package Cassandane::Tiny::Loader;
2 use strict;
3 use warnings;
4
5 use Carp ();
6
7 our $RELOADED;
8
9 sub import {
10 my ($class, $path) = @_;
11
12 my $into = caller;
13
14 unless (-d $path) {
15 Carp::confess(qq{can't find path "$path" for loading tests; Cassandane expects to be run from the ./cyrus-imapd/cassandane directory"});
16 }
17
18 my @tests = `find $path -type f \! -name "*~" \! -name ".*"`;
19
20 if ($?) {
21 Carp::confess("couldn't use find(1) to find tiny test files in $path");
22 }
23
24 chomp @tests;
25
26 for my $test (sort @tests) {
27 local $RELOADED;
28
29 unless (eval "package $into; do qq{$test}; die \$@ if \$@; 1") {
30 Carp::confess("tried to load $test but it failed: $@");
31 }
32
33 unless ($RELOADED) {
34 Carp::confess("tried to load $test but it did not 'use Cassandane::Tiny'");
35 }
36 }
37
38 return;
39 }
40
41 1;