1 # (X)Emacs mode: -*- cperl -*-
7 test - tools for helping in test suites (not including running externalprograms).
11 use FindBin 1.42 qw( $Bin );
12 use Test 1.13 qw( ok plan );
14 BEGIN { unshift @INC, $Bin };
16 use test qw( evcheck runcheck );
25 open my $fh, '>', 'foo';
27 for 'Bulgaria', 'Cholet';
29 }, 'write foo'), 1, 'write foo';
33 This package provides some variables, and sets up an environment, for test
34 scripts, such as those used in F<t/>.
36 This package does not including running external programs; that is provided by
37 C<test2.pm>. This is so that suites not needing that can include only
38 test.pm, and so not require the presence of C<IPC::Run>.
40 Setting up the environment includes:
44 =item Prepending F<blib/script> onto the path
46 =item Pushing the module F<lib/> dir onto the @INC var
48 For internal C<use> calls.
50 =item Changing directory to a temporary directory
52 To avoid cluttering the local dir, and/or allowing the local directory
53 structure to affect matters.
55 =item Cleaning up the temporary directory afterwards
57 Unless TEST_DEBUG is set in the environment.
63 # ----------------------------------------------------------------------------
65 # Pragmas -----------------------------
69 use vars qw( @EXPORT_OK );
71 # Inheritance -------------------------
73 use base qw( Exporter );
77 The following symbols are exported upon request:
87 @EXPORT_OK = qw( evcheck );
89 # Utility -----------------------------
91 use Carp qw( carp croak );
92 use Cwd 2.01 qw( cwd );
94 use Fatal 1.02 qw( close open seek sysopen unlink );
95 use Fcntl 1.03 qw( :DEFAULT );
96 use File::Basename qw( basename );
97 use File::Path 1.0401 qw( mkpath rmtree );
98 use File::Spec 0.6 qw( );
99 use File::Temp qw( tempdir );
100 use FindBin 1.42 qw( $Bin );
101 #use POSIX 1.02 qw( );
102 use Test 1.122 qw( ok skip );
104 # ----------------------------------------------------------------------------
106 # -------------------------------------
108 # -------------------------------------
110 use constant BUILD_SCRIPT_DIR => => File::Spec->catdir( $Bin, File::Spec->updir, qw( blib script ) );
112 # -------------------------------------
114 # -------------------------------------
116 $PATH = join ':', BUILD_SCRIPT_DIR, split /:/, $PATH;
120 # -------------------------------------
122 # -------------------------------------
126 Eval code, return status
140 Name to use in error messages
150 1 if eval was okay, 0 if not.
159 my ($code, $name) = @_;
167 carp "Code $name failed: $@\n"
175 # -------------------------------------
177 # defined further up to use in constants
179 # ----------------------------------------------------------------------------
189 =head1 REPORTING BUGS
195 Martyn J. Pearce C<fluffy@cpan.org>
199 Copyright (c) 2001, 2002, 2004 Martyn J. Pearce. This program is free
200 software; you can redistribute it and/or modify it under the same terms as
209 1; # keep require happy.