From 5f3663964d3883856fdd2699e5163a0cbc71e5c5 Mon Sep 17 00:00:00 2001 From: Gavin Carr Date: Fri, 5 Oct 2007 12:23:23 +0000 Subject: [PATCH] Add test drivers as files, since symlinks don't work. --- t/{driver => 01_templates.t} | 0 t/02_smoketest.t | 67 ++++++++++++++++++++++++++++++++++++ t/03_permalinks.t | 67 ++++++++++++++++++++++++++++++++++++ t/04_plugin_list.t | 67 ++++++++++++++++++++++++++++++++++++ 4 files changed, 201 insertions(+) rename t/{driver => 01_templates.t} (100%) create mode 100644 t/02_smoketest.t create mode 100644 t/03_permalinks.t create mode 100644 t/04_plugin_list.t diff --git a/t/driver b/t/01_templates.t similarity index 100% rename from t/driver rename to t/01_templates.t diff --git a/t/02_smoketest.t b/t/02_smoketest.t new file mode 100644 index 0000000..f176604 --- /dev/null +++ b/t/02_smoketest.t @@ -0,0 +1,67 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More qw( no_plan ); + +use Cwd; +use YAML; +use IO::File; +use File::Find; +use File::Copy; +#use File::Touch; +use File::Basename; +use Test::Differences; + +my $test = basename($0); +$test =~ s/^\d+_?//; +$test =~ s/\.t$//; + +my $testdir = $test; +$testdir = "t/$testdir" if -d "t/$testdir"; +$testdir = cwd . "/$testdir"; +die "cannot find root '$testdir'" unless -d $testdir; + +my $blosxom_config_dir = "$testdir/config"; +die "cannot find blosxom config dir '$blosxom_config_dir'" unless -d $blosxom_config_dir; +$ENV{BLOSXOM_CONFIG_DIR} = $blosxom_config_dir; + +my $blosxom_cgi = "$testdir/../../blosxom.cgi"; +die "cannot find blosxom.cgi '$blosxom_cgi'" unless -f $blosxom_cgi; +die "blosxom.cgi '$blosxom_cgi' is not executable" unless -x $blosxom_cgi; + +my $spec = YAML::LoadFile ("$testdir/spec.yaml") + or fail("$test - loading spec") and next; + +touch_files("$testdir/data"); + +my %expected = (); + +for (@{$spec->{tests}}) { + my ($args, $output) = @$_; + + unless ($expected{$output}) { + my $fh = IO::File->new("$testdir/$output", 'r') + or die "cannot open expected output file '$output': $!"; + { + local $/ = undef; + $expected{$output} = <$fh>; + } + $fh->close; + } + + my $got = qx($blosxom_cgi $args); + + eq_or_diff($got, $expected{$output}, "$test - got expected output for args [$args]", { style => 'Unified' }); +} + +sub touch_files { + find( sub { + if (/^(.*)\.(\d+)$/) { + copy($_, $1); + `touch -t $2 $1`; + } + }, + shift ); +} diff --git a/t/03_permalinks.t b/t/03_permalinks.t new file mode 100644 index 0000000..f176604 --- /dev/null +++ b/t/03_permalinks.t @@ -0,0 +1,67 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More qw( no_plan ); + +use Cwd; +use YAML; +use IO::File; +use File::Find; +use File::Copy; +#use File::Touch; +use File::Basename; +use Test::Differences; + +my $test = basename($0); +$test =~ s/^\d+_?//; +$test =~ s/\.t$//; + +my $testdir = $test; +$testdir = "t/$testdir" if -d "t/$testdir"; +$testdir = cwd . "/$testdir"; +die "cannot find root '$testdir'" unless -d $testdir; + +my $blosxom_config_dir = "$testdir/config"; +die "cannot find blosxom config dir '$blosxom_config_dir'" unless -d $blosxom_config_dir; +$ENV{BLOSXOM_CONFIG_DIR} = $blosxom_config_dir; + +my $blosxom_cgi = "$testdir/../../blosxom.cgi"; +die "cannot find blosxom.cgi '$blosxom_cgi'" unless -f $blosxom_cgi; +die "blosxom.cgi '$blosxom_cgi' is not executable" unless -x $blosxom_cgi; + +my $spec = YAML::LoadFile ("$testdir/spec.yaml") + or fail("$test - loading spec") and next; + +touch_files("$testdir/data"); + +my %expected = (); + +for (@{$spec->{tests}}) { + my ($args, $output) = @$_; + + unless ($expected{$output}) { + my $fh = IO::File->new("$testdir/$output", 'r') + or die "cannot open expected output file '$output': $!"; + { + local $/ = undef; + $expected{$output} = <$fh>; + } + $fh->close; + } + + my $got = qx($blosxom_cgi $args); + + eq_or_diff($got, $expected{$output}, "$test - got expected output for args [$args]", { style => 'Unified' }); +} + +sub touch_files { + find( sub { + if (/^(.*)\.(\d+)$/) { + copy($_, $1); + `touch -t $2 $1`; + } + }, + shift ); +} diff --git a/t/04_plugin_list.t b/t/04_plugin_list.t new file mode 100644 index 0000000..f176604 --- /dev/null +++ b/t/04_plugin_list.t @@ -0,0 +1,67 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More qw( no_plan ); + +use Cwd; +use YAML; +use IO::File; +use File::Find; +use File::Copy; +#use File::Touch; +use File::Basename; +use Test::Differences; + +my $test = basename($0); +$test =~ s/^\d+_?//; +$test =~ s/\.t$//; + +my $testdir = $test; +$testdir = "t/$testdir" if -d "t/$testdir"; +$testdir = cwd . "/$testdir"; +die "cannot find root '$testdir'" unless -d $testdir; + +my $blosxom_config_dir = "$testdir/config"; +die "cannot find blosxom config dir '$blosxom_config_dir'" unless -d $blosxom_config_dir; +$ENV{BLOSXOM_CONFIG_DIR} = $blosxom_config_dir; + +my $blosxom_cgi = "$testdir/../../blosxom.cgi"; +die "cannot find blosxom.cgi '$blosxom_cgi'" unless -f $blosxom_cgi; +die "blosxom.cgi '$blosxom_cgi' is not executable" unless -x $blosxom_cgi; + +my $spec = YAML::LoadFile ("$testdir/spec.yaml") + or fail("$test - loading spec") and next; + +touch_files("$testdir/data"); + +my %expected = (); + +for (@{$spec->{tests}}) { + my ($args, $output) = @$_; + + unless ($expected{$output}) { + my $fh = IO::File->new("$testdir/$output", 'r') + or die "cannot open expected output file '$output': $!"; + { + local $/ = undef; + $expected{$output} = <$fh>; + } + $fh->close; + } + + my $got = qx($blosxom_cgi $args); + + eq_or_diff($got, $expected{$output}, "$test - got expected output for args [$args]", { style => 'Unified' }); +} + +sub touch_files { + find( sub { + if (/^(.*)\.(\d+)$/) { + copy($_, $1); + `touch -t $2 $1`; + } + }, + shift ); +} -- 2.30.2