Almost-minimal filesystem based blog.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
2.9 KiB

  1. #!/usr/bin/perl
  2. =pod
  3. =head1 NAME
  4. validate.pl - W3C validate markup from Wala.pm
  5. =head1 SYNOPSIS
  6. Given a working installation and configuration file:
  7. ./validate.pl
  8. =head1 DESCRIPTION
  9. These tests are aimed at a working installation with several files in place,
  10. and require Test::HTML::W3C as well as Test::Simple. For the time being, I'm
  11. using "valid W3C HTML" as a proxy for "not broken", and a number of larger
  12. pages as a proxy for their component features. This works surprisingly well for
  13. much of what the module does.
  14. What these tests don't validate in any way is the handling of user input,
  15. writing of pages, change logging, or edit conflict resolution. I'll do
  16. something about this, eventually. There are also be some issues around
  17. testing with different configurations.
  18. Nothing here should be destructive.
  19. =head1 SEE ALSO
  20. test.pl in Wala Wiki distribution, Test::HTML::W3C.
  21. =cut
  22. use strict;
  23. use warnings;
  24. use lib 'lib';
  25. use Test::HTML::W3C 'show_detail';
  26. use Test::Simple tests => 13;
  27. use Wala qw(%DISPLAY_CONF);
  28. # TESTS
  29. section ('configuration');
  30. our (%WalaConf, %DISPLAY_CONF);
  31. ok (do 'p1k3.conf.pl', "do conf.pl");
  32. ok (defined %WalaConf, 'External configuration hash defined.');
  33. ok (my $w = Wala->new(%WalaConf), 'got Wala object.');
  34. # This will turn off stuff that breaks testing.
  35. $w->TestMode(1);
  36. section ('starting markup validation');
  37. render('HomePage', 'complete rendered HomePage validates');
  38. render('PageIndex', 'PageIndex validates' );
  39. render('M', 'Specific letter index validates' );
  40. render('RecentChanges', 'RecentChanges validates' );
  41. render('PageChangeTimes', 'PageChangeTimes validates' );
  42. render('WalaCode', 'WalaCode validates' );
  43. is_valid_markup (
  44. $w->get_header('SandBox') . $w->edit_form('SandBox') .
  45. '</body></html>',
  46. "Edit form validates"
  47. ) or diag_html();
  48. pause(1);
  49. is_valid_markup (
  50. $w->get_header('Preferences') . $w->get_preferences_form('HomePage') .
  51. '</body></html>',
  52. "Preferences form validates"
  53. ) or diag_html();
  54. pause(1);
  55. my $cacheval = $w->UseCache;
  56. USECACHE: {
  57. $w->UseCache(1);
  58. render('SandBox', 'SandBox validates with caching explicitly enabled.');
  59. }
  60. NOCACHE: {
  61. $w->UseCache(0);
  62. render('SandBox', 'SandBox validates with caching explicitly disabled.' );
  63. }
  64. $w->UseCache($cacheval);
  65. # END OF TESTS
  66. # Utility routines.
  67. sub pause {
  68. my $time = shift;
  69. #print " pausing $time seconds\n";
  70. sleep $time;
  71. }
  72. sub section {
  73. my $msg = shift;
  74. print "\n-- $msg --\n\n";
  75. }
  76. sub render {
  77. my $page = shift;
  78. my $msg = shift;
  79. my $markup = $w->get_header($page)
  80. . $w->print_page($page)
  81. . $w->get_footer($page);
  82. is_valid_markup (
  83. $markup,
  84. $msg
  85. ) or diag_html();
  86. #print $markup;
  87. pause(1);
  88. }