From: Gavin Carr Date: Fri, 5 Oct 2007 12:23:23 +0000 (+0000) Subject: Add test drivers as files, since symlinks don't work. X-Git-Tag: debian/2.1.2-2~66 X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=5f3663964d3883856fdd2699e5163a0cbc71e5c5;p=pkg%2Fblosxom.git Add test drivers as files, since symlinks don't work. --- diff --git a/t/01_templates.t b/t/01_templates.t new file mode 100644 index 0000000..f176604 --- /dev/null +++ b/t/01_templates.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/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 ); +} diff --git a/t/driver b/t/driver deleted file mode 100644 index f176604..0000000 --- a/t/driver +++ /dev/null @@ -1,67 +0,0 @@ -#!/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 ); -}