+++ /dev/null
-#!/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 );
-}
+++ /dev/null
-#!/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 );
-}
+++ /dev/null
-#!/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 );
-}
+++ /dev/null
-#!/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 );
-}
+++ /dev/null
-#!/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 );
-}
--- /dev/null
+Running Tests
+=============
+
+ perl ./Setup
+ prove *.t
+
+
+
+Test Layout
+===========
+
+To add a new test, you want to add two things - a test script (which
+is typically just a symlink to the main 'driver' script), and a test
+directory. If you just want a symlink test script, then add your
+test script name to 'driver_tests', and rerun Setup. To add a new
+test directory, you're probably best just to copy one of the
+existing ones - 'templates' is a good choice:
+
+ cp -rp templates newtest
+
+Test directory layout is as follows, using 'templates' as an example:
+
+ templates
+ |-- config
+ | `-- blosxom.conf
+ |-- data
+ | |-- 1.txt
+ | |-- 1.txt.200607192254
+ | |-- content_type.html
+ | |-- date.html
+ | |-- foot.html
+ | |-- head.html
+ | `-- story.html
+ |-- expected.html
+ `-- spec.yaml
+
+The 'config' directory contains the config files for this blosxom
+instance, which is minimally a 'blosxom.conf' file with the $data_dir
+variable pointing to the 'data' directory. Customising this is
+optional.
+
+The 'data directory' is the set of stories or posts you want to use
+for your test, and any flavour files you want. Stories may optionally be
+suffixed with a numeric timestamp (format YYYYMMDDHHMI) like the
+'1.txt.200607192254' entry above, which is used to set the modify time
+of the story explicitly (since CVS does not store mtimes). Providing
+flavour files is recommended so that your tests don't break if the
+default flavours change.
+
+At the top level of the test directory are a set of one or more
+expected output files, and the spec.yaml files which controls the set
+of tests that are run. For templates, the spec.yaml looks like this:
+
+ tests:
+ -
+ - ""
+ - expected.html
+
+This lists the set of tests to be run (in this case just a single test).
+Each test requires a list of two arguments - the arguments to path to
+blosxom.cgi (in this case none, an empty string), and a file containing
+the expected output. So this test will execute blosxom.cgi with no
+arguments, and compare the output produced against that contained in
+the 'expected.html' file.
+
+A longer spec.yaml example is:
+
+ tests:
+ -
+ - ""
+ - expected.html
+ -
+ - path=/foo
+ - expected.html
+ -
+ - path=/foo/bar.html
+ - expected.bar
+
+This defines three tests, one with no arguments, one with a path of
+/foo, and a third with a path of /foo/bar.html.
+
--- /dev/null
+#!/usr/bin/env perl
+#
+# Script to setup test script symlinks, since CVS can't store them
+#
+
+use strict;
+use IO::File;
+
+my $DRIVER = 'driver';
+my $TESTS = 'driver_tests';
+die "cannot find driver file '$DRIVER'" unless -f $DRIVER;
+die "cannot find tests file '$TESTS'" unless -f $TESTS;
+
+my @tests = ();
+
+my $th = IO::File->new($TESTS, 'r')
+ or die "cannot open tests file '$TESTS': $!";
+@tests = <$th>;
+close $th;
+
+for my $t (@tests) {
+ chomp $t;
+ print "symlink $DRIVER $t\n";
+ eval { symlink $DRIVER, $t } or die "symlink $DRIVER, $t failed: $!";
+}
+
--- /dev/null
+#!/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 );
+}
--- /dev/null
+01_templates.t
+02_smoketest.t
+03_permalinks.t
+04_plugin_dir.t
+04_plugin_list.t