From: Gavin Carr Date: Wed, 3 Oct 2007 11:58:13 +0000 (+0000) Subject: Add plugin_dir and plugin_list test cases. X-Git-Tag: v2_1_0~39 X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=12352c94e4e3f56b9e99d38c52079c92a24ace59;p=matthijs%2Fupstream%2Fblosxom.git Add plugin_dir and plugin_list test cases. --- diff --git a/t/04_plugin_dir.t b/t/04_plugin_dir.t new file mode 100644 index 0000000..c27c35b --- /dev/null +++ b/t/04_plugin_dir.t @@ -0,0 +1,35 @@ +# blosxom standard $plugin_dir testing + +use strict; +use Test::More tests => 1; +use Test::Differences; +use Cwd; +use IO::File; + +my $blosxom_root = 'plugin_dir'; +$blosxom_root = "t/$blosxom_root" if -d "t/$blosxom_root"; +$blosxom_root = cwd . "/$blosxom_root"; +die "cannot find root '$blosxom_root'" + unless -d $blosxom_root; + +my $blosxom_config_dir = "$blosxom_root/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 = "$blosxom_root/../../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 $fh = IO::File->new("$blosxom_root/expected.html", 'r') + or die "cannot open expected output file '$blosxom_root/expected.html': $!"; +my $expected; +{ + local $/ = undef; + $expected = <$fh>; + $fh->close; +} + +my $output = qx($blosxom_cgi); + +eq_or_diff($output, $expected, 'html output ok'); + diff --git a/t/05_plugin_list.t b/t/05_plugin_list.t new file mode 100644 index 0000000..5e4e952 --- /dev/null +++ b/t/05_plugin_list.t @@ -0,0 +1,35 @@ +# blosxom $plugin_list testing + +use strict; +use Test::More tests => 1; +use Test::Differences; +use Cwd; +use IO::File; + +my $blosxom_root = 'plugin_list'; +$blosxom_root = "t/$blosxom_root" if -d "t/$blosxom_root"; +$blosxom_root = cwd . "/$blosxom_root"; +die "cannot find root '$blosxom_root'" + unless -d $blosxom_root; + +my $blosxom_config_dir = "$blosxom_root/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 = "$blosxom_root/../../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 $fh = IO::File->new("$blosxom_root/expected.html", 'r') + or die "cannot open expected output file '$blosxom_root/expected.html': $!"; +my $expected; +{ + local $/ = undef; + $expected = <$fh>; + $fh->close; +} + +my $output = qx($blosxom_cgi); + +eq_or_diff($output, $expected, 'html output ok'); + diff --git a/t/plugin_dir/config/blosxom.conf b/t/plugin_dir/config/blosxom.conf new file mode 100644 index 0000000..679a892 --- /dev/null +++ b/t/plugin_dir/config/blosxom.conf @@ -0,0 +1,5 @@ +$blog_title = 'plugin_list test'; +$blog_encoding = 'ISO-8859-1'; +$datadir = "$ENV{BLOSXOM_CONFIG_DIR}/../data"; +$plugin_list = ''; +$plugin_dir = "$ENV{BLOSXOM_CONFIG_DIR}/../plugins"; diff --git a/t/plugin_dir/data/1.txt b/t/plugin_dir/data/1.txt new file mode 100644 index 0000000..748c525 --- /dev/null +++ b/t/plugin_dir/data/1.txt @@ -0,0 +1,4 @@ +Story 1 + +Story 1 text + diff --git a/t/plugin_dir/data/date.html b/t/plugin_dir/data/date.html new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/t/plugin_dir/data/date.html @@ -0,0 +1 @@ + diff --git a/t/plugin_dir/data/foot.html b/t/plugin_dir/data/foot.html new file mode 100644 index 0000000..308b1d0 --- /dev/null +++ b/t/plugin_dir/data/foot.html @@ -0,0 +1,2 @@ + + diff --git a/t/plugin_dir/data/head.html b/t/plugin_dir/data/head.html new file mode 100644 index 0000000..f70f5a3 --- /dev/null +++ b/t/plugin_dir/data/head.html @@ -0,0 +1,6 @@ + + +$blog_title + + +

$blog_title

diff --git a/t/plugin_dir/data/story.html b/t/plugin_dir/data/story.html new file mode 100644 index 0000000..ca627b8 --- /dev/null +++ b/t/plugin_dir/data/story.html @@ -0,0 +1,2 @@ +$dump_plugins::list +$body diff --git a/t/plugin_dir/expected.html b/t/plugin_dir/expected.html new file mode 100644 index 0000000..4c5f854 --- /dev/null +++ b/t/plugin_dir/expected.html @@ -0,0 +1,22 @@ +Content-Type: text/html; charset=ISO-8859-1 + + + +plugin_list test + + +

plugin_list test

+ +
+plugin2
+plugin4
+dump_plugins
+plugin1
+plugin3
+
+ + +Story 1 text + + + diff --git a/t/plugin_dir/plugins/02plugin2 b/t/plugin_dir/plugins/02plugin2 new file mode 100644 index 0000000..1c86931 --- /dev/null +++ b/t/plugin_dir/plugins/02plugin2 @@ -0,0 +1,3 @@ +package plugin2; +sub start { 1 }; +1; diff --git a/t/plugin_dir/plugins/04plugin4_ b/t/plugin_dir/plugins/04plugin4_ new file mode 100644 index 0000000..2ddb545 --- /dev/null +++ b/t/plugin_dir/plugins/04plugin4_ @@ -0,0 +1,3 @@ +package plugin4; +sub start { 1 }; +1; diff --git a/t/plugin_dir/plugins/dump_plugins b/t/plugin_dir/plugins/dump_plugins new file mode 100644 index 0000000..3550b4b --- /dev/null +++ b/t/plugin_dir/plugins/dump_plugins @@ -0,0 +1,5 @@ +package dump_plugins; +use vars qw($list); +sub start { 1 }; +sub head { $list = sprintf "
\n%s\n
\n", join("\n", @blosxom::plugins); } +1; diff --git a/t/plugin_dir/plugins/plugin1 b/t/plugin_dir/plugins/plugin1 new file mode 100644 index 0000000..635cd26 --- /dev/null +++ b/t/plugin_dir/plugins/plugin1 @@ -0,0 +1,3 @@ +package plugin1; +sub start { 1 }; +1; diff --git a/t/plugin_dir/plugins/plugin3_ b/t/plugin_dir/plugins/plugin3_ new file mode 100644 index 0000000..e2d75ce --- /dev/null +++ b/t/plugin_dir/plugins/plugin3_ @@ -0,0 +1,3 @@ +package plugin3; +sub start { 1 }; +1; diff --git a/t/plugin_list/config/blosxom.conf b/t/plugin_list/config/blosxom.conf new file mode 100644 index 0000000..859eb10 --- /dev/null +++ b/t/plugin_list/config/blosxom.conf @@ -0,0 +1,5 @@ +$blog_title = 'plugin_list test'; +$blog_encoding = 'ISO-8859-1'; +$datadir = "$ENV{BLOSXOM_CONFIG_DIR}/../data"; +$plugin_list = "$ENV{BLOSXOM_CONFIG_DIR}/plugins.conf"; +$plugin_dir = "$ENV{BLOSXOM_CONFIG_DIR}/../plugins"; diff --git a/t/plugin_list/config/plugins.conf b/t/plugin_list/config/plugins.conf new file mode 100644 index 0000000..3a4090e --- /dev/null +++ b/t/plugin_list/config/plugins.conf @@ -0,0 +1,19 @@ + +# Bare +plugin1 + +# Numbered +02plugin2 + +# Underscored +plugin3_ + +# Numbered and underscored +04plugin4_ + +# Commented out +# plugin5 + +# Real plugin - dump the list of plugins +dump_plugins + diff --git a/t/plugin_list/data/1.txt b/t/plugin_list/data/1.txt new file mode 100644 index 0000000..748c525 --- /dev/null +++ b/t/plugin_list/data/1.txt @@ -0,0 +1,4 @@ +Story 1 + +Story 1 text + diff --git a/t/plugin_list/data/date.html b/t/plugin_list/data/date.html new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/t/plugin_list/data/date.html @@ -0,0 +1 @@ + diff --git a/t/plugin_list/data/foot.html b/t/plugin_list/data/foot.html new file mode 100644 index 0000000..308b1d0 --- /dev/null +++ b/t/plugin_list/data/foot.html @@ -0,0 +1,2 @@ + + diff --git a/t/plugin_list/data/head.html b/t/plugin_list/data/head.html new file mode 100644 index 0000000..f70f5a3 --- /dev/null +++ b/t/plugin_list/data/head.html @@ -0,0 +1,6 @@ + + +$blog_title + + +

$blog_title

diff --git a/t/plugin_list/data/story.html b/t/plugin_list/data/story.html new file mode 100644 index 0000000..ca627b8 --- /dev/null +++ b/t/plugin_list/data/story.html @@ -0,0 +1,2 @@ +$dump_plugins::list +$body diff --git a/t/plugin_list/expected.html b/t/plugin_list/expected.html new file mode 100644 index 0000000..14603c8 --- /dev/null +++ b/t/plugin_list/expected.html @@ -0,0 +1,22 @@ +Content-Type: text/html; charset=ISO-8859-1 + + + +plugin_list test + + +

plugin_list test

+ +
+plugin1
+plugin2
+plugin3
+plugin4
+dump_plugins
+
+ + +Story 1 text + + + diff --git a/t/plugin_list/plugins/dump_plugins b/t/plugin_list/plugins/dump_plugins new file mode 100644 index 0000000..3550b4b --- /dev/null +++ b/t/plugin_list/plugins/dump_plugins @@ -0,0 +1,5 @@ +package dump_plugins; +use vars qw($list); +sub start { 1 }; +sub head { $list = sprintf "
\n%s\n
\n", join("\n", @blosxom::plugins); } +1; diff --git a/t/plugin_list/plugins/plugin1 b/t/plugin_list/plugins/plugin1 new file mode 100644 index 0000000..635cd26 --- /dev/null +++ b/t/plugin_list/plugins/plugin1 @@ -0,0 +1,3 @@ +package plugin1; +sub start { 1 }; +1; diff --git a/t/plugin_list/plugins/plugin2 b/t/plugin_list/plugins/plugin2 new file mode 100644 index 0000000..1c86931 --- /dev/null +++ b/t/plugin_list/plugins/plugin2 @@ -0,0 +1,3 @@ +package plugin2; +sub start { 1 }; +1; diff --git a/t/plugin_list/plugins/plugin3 b/t/plugin_list/plugins/plugin3 new file mode 100644 index 0000000..e2d75ce --- /dev/null +++ b/t/plugin_list/plugins/plugin3 @@ -0,0 +1,3 @@ +package plugin3; +sub start { 1 }; +1; diff --git a/t/plugin_list/plugins/plugin4 b/t/plugin_list/plugins/plugin4 new file mode 100644 index 0000000..2ddb545 --- /dev/null +++ b/t/plugin_list/plugins/plugin4 @@ -0,0 +1,3 @@ +package plugin4; +sub start { 1 }; +1; diff --git a/t/plugin_list/plugins/plugin5 b/t/plugin_list/plugins/plugin5 new file mode 100644 index 0000000..17a57bc --- /dev/null +++ b/t/plugin_list/plugins/plugin5 @@ -0,0 +1,3 @@ +package plugin5; +sub start { 1 }; +1;