From 74e116d89320f806eabbac8d3e30f8f122304507 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 30 Nov 2015 17:33:00 +0000 Subject: [PATCH 1/1] Run autopkgtest tests using autodep8 and the pkg-perl team's infrastructure (cherry picked from commit cdfb4ab1a3c60bf699b8d77618ec9bdf526cdb35) --- debian/control | 1 + debian/tests/pkg-perl/smoke-env | 1 + debian/tests/pkg-perl/syntax-skip | 4 ++++ debian/tests/pkg-perl/use-name | 1 + t/basewiki_brokenlinks.t | 31 ++++++++++++++++++++--------- t/comments.t | 21 +++++++++++++++++--- t/conflicts.t | 19 ++++++++++++++++-- t/cvs.t | 12 +++++++---- t/git.t | 10 +++++++++- t/img.t | 16 +++++++++++++++ t/inline.t | 27 ++++++++++++++++++------- t/permalink.t | 23 ++++++++++++++++++--- t/podcast.t | 31 ++++++++++++++++++----------- t/relativity.t | 18 ++++++++++++++--- t/syntax.t | 2 ++ t/template_syntax.t | 2 ++ t/templates_documented.t | 6 +++++- t/trail.t | 33 ++++++++++++++++++++++--------- 18 files changed, 205 insertions(+), 53 deletions(-) create mode 100644 debian/tests/pkg-perl/smoke-env create mode 100644 debian/tests/pkg-perl/syntax-skip create mode 100644 debian/tests/pkg-perl/use-name diff --git a/debian/control b/debian/control index 0b1314699..d2011bf4e 100644 --- a/debian/control +++ b/debian/control @@ -23,6 +23,7 @@ Uploaders: Josh Triplett Standards-Version: 3.9.5 Homepage: http://ikiwiki.info/ Vcs-Git: git://git.ikiwiki.info/ +Testsuite: autopkgtest-pkg-perl Package: ikiwiki Architecture: all diff --git a/debian/tests/pkg-perl/smoke-env b/debian/tests/pkg-perl/smoke-env new file mode 100644 index 000000000..774738148 --- /dev/null +++ b/debian/tests/pkg-perl/smoke-env @@ -0,0 +1 @@ +INSTALLED_TESTS=1 diff --git a/debian/tests/pkg-perl/syntax-skip b/debian/tests/pkg-perl/syntax-skip new file mode 100644 index 000000000..404e431d3 --- /dev/null +++ b/debian/tests/pkg-perl/syntax-skip @@ -0,0 +1,4 @@ +IkiWiki/Plugin/amazon_s3.pm +IkiWiki/Plugin/cvs.pm +IkiWiki/Plugin/monotone.pm +IkiWiki/Plugin/po.pm diff --git a/debian/tests/pkg-perl/use-name b/debian/tests/pkg-perl/use-name new file mode 100644 index 000000000..3d60011b3 --- /dev/null +++ b/debian/tests/pkg-perl/use-name @@ -0,0 +1 @@ +IkiWiki diff --git a/t/basewiki_brokenlinks.t b/t/basewiki_brokenlinks.t index 74ddc61c5..26e3859ab 100755 --- a/t/basewiki_brokenlinks.t +++ b/t/basewiki_brokenlinks.t @@ -1,21 +1,32 @@ #!/usr/bin/perl use warnings; use strict; -use Test::More 'no_plan'; +use Test::More; + +my $installed = $ENV{INSTALLED_TESTS}; ok(! system("rm -rf t/tmp; mkdir t/tmp")); -ok(! system("make -s ikiwiki.out")); -ok(! system("make underlay_install DESTDIR=`pwd`/t/tmp/install PREFIX=/usr >/dev/null")); + +my @command; +if ($installed) { + @command = qw(env LC_ALL=C ikiwiki); +} +else { + ok(! system("make -s ikiwiki.out")); + ok(! system("make underlay_install DESTDIR=`pwd`/t/tmp/install PREFIX=/usr >/dev/null")); + @command = qw(env LC_ALL=C perl -I. ./ikiwiki.out + --underlaydir=t/tmp/install/usr/share/ikiwiki/basewiki + --set underlaydirbase=t/tmp/install/usr/share/ikiwiki + --templatedir=templates); +} foreach my $plugin ("", "listdirectives") { - ok(! system("LC_ALL=C perl -I. ./ikiwiki.out -rebuild -plugin brokenlinks ". + ok(! system(@command, qw(--rebuild --plugin brokenlinks), # always enabled because pages link to it conditionally, # which brokenlinks cannot handle properly - "-plugin smiley ". - ($plugin ? "-plugin $plugin " : ""). - "-underlaydir=t/tmp/install/usr/share/ikiwiki/basewiki ". - "-set underlaydirbase=t/tmp/install/usr/share/ikiwiki ". - "-templatedir=templates t/basewiki_brokenlinks t/tmp/out")); + qw(--plugin smiley), + ($plugin ? ("--plugin", $plugin) : ()), + qw(t/basewiki_brokenlinks t/tmp/out))); my $result=`grep 'no broken links' t/tmp/out/index.html`; ok(length($result)); if (! length $result) { @@ -27,3 +38,5 @@ foreach my $plugin ("", "listdirectives") { ok(! system("rm -rf t/tmp/out t/basewiki_brokenlinks/.ikiwiki")); } ok(! system("rm -rf t/tmp")); + +done_testing(); diff --git a/t/comments.t b/t/comments.t index da2148b6b..a5add9701 100755 --- a/t/comments.t +++ b/t/comments.t @@ -1,7 +1,7 @@ #!/usr/bin/perl use warnings; use strict; -use Test::More 'no_plan'; +use Test::More; use IkiWiki; ok(! system("rm -rf t/tmp")); @@ -9,6 +9,20 @@ ok(mkdir "t/tmp"); ok(! system("cp -R t/tinyblog t/tmp/in")); ok(mkdir "t/tmp/in/post" or -d "t/tmp/in/post"); +my $installed = $ENV{INSTALLED_TESTS}; + +my @command; +if ($installed) { + @command = qw(ikiwiki); +} +else { + ok(! system("make -s ikiwiki.out")); + @command = qw(perl -I. ./ikiwiki.out + --underlaydir=underlays/basewiki + --set underlaydirbase=underlays + --templatedir=templates); +} + my $comment; $comment = < 106; +my $installed = $ENV{INSTALLED_TESTS}; + +my @command; +if ($installed) { + ok(1, "running installed"); + @command = qw(ikiwiki); +} +else { + ok(! system("make -s ikiwiki.out")); + @command = qw(perl -I. ./ikiwiki.out + --underlaydir=underlays/basewiki + --set underlaydirbase=underlays + --templatedir=templates); +} + # setup my $srcdir="t/tmp/src"; my $destdir="t/tmp/dest"; -ok(! system("make -s ikiwiki.out")); # runs ikiwiki to build test site sub runiki { my $testdesc=shift; - ok((! system("perl -I. ./ikiwiki.out -plugin txt -plugin rawhtml -underlaydir=underlays/basewiki -set underlaydirbase=underlays -templatedir=templates $srcdir $destdir @_")), + ok((! system(@command, qw(--plugin txt --plugin rawhtml), + $srcdir, $destdir, @_)), $testdesc); } sub refreshiki { diff --git a/t/cvs.t b/t/cvs.t index cbac43252..43a2ca3a8 100755 --- a/t/cvs.t +++ b/t/cvs.t @@ -4,6 +4,8 @@ use strict; use Test::More; my $total_tests = 72; use IkiWiki; +my $installed = $ENV{INSTALLED_TESTS}; + my $default_test_methods = '^test_*'; my @required_programs = qw( cvs @@ -606,12 +608,14 @@ sub _generate_and_configure_post_commit_hook { $config{wrapper} = $config{cvs_wrapper}; require IkiWiki::Wrapper; - { - no warnings 'once'; + if ($installed) { $IkiWiki::program_to_wrap = 'ikiwiki.out'; - # XXX substitute its interpreter to Makefile's $(PERL) - # XXX best solution: do this to all scripts during build } + else { + $IkiWiki::program_to_wrap = `which ikiwiki`; + } + # XXX substitute its interpreter to Makefile's $(PERL) + # XXX best solution: do this to all scripts during build IkiWiki::gen_wrapper(); my $cvs = "cvs -d $config{cvsrepo}"; diff --git a/t/git.t b/t/git.t index 0396ae065..8990a554e 100755 --- a/t/git.t +++ b/t/git.t @@ -27,8 +27,16 @@ $config{diffurl} = '/nonexistent/cgit/plain/[[file]]'; IkiWiki::loadplugins(); IkiWiki::checkconfig(); +my $makerepo; +if ($ENV{INSTALLED_TESTS}) { + $makerepo = "ikiwiki-makerepo"; +} +else { + $makerepo = "./ikiwiki-makerepo"; +} + ok (mkdir($config{srcdir})); -is (system("./ikiwiki-makerepo git $config{srcdir} $dir/repo"), 0); +is (system("$makerepo git $config{srcdir} $dir/repo"), 0); my @changes; @changes = IkiWiki::rcs_recentchanges(3); diff --git a/t/img.t b/t/img.t index 968200b3e..5e92f1aff 100755 --- a/t/img.t +++ b/t/img.t @@ -34,6 +34,22 @@ else { push @command, qw(--set usedirs=0 --plugin img t/tmp/in t/tmp/out --verbose); +my $installed = $ENV{INSTALLED_TESTS}; + +my @command; +if ($installed) { + @command = qw(ikiwiki); +} +else { + ok(! system("make -s ikiwiki.out")); + @command = qw(perl -I. ./ikiwiki.out + --underlaydir=underlays/basewiki + --set underlaydirbase=underlays + --templatedir=templates); +} + +push @command, qw(--set usedirs=0 --plugin img t/tmp/in t/tmp/out --verbose); + my $magick = new Image::Magick; $magick->Read("t/img/twopages.pdf"); diff --git a/t/inline.t b/t/inline.t index 726227b8f..536bd6d67 100755 --- a/t/inline.t +++ b/t/inline.t @@ -4,6 +4,24 @@ use strict; use Test::More; use IkiWiki; +my $installed = $ENV{INSTALLED_TESTS}; + +my @command; +if ($installed) { + @command = qw(ikiwiki); +} +else { + ok(! system("make -s ikiwiki.out")); + @command = qw(perl -I. ./ikiwiki.out + --underlaydir=underlays/basewiki + --set underlaydirbase=underlays + --templatedir=templates); +} + +push @command, qw(--set usedirs=0 --plugin inline + --url=http://example.com --cgiurl=http://example.com/ikiwiki.cgi + --rss --atom t/tmp/in t/tmp/out --verbose); + my $blob; ok(! system("rm -rf t/tmp")); @@ -33,13 +51,8 @@ foreach my $page (qw(protagonists/shepard protagonists/link write_old_file("$page.mdwn", "this page is {$page}"); } -ok(! system("make -s ikiwiki.out")); - -my $command = "perl -I. ./ikiwiki.out -set usedirs=0 -plugin inline -url=http://example.com -cgiurl=http://example.com/ikiwiki.cgi -rss -atom -underlaydir=underlays/basewiki -set underlaydirbase=underlays -templatedir=templates t/tmp/in t/tmp/out -verbose"; - -ok(! system($command)); - -ok(! system("$command -refresh")); +ok(! system(@command)); +ok(! system(@command, "--refresh")); $blob = readfile("t/tmp/out/protagonists.html"); like($blob, qr{Add a new post}, 'rootpage=yes gives postform'); diff --git a/t/permalink.t b/t/permalink.t index 36be984c5..edb05a81b 100755 --- a/t/permalink.t +++ b/t/permalink.t @@ -1,14 +1,31 @@ #!/usr/bin/perl use warnings; use strict; -use Test::More 'no_plan'; +use Test::More; + +my $installed = $ENV{INSTALLED_TESTS}; + +my @command; +if ($installed) { + @command = qw(ikiwiki); +} +else { + ok(! system("make -s ikiwiki.out")); + @command = qw(perl -I. ./ikiwiki.out + --underlaydir=underlays/basewiki + --set underlaydirbase=underlays + --templatedir=templates); +} ok(! system("rm -rf t/tmp")); ok(! system("mkdir t/tmp")); -ok(! system("make -s ikiwiki.out")); -ok(! system("perl -I. ./ikiwiki.out -plugin inline -url=http://example.com -cgiurl=http://example.com/ikiwiki.cgi -rss -atom -underlaydir=underlays/basewiki -set underlaydirbase=underlays -templatedir=templates t/tinyblog t/tmp/out")); +ok(! system(@command, qw(--plugin inline --url=http://example.com + --cgiurl=http://example.com/ikiwiki.cgi --rss --atom + t/tinyblog t/tmp/out))); # This guid should never, ever change, for any reason whatsoever! my $guid="http://example.com/post/"; ok(length `egrep '$guid' t/tmp/out/index.rss`); ok(length `egrep '$guid' t/tmp/out/index.atom`); ok(! system("rm -rf t/tmp t/tinyblog/.ikiwiki")); + +done_testing(); diff --git a/t/podcast.t b/t/podcast.t index 94505a05e..77c905bde 100755 --- a/t/podcast.t +++ b/t/podcast.t @@ -9,13 +9,28 @@ BEGIN { "XML::Feed and/or HTML::Parser or File::MimeInfo not available"}; } else { - eval q{use Test::More tests => 136}; + eval q{use Test::More tests => 137}; } } use Cwd; use File::Basename; +my $installed = $ENV{INSTALLED_TESTS}; + +my @base_command; +if ($installed) { + ok(1, "running installed"); + @base_command = qw(ikiwiki); +} +else { + ok(! system("make -s ikiwiki.out")); + @base_command = qw(perl -I. ./ikiwiki.out + --underlaydir=underlays/basewiki + --set underlaydirbase=underlays + --templatedir=templates); +} + my $tmp = 't/tmp'; my $statedir = 't/tinypodcast/.ikiwiki'; @@ -23,10 +38,8 @@ sub podcast { my $podcast_style = shift; my $baseurl = 'http://example.com'; - my @command = (qw(./ikiwiki.out -plugin inline -rss -atom)); - push @command, qw(-underlaydir=underlays/basewiki); - push @command, qw(-set underlaydirbase=underlays -templatedir=templates); - push @command, "-url=$baseurl", qw(t/tinypodcast), "$tmp/out"; + my @command = (@base_command, qw(--plugin inline --rss --atom)); + push @command, "--url=$baseurl", qw(t/tinypodcast), "$tmp/out"; ok(! system("mkdir $tmp"), q{setup}); @@ -113,9 +126,7 @@ sub podcast { } sub single_page_html { - my @command = (qw(./ikiwiki.out)); - push @command, qw(-underlaydir=underlays/basewiki); - push @command, qw(-set underlaydirbase=underlays -templatedir=templates); + my @command = @base_command; push @command, qw(t/tinypodcast), "$tmp/out"; ok(! system("mkdir $tmp"), @@ -158,9 +169,7 @@ sub single_page_html { } sub inlined_pages_html { - my @command = (qw(./ikiwiki.out -plugin inline)); - push @command, qw(-underlaydir=underlays/basewiki); - push @command, qw(-set underlaydirbase=underlays -templatedir=templates); + my @command = (@base_command, qw(--plugin inline)); push @command, qw(t/tinypodcast), "$tmp/out"; ok(! system("mkdir $tmp"), diff --git a/t/relativity.t b/t/relativity.t index 054f8f664..73145dfd7 100755 --- a/t/relativity.t +++ b/t/relativity.t @@ -16,6 +16,20 @@ use Errno qw(ENOENT); # Black-box (ish) test for relative linking between CGI and static content +my $installed = $ENV{INSTALLED_TESTS}; + +my @command; +if ($installed) { + @command = qw(ikiwiki); +} +else { + ok(! system("make -s ikiwiki.out")); + @command = qw(perl -I. ./ikiwiki.out + --underlaydir=underlays/basewiki + --set underlaydirbase=underlays + --templatedir=templates); +} + sub parse_cgi_content { my $content = shift; my %bits; @@ -53,7 +67,6 @@ sub write_setup_file { wikiname: this is the name of my wiki srcdir: t/tmp/in destdir: t/tmp/out -templatedir: templates $urlline cgiurl: $args{cgiurl} $w3mmodeline @@ -72,7 +85,7 @@ EOF sub thoroughly_rebuild { ok(unlink("t/tmp/ikiwiki.cgi") || $!{ENOENT}); - ok(! system("./ikiwiki.out --setup t/tmp/test.setup --rebuild --wrappers")); + ok(! system(@command, qw(--setup t/tmp/test.setup --rebuild --wrappers))); } sub check_cgi_mode_bits { @@ -132,7 +145,6 @@ sub run_cgi { } sub test_startup { - ok(! system("make -s ikiwiki.out")); ok(! system("rm -rf t/tmp")); ok(! system("mkdir t/tmp")); diff --git a/t/syntax.t b/t/syntax.t index b7c6efd58..1d496be2d 100755 --- a/t/syntax.t +++ b/t/syntax.t @@ -3,6 +3,8 @@ use warnings; use strict; use Test::More; +plan(skip_all => 'running installed') if $ENV{INSTALLED_TESTS}; + my @progs="ikiwiki.in"; my @libs="IkiWiki.pm"; # monotone, external, amazon_s3, po, and cvs diff --git a/t/template_syntax.t b/t/template_syntax.t index e3d1feca9..3e6509f35 100755 --- a/t/template_syntax.t +++ b/t/template_syntax.t @@ -3,6 +3,8 @@ use warnings; use strict; use Test::More; +plan(skip_all => 'running installed') if $ENV{INSTALLED_TESTS}; + my @templates=(glob("templates/*.tmpl"), glob("doc/templates/*.mdwn")); plan(tests => 2*@templates); diff --git a/t/templates_documented.t b/t/templates_documented.t index 826c51d36..4991e4521 100755 --- a/t/templates_documented.t +++ b/t/templates_documented.t @@ -1,7 +1,9 @@ #!/usr/bin/perl use warnings; use strict; -use Test::More 'no_plan'; +use Test::More; + +plan(skip_all => 'running installed') if $ENV{INSTALLED_TESTS}; $/=undef; open(IN, "doc/templates.mdwn") || die "doc/templates.mdwn: $!"; @@ -12,3 +14,5 @@ foreach my $file (glob("templates/*.tmpl")) { $file=~s/templates\///; ok($page =~ /\Q$file\E/, "$file documented on doc/templates.mdwn"); } + +done_testing(); diff --git a/t/trail.t b/t/trail.t index dce3b3c7e..cac64c366 100755 --- a/t/trail.t +++ b/t/trail.t @@ -1,7 +1,7 @@ #!/usr/bin/perl use warnings; use strict; -use Test::More 'no_plan'; +use Test::More; use IkiWiki; sub check_trail { @@ -27,6 +27,24 @@ my $blob; ok(! system("rm -rf t/tmp")); ok(! system("mkdir t/tmp")); +my $installed = $ENV{INSTALLED_TESTS}; + +my @command; +if ($installed) { + @command = qw(ikiwiki); +} +else { + ok(! system("make -s ikiwiki.out")); + @command = qw(perl -I. ./ikiwiki.out + --underlaydir=underlays/basewiki + --set underlaydirbase=underlays + --templatedir=templates); +} + +push @command, qw(--set usedirs=0 --plugin trail --plugin inline + --url=http://example.com --cgiurl=http://example.com/ikiwiki.cgi + --rss --atom t/tmp/in t/tmp/out --verbose); + # Write files with a date in the past, so that when we refresh, # the update is detected. sub write_old_file { @@ -129,13 +147,8 @@ write_old_file("wind_in_the_willows.mdwn", <badger<\/a>/m); @@ -232,7 +245,7 @@ writefile("limited/c.mdwn", "t/tmp/in", '[[!meta title="New C page"]]c'); writefile("untrail.mdwn", "t/tmp/in", "no longer a trail"); -ok(! system("$command -refresh")); +ok(! system(@command, "--refresh")); check_trail("add/a.html", "n=add/b p="); check_trail("add/b.html", "n=add/c p=add/a"); @@ -290,3 +303,5 @@ check_no_trail("untrail/a.html"); check_no_trail("untrail/b.html"); ok(! system("rm -rf t/tmp")); + +done_testing(); -- 2.39.2