From: Gavin Carr Date: Tue, 13 Nov 2007 09:14:22 +0000 (+0000) Subject: Add initial static_basic static test case. X-Git-Tag: debian/2.1.2-2~60 X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=dd3d1214ab2e820bfe64b49f4f84ccaefb7013a9;p=pkg%2Fblosxom.git Add initial static_basic static test case. --- diff --git a/t/README b/t/README index c935d16..53ea291 100644 --- a/t/README +++ b/t/README @@ -12,9 +12,9 @@ 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: +test script name to '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 diff --git a/t/Setup b/t/Setup index ffdbe16..93f0733 100755 --- a/t/Setup +++ b/t/Setup @@ -7,7 +7,7 @@ use strict; use IO::File; my $DRIVER = 'driver'; -my $TESTS = 'driver_tests'; +my $TESTS = 'Tests'; die "cannot find driver file '$DRIVER'" unless -f $DRIVER; die "cannot find tests file '$TESTS'" unless -f $TESTS; diff --git a/t/Tests b/t/Tests new file mode 100644 index 0000000..0a999a3 --- /dev/null +++ b/t/Tests @@ -0,0 +1,7 @@ +01_templates.t +02_smoketest.t +03_permalinks.t +03_interpolate.t +04_plugin_dir.t +04_plugin_list.t +08_static_basic.t diff --git a/t/driver b/t/driver index f176604..574276b 100644 --- a/t/driver +++ b/t/driver @@ -26,34 +26,94 @@ 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; +$ENV{TZ} = 'UTC'; 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; + or die("$test - could not load spec"); touch_files("$testdir/data"); -my %expected = (); +# Eval blosxom.conf +my ($static_dir, $static_password, @static_flavours); +if (my $fh = IO::File->new("$blosxom_config_dir/blosxom.conf", 'r')) { + no strict; + local $/ = undef; + eval <$fh>; +} -for (@{$spec->{tests}}) { - my ($args, $output) = @$_; +# Static mode +if ($static_password) { + eval { + require File::DirCompare; + require File::Remove; + }; + SKIP: { + skip "Static tests require additional modules: $@", 1 if $@; + my $expected = $spec->{expected}; + skip "Static tests require 'expected' directory", 1 unless $expected; + $expected = "$blosxom_config_dir/../$expected" unless $expected =~ m!^/!; + skip "Static tests 'expected' directory is missing", 1 unless -d $expected; + skip "Static tests 'static_dir' directory is missing", 1 unless -d $static_dir; - 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; + File::Remove::remove(\1, "$static_dir/*"); + + my $errors = qx($blosxom_cgi -quiet=1 -password=$static_password); + is($errors, '', 'no errors reported from static run'); + File::DirCompare->compare($static_dir, "$blosxom_config_dir/../" . $spec->{expected}, sub { + my ($a, $b) = @_; + my ($a_short, $b_short) = ($a, $b); + $a_short =~ s!^.*\.\./!! if $a_short; + $b_short =~ s!^.*\.\./!! if $b_short; + if (! $b) { + fail("$a_short has no corresponding file"); + } elsif (! $a) { + fail("$b_short has no corresponding file"); + } else { + my ($got, $expected) = ('', ''); + my $fh = IO::File->new($a, 'r') + or die "cannot open static output file '$a': $!"; + { + local $/ = undef; + $got = <$fh>; + $fh->close; + } + $fh = IO::File->new($b, 'r') + or die "cannot open static output file '$b': $!"; + { + local $/ = undef; + $expected = <$fh>; + $fh->close; + } + eq_or_diff($got, $expected, "file $a_short and $b_short match", { style => 'Unified' }); + } + }, { ignore_cmp => 1 }); } +} - my $got = qx($blosxom_cgi $args); +# Dynamic mode +else { + my %expected = (); + for (@{$spec->{tests}}) { + my ($args, $output) = @$_; - eq_or_diff($got, $expected{$output}, "$test - got expected output for args [$args]", { style => 'Unified' }); + 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 { diff --git a/t/driver_tests b/t/driver_tests deleted file mode 100644 index a7d2714..0000000 --- a/t/driver_tests +++ /dev/null @@ -1,6 +0,0 @@ -01_templates.t -02_smoketest.t -03_permalinks.t -03_interpolate.t -04_plugin_dir.t -04_plugin_list.t diff --git a/t/smoketest/expected.rss b/t/smoketest/expected.rss index 4ea06ca..579b3bf 100644 --- a/t/smoketest/expected.rss +++ b/t/smoketest/expected.rss @@ -12,7 +12,7 @@ Content-Type: text/xml; charset=ISO-8859-1 Lorem ipsum - Wed, 19 Jul 2006 22:54:00 +1000 + Wed, 19 Jul 2006 22:54:00 +0000 http://localhost/2006/07/19#1 /1 diff --git a/t/static_basic/config/blosxom.conf b/t/static_basic/config/blosxom.conf new file mode 100644 index 0000000..7d8ef26 --- /dev/null +++ b/t/static_basic/config/blosxom.conf @@ -0,0 +1,4 @@ +$datadir = "$ENV{BLOSXOM_CONFIG_DIR}/../data"; +$static_dir = "$ENV{BLOSXOM_CONFIG_DIR}/../static"; +$static_password = 'static'; +@static_flavours = qw/html rss/; diff --git a/t/static_basic/data/1.txt b/t/static_basic/data/1.txt new file mode 100644 index 0000000..ea2a941 --- /dev/null +++ b/t/static_basic/data/1.txt @@ -0,0 +1,16 @@ +Lorem ipsum +Lorem ipsum dolor sit amet ipso facto.Lorem ipsum dolor sit amet ipso +facto.Lorem ipsum dolor sit amet ipso facto. Lorem ipsum dolor sit +amet ipso facto.Lorem ipsum dolor sit amet ipso facto. + +facto.Lorem ipsum dolor sit amet ipso facto.Lorem ipsum dolor sit amet +ipso facto.Lorem ipsum dolor sit amet ipso facto. Lorem ipsum dolor +sit amet ipso facto.Lorem ipsum dolor sit amet ipso facto. + +Lorem ipso hoccer foer tyr wuz de ras cora dola tymon ipso hoc cer fuz +de ramas cora dola tymon ipso hoccer. Lorem ipso foer tyr wuz de ramas +cora dola tym ipso hor.Lorem ipso foer tyr wuz de ramas cora dola tym +ipso hor tyr wuz de ramas cora dola tymon ipso foer tyr wuz de ramas +cora dola tymo. Lorem ipso hoccer foer tyr wuz de ras cora dola tymon +ipso hoc cer fuz de ramas cora dola tymon ipso hoccer. Lorem ipso foer +tyr wuz de ramas cora dola tym ipso hor. diff --git a/t/static_basic/data/1.txt.200607192254 b/t/static_basic/data/1.txt.200607192254 new file mode 100644 index 0000000..ea2a941 --- /dev/null +++ b/t/static_basic/data/1.txt.200607192254 @@ -0,0 +1,16 @@ +Lorem ipsum +Lorem ipsum dolor sit amet ipso facto.Lorem ipsum dolor sit amet ipso +facto.Lorem ipsum dolor sit amet ipso facto. Lorem ipsum dolor sit +amet ipso facto.Lorem ipsum dolor sit amet ipso facto. + +facto.Lorem ipsum dolor sit amet ipso facto.Lorem ipsum dolor sit amet +ipso facto.Lorem ipsum dolor sit amet ipso facto. Lorem ipsum dolor +sit amet ipso facto.Lorem ipsum dolor sit amet ipso facto. + +Lorem ipso hoccer foer tyr wuz de ras cora dola tymon ipso hoc cer fuz +de ramas cora dola tymon ipso hoccer. Lorem ipso foer tyr wuz de ramas +cora dola tym ipso hor.Lorem ipso foer tyr wuz de ramas cora dola tym +ipso hor tyr wuz de ramas cora dola tymon ipso foer tyr wuz de ramas +cora dola tymo. Lorem ipso hoccer foer tyr wuz de ras cora dola tymon +ipso hoc cer fuz de ramas cora dola tymon ipso hoccer. Lorem ipso foer +tyr wuz de ramas cora dola tym ipso hor. diff --git a/t/static_basic/data/content_type.html b/t/static_basic/data/content_type.html new file mode 100644 index 0000000..e81f92a --- /dev/null +++ b/t/static_basic/data/content_type.html @@ -0,0 +1 @@ +text/xhtml; charset=UTF-8 diff --git a/t/static_basic/data/date.html b/t/static_basic/data/date.html new file mode 100644 index 0000000..2cdf76d --- /dev/null +++ b/t/static_basic/data/date.html @@ -0,0 +1 @@ +

$yr-$mo_num-$da

diff --git a/t/static_basic/data/foot.html b/t/static_basic/data/foot.html new file mode 100644 index 0000000..5179ade --- /dev/null +++ b/t/static_basic/data/foot.html @@ -0,0 +1,3 @@ + + + diff --git a/t/static_basic/data/head.html b/t/static_basic/data/head.html new file mode 100644 index 0000000..7426227 --- /dev/null +++ b/t/static_basic/data/head.html @@ -0,0 +1,11 @@ + + + + + $blog_title $path_info_da $path_info_mo $path_info_yr + + + +

$blog_title

+

$path_info_da $path_info_mo $path_info_yr

diff --git a/t/static_basic/data/story.html b/t/static_basic/data/story.html new file mode 100644 index 0000000..7f3d068 --- /dev/null +++ b/t/static_basic/data/story.html @@ -0,0 +1,3 @@ +

$title

+
$body
+

posted at: $ti | path: $path | permanent link to this entry

diff --git a/t/static_basic/expected/2006/07/19/index.html b/t/static_basic/expected/2006/07/19/index.html new file mode 100644 index 0000000..befcf2d --- /dev/null +++ b/t/static_basic/expected/2006/07/19/index.html @@ -0,0 +1,32 @@ + + + + + My Weblog 19 07 2006 + + + +

My Weblog

+

19 07 2006

+

2006-07-19

+

Lorem ipsum

+
Lorem ipsum dolor sit amet ipso facto.Lorem ipsum dolor sit amet ipso +facto.Lorem ipsum dolor sit amet ipso facto. Lorem ipsum dolor sit +amet ipso facto.Lorem ipsum dolor sit amet ipso facto. + +facto.Lorem ipsum dolor sit amet ipso facto.Lorem ipsum dolor sit amet +ipso facto.Lorem ipsum dolor sit amet ipso facto. Lorem ipsum dolor +sit amet ipso facto.Lorem ipsum dolor sit amet ipso facto. + +Lorem ipso hoccer foer tyr wuz de ras cora dola tymon ipso hoc cer fuz +de ramas cora dola tymon ipso hoccer. Lorem ipso foer tyr wuz de ramas +cora dola tym ipso hor.Lorem ipso foer tyr wuz de ramas cora dola tym +ipso hor tyr wuz de ramas cora dola tymon ipso foer tyr wuz de ramas +cora dola tymo. Lorem ipso hoccer foer tyr wuz de ras cora dola tymon +ipso hoc cer fuz de ramas cora dola tymon ipso hoccer. Lorem ipso foer +tyr wuz de ramas cora dola tym ipso hor.
+

posted at: 22:54 | path: | permanent link to this entry

+ + + diff --git a/t/static_basic/expected/2006/07/19/index.rss b/t/static_basic/expected/2006/07/19/index.rss new file mode 100644 index 0000000..9d5130f --- /dev/null +++ b/t/static_basic/expected/2006/07/19/index.rss @@ -0,0 +1,34 @@ + + + + My Weblog + http://localhost/ + Yet another Blosxom weblog. + en + http://blogs.law.harvard.edu/tech/rss + blosxom/2.0.2 + + + Lorem ipsum + Wed, 19 Jul 2006 22:54:00 +0000 + http://localhost/2006/07/19#1 + + /1 + Lorem ipsum dolor sit amet ipso facto.Lorem ipsum dolor sit amet ipso +facto.Lorem ipsum dolor sit amet ipso facto. Lorem ipsum dolor sit +amet ipso facto.Lorem ipsum dolor sit amet ipso facto. + +facto.Lorem ipsum dolor sit amet ipso facto.Lorem ipsum dolor sit amet +ipso facto.Lorem ipsum dolor sit amet ipso facto. Lorem ipsum dolor +sit amet ipso facto.Lorem ipsum dolor sit amet ipso facto. + +Lorem ipso hoccer foer tyr wuz de ras cora dola tymon ipso hoc cer fuz +de ramas cora dola tymon ipso hoccer. Lorem ipso foer tyr wuz de ramas +cora dola tym ipso hor.Lorem ipso foer tyr wuz de ramas cora dola tym +ipso hor tyr wuz de ramas cora dola tymon ipso foer tyr wuz de ramas +cora dola tymo. Lorem ipso hoccer foer tyr wuz de ras cora dola tymon +ipso hoc cer fuz de ramas cora dola tymon ipso hoccer. Lorem ipso foer +tyr wuz de ramas cora dola tym ipso hor. + + + diff --git a/t/static_basic/expected/2006/07/index.html b/t/static_basic/expected/2006/07/index.html new file mode 100644 index 0000000..e2a2c52 --- /dev/null +++ b/t/static_basic/expected/2006/07/index.html @@ -0,0 +1,32 @@ + + + + + My Weblog 07 2006 + + + +

My Weblog

+

07 2006

+

2006-07-19

+

Lorem ipsum

+
Lorem ipsum dolor sit amet ipso facto.Lorem ipsum dolor sit amet ipso +facto.Lorem ipsum dolor sit amet ipso facto. Lorem ipsum dolor sit +amet ipso facto.Lorem ipsum dolor sit amet ipso facto. + +facto.Lorem ipsum dolor sit amet ipso facto.Lorem ipsum dolor sit amet +ipso facto.Lorem ipsum dolor sit amet ipso facto. Lorem ipsum dolor +sit amet ipso facto.Lorem ipsum dolor sit amet ipso facto. + +Lorem ipso hoccer foer tyr wuz de ras cora dola tymon ipso hoc cer fuz +de ramas cora dola tymon ipso hoccer. Lorem ipso foer tyr wuz de ramas +cora dola tym ipso hor.Lorem ipso foer tyr wuz de ramas cora dola tym +ipso hor tyr wuz de ramas cora dola tymon ipso foer tyr wuz de ramas +cora dola tymo. Lorem ipso hoccer foer tyr wuz de ras cora dola tymon +ipso hoc cer fuz de ramas cora dola tymon ipso hoccer. Lorem ipso foer +tyr wuz de ramas cora dola tym ipso hor.
+

posted at: 22:54 | path: | permanent link to this entry

+ + + diff --git a/t/static_basic/expected/2006/07/index.rss b/t/static_basic/expected/2006/07/index.rss new file mode 100644 index 0000000..9d5130f --- /dev/null +++ b/t/static_basic/expected/2006/07/index.rss @@ -0,0 +1,34 @@ + + + + My Weblog + http://localhost/ + Yet another Blosxom weblog. + en + http://blogs.law.harvard.edu/tech/rss + blosxom/2.0.2 + + + Lorem ipsum + Wed, 19 Jul 2006 22:54:00 +0000 + http://localhost/2006/07/19#1 + + /1 + Lorem ipsum dolor sit amet ipso facto.Lorem ipsum dolor sit amet ipso +facto.Lorem ipsum dolor sit amet ipso facto. Lorem ipsum dolor sit +amet ipso facto.Lorem ipsum dolor sit amet ipso facto. + +facto.Lorem ipsum dolor sit amet ipso facto.Lorem ipsum dolor sit amet +ipso facto.Lorem ipsum dolor sit amet ipso facto. Lorem ipsum dolor +sit amet ipso facto.Lorem ipsum dolor sit amet ipso facto. + +Lorem ipso hoccer foer tyr wuz de ras cora dola tymon ipso hoc cer fuz +de ramas cora dola tymon ipso hoccer. Lorem ipso foer tyr wuz de ramas +cora dola tym ipso hor.Lorem ipso foer tyr wuz de ramas cora dola tym +ipso hor tyr wuz de ramas cora dola tymon ipso foer tyr wuz de ramas +cora dola tymo. Lorem ipso hoccer foer tyr wuz de ras cora dola tymon +ipso hoc cer fuz de ramas cora dola tymon ipso hoccer. Lorem ipso foer +tyr wuz de ramas cora dola tym ipso hor. + + + diff --git a/t/static_basic/expected/2006/index.html b/t/static_basic/expected/2006/index.html new file mode 100644 index 0000000..6d1fd23 --- /dev/null +++ b/t/static_basic/expected/2006/index.html @@ -0,0 +1,32 @@ + + + + + My Weblog 2006 + + + +

My Weblog

+

2006

+

2006-07-19

+

Lorem ipsum

+
Lorem ipsum dolor sit amet ipso facto.Lorem ipsum dolor sit amet ipso +facto.Lorem ipsum dolor sit amet ipso facto. Lorem ipsum dolor sit +amet ipso facto.Lorem ipsum dolor sit amet ipso facto. + +facto.Lorem ipsum dolor sit amet ipso facto.Lorem ipsum dolor sit amet +ipso facto.Lorem ipsum dolor sit amet ipso facto. Lorem ipsum dolor +sit amet ipso facto.Lorem ipsum dolor sit amet ipso facto. + +Lorem ipso hoccer foer tyr wuz de ras cora dola tymon ipso hoc cer fuz +de ramas cora dola tymon ipso hoccer. Lorem ipso foer tyr wuz de ramas +cora dola tym ipso hor.Lorem ipso foer tyr wuz de ramas cora dola tym +ipso hor tyr wuz de ramas cora dola tymon ipso foer tyr wuz de ramas +cora dola tymo. Lorem ipso hoccer foer tyr wuz de ras cora dola tymon +ipso hoc cer fuz de ramas cora dola tymon ipso hoccer. Lorem ipso foer +tyr wuz de ramas cora dola tym ipso hor.
+

posted at: 22:54 | path: | permanent link to this entry

+ + + diff --git a/t/static_basic/expected/2006/index.rss b/t/static_basic/expected/2006/index.rss new file mode 100644 index 0000000..9d5130f --- /dev/null +++ b/t/static_basic/expected/2006/index.rss @@ -0,0 +1,34 @@ + + + + My Weblog + http://localhost/ + Yet another Blosxom weblog. + en + http://blogs.law.harvard.edu/tech/rss + blosxom/2.0.2 + + + Lorem ipsum + Wed, 19 Jul 2006 22:54:00 +0000 + http://localhost/2006/07/19#1 + + /1 + Lorem ipsum dolor sit amet ipso facto.Lorem ipsum dolor sit amet ipso +facto.Lorem ipsum dolor sit amet ipso facto. Lorem ipsum dolor sit +amet ipso facto.Lorem ipsum dolor sit amet ipso facto. + +facto.Lorem ipsum dolor sit amet ipso facto.Lorem ipsum dolor sit amet +ipso facto.Lorem ipsum dolor sit amet ipso facto. Lorem ipsum dolor +sit amet ipso facto.Lorem ipsum dolor sit amet ipso facto. + +Lorem ipso hoccer foer tyr wuz de ras cora dola tymon ipso hoc cer fuz +de ramas cora dola tymon ipso hoccer. Lorem ipso foer tyr wuz de ramas +cora dola tym ipso hor.Lorem ipso foer tyr wuz de ramas cora dola tym +ipso hor tyr wuz de ramas cora dola tymon ipso foer tyr wuz de ramas +cora dola tymo. Lorem ipso hoccer foer tyr wuz de ras cora dola tymon +ipso hoc cer fuz de ramas cora dola tymon ipso hoccer. Lorem ipso foer +tyr wuz de ramas cora dola tym ipso hor. + + + diff --git a/t/static_basic/expected/index.html b/t/static_basic/expected/index.html new file mode 100644 index 0000000..d0a68a6 --- /dev/null +++ b/t/static_basic/expected/index.html @@ -0,0 +1,32 @@ + + + + + My Weblog + + + +

My Weblog

+

+

2006-07-19

+

Lorem ipsum

+
Lorem ipsum dolor sit amet ipso facto.Lorem ipsum dolor sit amet ipso +facto.Lorem ipsum dolor sit amet ipso facto. Lorem ipsum dolor sit +amet ipso facto.Lorem ipsum dolor sit amet ipso facto. + +facto.Lorem ipsum dolor sit amet ipso facto.Lorem ipsum dolor sit amet +ipso facto.Lorem ipsum dolor sit amet ipso facto. Lorem ipsum dolor +sit amet ipso facto.Lorem ipsum dolor sit amet ipso facto. + +Lorem ipso hoccer foer tyr wuz de ras cora dola tymon ipso hoc cer fuz +de ramas cora dola tymon ipso hoccer. Lorem ipso foer tyr wuz de ramas +cora dola tym ipso hor.Lorem ipso foer tyr wuz de ramas cora dola tym +ipso hor tyr wuz de ramas cora dola tymon ipso foer tyr wuz de ramas +cora dola tymo. Lorem ipso hoccer foer tyr wuz de ras cora dola tymon +ipso hoc cer fuz de ramas cora dola tymon ipso hoccer. Lorem ipso foer +tyr wuz de ramas cora dola tym ipso hor.
+

posted at: 22:54 | path: | permanent link to this entry

+ + + diff --git a/t/static_basic/expected/index.rss b/t/static_basic/expected/index.rss new file mode 100644 index 0000000..9d5130f --- /dev/null +++ b/t/static_basic/expected/index.rss @@ -0,0 +1,34 @@ + + + + My Weblog + http://localhost/ + Yet another Blosxom weblog. + en + http://blogs.law.harvard.edu/tech/rss + blosxom/2.0.2 + + + Lorem ipsum + Wed, 19 Jul 2006 22:54:00 +0000 + http://localhost/2006/07/19#1 + + /1 + Lorem ipsum dolor sit amet ipso facto.Lorem ipsum dolor sit amet ipso +facto.Lorem ipsum dolor sit amet ipso facto. Lorem ipsum dolor sit +amet ipso facto.Lorem ipsum dolor sit amet ipso facto. + +facto.Lorem ipsum dolor sit amet ipso facto.Lorem ipsum dolor sit amet +ipso facto.Lorem ipsum dolor sit amet ipso facto. Lorem ipsum dolor +sit amet ipso facto.Lorem ipsum dolor sit amet ipso facto. + +Lorem ipso hoccer foer tyr wuz de ras cora dola tymon ipso hoc cer fuz +de ramas cora dola tymon ipso hoccer. Lorem ipso foer tyr wuz de ramas +cora dola tym ipso hor.Lorem ipso foer tyr wuz de ramas cora dola tym +ipso hor tyr wuz de ramas cora dola tymon ipso foer tyr wuz de ramas +cora dola tymo. Lorem ipso hoccer foer tyr wuz de ras cora dola tymon +ipso hoc cer fuz de ramas cora dola tymon ipso hoccer. Lorem ipso foer +tyr wuz de ramas cora dola tym ipso hor. + + + diff --git a/t/static_basic/spec.yaml b/t/static_basic/spec.yaml new file mode 100644 index 0000000..9c82ce4 --- /dev/null +++ b/t/static_basic/spec.yaml @@ -0,0 +1 @@ +expected: expected