Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated t/compile* tests to handle the stupidity that is windows\path…

…\separators

git-svn-id: svn://svn.tt2.org/tt/Template2/trunk@1236 d5a88997-0a34-4036-9ed2-92fb5d660d91
  • Loading branch information...
commit d884f67981dce057e67c610d5380356ac9a40725 1 parent a654129
Andy Wardley authored
17 t/compile1.t
View
@@ -18,20 +18,26 @@
#========================================================================
use strict;
+use warnings;
use lib qw( ./lib ../lib );
use Template::Test;
-$^W = 1;
+use File::Spec;
# declare extra tests to follow test_expect();
$Template::Test::EXTRA = 2;
# script may be being run in distribution root or 't' directory
-my $dir = -d 't' ? 't/test/src' : 'test/src';
+my @dir = -d 't' ? qw(t test src) : qw(test src);
+my $dir = File::Spec->catfile(@dir);
+my $zero = File::Spec->catfile(@dir, 'divisionbyzero');
my $ttcfg = {
POST_CHOMP => 1,
INCLUDE_PATH => $dir,
- COMPILE_EXT => '.ttc',
- EVAL_PERL => 1,
+ COMPILE_EXT => '.ttc',
+ EVAL_PERL => 1,
+ CONSTANTS => {
+ zero => $zero,
+ },
};
# delete any existing files
@@ -80,4 +86,5 @@ This is the baz file, a:
[%- # first pass, writes the compiled code to cache -%]
[% INCLUDE divisionbyzero -%]
-- expect --
-undef error - Illegal division by zero at t/test/src/divisionbyzero line 1.
+-- process --
+undef error - Illegal division by zero at [% constants.zero %] line 1.
13 t/compile2.t
View
@@ -20,14 +20,20 @@
use strict;
use lib qw( ./lib ../lib );
use Template::Test;
+use File::Spec;
$^W = 1;
# script may be being run in distribution root or 't' directory
-my $dir = -d 't' ? 't/test/src' : 'test/src';
+my @dir = -d 't' ? qw(t test src) : qw(test src);
+my $dir = File::Spec->catfile(@dir);
+my $zero = File::Spec->catfile(@dir, 'divisionbyzero');
my $ttcfg = {
POST_CHOMP => 1,
INCLUDE_PATH => $dir,
- COMPILE_EXT => '.ttc',
+ COMPILE_EXT => '.ttc',
+ CONSTANTS => {
+ zero => $zero,
+ },
};
my $compiled = "$dir/foo.ttc";
@@ -94,4 +100,5 @@ This is the footer, author: billg, version: 6.66
[%- # second pass, reads the compiled code from cache -%]
[% INCLUDE divisionbyzero -%]
-- expect --
-undef error - Illegal division by zero at t/test/src/divisionbyzero line 1, <DATA> chunk 1.
+-- process --
+undef error - Illegal division by zero at [% constants.zero %] line 1, <DATA> chunk 1.
6 t/compile3.t
View
@@ -18,10 +18,11 @@
#========================================================================
use strict;
+use warnings;
use lib qw( ./lib ../lib );
use Template::Test;
use File::Copy;
-$^W = 1;
+use File::Spec;
#ntests(13);
@@ -30,7 +31,8 @@ $Template::Test::EXTRA = 1;
#$Template::Parser::DEBUG = 1;
# script may be being run in distribution root or 't' directory
-my $dir = -d 't' ? 't/test/src' : 'test/src';
+my @dir = -d 't' ? qw(t test src) : qw(test src);
+my $dir = File::Spec->catfile(@dir);
my $ttcfg = {
POST_CHOMP => 1,
INCLUDE_PATH => $dir,
12 t/compile4.t
View
@@ -30,8 +30,11 @@ $^W = 1;
#$Template::Test::EXTRA = 2;
# script may be being run in distribution root or 't' directory
-my $dir = abs_path( -d 't' ? 't/test' : 'test' );
-my $cdir = abs_path("$dir/tmp") . "/cache";
+my @dir = -d 't' ? qw(t test) : qw(test);
+my $dir = abs_path( File::Spec->catfile(@dir) );
+my $tdir = abs_path( File::Spec->catfile(@dir, 'tmp'));
+my $cdir = File::Spec->catfile($tdir, 'cache');
+my $zero = File::Spec->catfile($dir, qw(src divisionbyzero));
my $ttcfg = {
POST_CHOMP => 1,
INCLUDE_PATH => "$dir/src",
@@ -39,7 +42,8 @@ my $ttcfg = {
COMPILE_EXT => '.ttc',
ABSOLUTE => 1,
CONSTANTS => {
- dir => $dir,
+ dir => $dir,
+ zero => $zero,
},
};
@@ -88,4 +92,4 @@ This is the blam file
[% INCLUDE divisionbyzero -%]
-- expect --
-- process --
-undef error - Illegal division by zero at [% constants.dir %]/src/divisionbyzero line 1.
+undef error - Illegal division by zero at [% constants.zero %] line 1.
28 t/compile5.t
View
@@ -19,15 +19,22 @@
#========================================================================
use strict;
+use warnings;
use lib qw( ./lib ../lib );
use Template::Test;
use Cwd qw( abs_path );
use File::Path;
-$^W = 1;
+my @dir = -d 't' ? qw(t test) : qw(test);
+my $dir = abs_path( File::Spec->catfile(@dir) );
+my $tdir = abs_path( File::Spec->catfile(@dir, 'tmp'));
+my $cdir = File::Spec->catfile($tdir, 'cache');
+my $zero = File::Spec->catfile($dir, qw(src divisionbyzero));
+print "zero: $zero\n";
-my $dir = abs_path( -d 't' ? 't/test' : 'test' );
-my $cdir = abs_path("$dir/tmp") . "/cache";
+#my $dir = abs_path( -d 't' ? 't/test' : 'test' );
+#my $cdir = abs_path("$dir/tmp") . "/cache";
+#my $zero = "$cdir/src/divisionbyzero";
my $ttcfg = {
POST_CHOMP => 1,
INCLUDE_PATH => "$dir/src",
@@ -35,10 +42,13 @@ my $ttcfg = {
COMPILE_EXT => '.ttc',
ABSOLUTE => 1,
CONSTANTS => {
- dir => $dir,
+ dir => $dir,
+ zero => $zero,
},
};
+#print "
+
# check compiled template files exist
my $fixdir = $dir;
$fixdir =~ s[:][]g if $^O eq 'MSWin32';
@@ -46,9 +56,9 @@ my ($foo, $bar, $blam) = map { "$cdir/$fixdir/src/$_.ttc" }
qw( foo complex blam );
$blam =~ s[/+][/]g;
-ok( -f $foo );
-ok( -f $bar );
-ok( -f $blam );
+ok( -f $foo, 'cached foo' );
+ok( -f $bar, 'cached bar' );
+ok( -f $blam, 'cached blam' );
# we're going to hack on the compiled 'foo' file to change some key text.
# this way we can tell that the template was loaded from the compiled
@@ -88,6 +98,8 @@ utime( @blam_times, $blam );
test_expect(\*DATA, $ttcfg, { root => abs_path($dir) } );
+exit;
+
# cleanup cache directory
rmtree($cdir) if -d $cdir;
@@ -116,4 +128,4 @@ This is the wam-bam file
[% INCLUDE divisionbyzero -%]
-- expect --
-- process --
-undef error - Illegal division by zero at [% constants.dir %]/src/divisionbyzero line 1, <DATA> chunk 1.
+undef error - Illegal division by zero at [% constants.zero %] line 1, <DATA> chunk 1.
6 t/zz-pmv.t
View
@@ -15,6 +15,10 @@ my @MODULES = (
# Don't run tests for installs
use Test::More;
+unless (grep(/--abw/, @ARGV)) {
+ plan( skip_all => 'Internal test for abw, add the --abw flag to run' );
+}
+
unless ( $ENV{AUTOMATED_TESTING} or $ENV{RELEASE_TESTING} ) {
plan( skip_all => "Author tests not required for installation" );
}
@@ -29,4 +33,4 @@ foreach my $MODULE ( @MODULES ) {
}
}
-all_minimum_version_from_metayml_ok();
+all_minimum_version_ok(5.006);
Please sign in to comment.
Something went wrong with that request. Please try again.