summaryrefslogtreecommitdiff
path: root/t/conflicts.t
blob: d7e04d3ae39a66b1bdcd711aa0aa0ee12f0584ec (plain)
  1. #!/usr/bin/perl
  2. # Tests for bugs relating to conflicting files in the srcdir
  3. use warnings;
  4. use strict;
  5. use Test::More tests => 106;
  6. # setup
  7. my $srcdir="t/tmp/src";
  8. my $destdir="t/tmp/dest";
  9. ok(! system("make -s ikiwiki.out"));
  10. # runs ikiwiki to build test site
  11. sub runiki {
  12. my $testdesc=shift;
  13. ok((! system("perl -I. ./ikiwiki.out -plugin txt -plugin rawhtml -underlaydir=underlays/basewiki -set underlaydirbase=underlays -templatedir=templates $srcdir $destdir @_")),
  14. $testdesc);
  15. }
  16. sub refreshiki {
  17. runiki(shift);
  18. }
  19. sub setupiki {
  20. ok(! system("rm -rf $srcdir/.ikiwiki $destdir"));
  21. runiki(shift, "--rebuild");
  22. }
  23. sub newsrcdir {
  24. ok(! system("rm -rf $srcdir $destdir"));
  25. ok(! system("mkdir -p $srcdir"));
  26. }
  27. # At one point, changing the extension of the source file of a page caused
  28. # ikiwiki to fail.
  29. newsrcdir();
  30. ok(! system("touch $srcdir/foo.mdwn"));
  31. setupiki("initial setup");
  32. ok(! system("mv $srcdir/foo.mdwn $srcdir/foo.txt"));
  33. refreshiki("changed extension of source file of page");
  34. ok(! system("mv $srcdir/foo.txt $srcdir/foo.mdwn"));
  35. refreshiki("changed extension of source file of page 2");
  36. # Conflicting page sources is sorta undefined behavior,
  37. # but should not crash ikiwiki.
  38. # Added when refreshing
  39. ok(! system("touch $srcdir/foo.txt"));
  40. refreshiki("conflicting page sources in refresh");
  41. # Present during setup
  42. newsrcdir();
  43. ok(! system("touch $srcdir/foo.mdwn"));
  44. ok(! system("touch $srcdir/foo.txt"));
  45. setupiki("conflicting page sources in setup");
  46. # Page and non-page file with same pagename.
  47. newsrcdir();
  48. ok(! system("touch $srcdir/foo.mdwn"));
  49. ok(! system("touch $srcdir/foo"));
  50. setupiki("conflicting page and non-page in setup");
  51. newsrcdir();
  52. ok(! system("touch $srcdir/foo.mdwn"));
  53. setupiki("initial setup");
  54. ok(! system("touch $srcdir/foo"));
  55. refreshiki("conflicting page added (non-page already existing) in refresh");
  56. newsrcdir();
  57. ok(! system("touch $srcdir/foo"));
  58. setupiki("initial setup");
  59. ok(! system("touch $srcdir/foo.mdwn"));
  60. refreshiki("conflicting non-page added (page already existing) in refresh");
  61. # Page that renders to a file that is also a subdirectory holding another
  62. # file.
  63. newsrcdir();
  64. ok(! system("touch $srcdir/foo.mdwn"));
  65. ok(! system("mkdir -p $srcdir/foo/index.html"));
  66. ok(! system("touch $srcdir/foo/index.html/bar.mdwn"));
  67. setupiki("conflicting page file and subdirectory");
  68. newsrcdir();
  69. ok(! system("touch $srcdir/foo.mdwn"));
  70. ok(! system("mkdir -p $srcdir/foo/index.html"));
  71. ok(! system("touch $srcdir/foo/index.html/bar"));
  72. setupiki("conflicting page file and subdirectory 2");
  73. # Changing a page file into a non-page could also cause ikiwiki to fail.
  74. newsrcdir();
  75. ok(! system("touch $srcdir/foo.mdwn"));
  76. setupiki("initial setup");
  77. ok(! system("mv $srcdir/foo.mdwn $srcdir/foo"));
  78. refreshiki("page file turned into non-page");
  79. # Changing a non-page file into a page could also cause ikiwiki to fail.
  80. newsrcdir();
  81. ok(! system("touch $srcdir/foo"));
  82. setupiki("initial setup");
  83. ok(! system("mv $srcdir/foo $srcdir/foo.mdwn"));
  84. refreshiki("non-page file turned into page");
  85. # What if a page renders to the same html file that a rawhtml file provides?
  86. # Added when refreshing
  87. newsrcdir();
  88. ok(! system("touch $srcdir/foo.mdwn"));
  89. setupiki("initial setup");
  90. ok(! system("mkdir -p $srcdir/foo"));
  91. ok(! system("touch $srcdir/foo/index.html"));
  92. refreshiki("rawhtml file rendered same as existing page in refresh");
  93. # Moved when refreshing
  94. newsrcdir();
  95. ok(! system("touch $srcdir/foo.mdwn"));
  96. setupiki("initial setup");
  97. ok(! system("mkdir -p $srcdir/foo"));
  98. ok(! system("mv $srcdir/foo.mdwn $srcdir/foo/index.html"));
  99. refreshiki("existing page moved to rawhtml file in refresh");
  100. # Inverse added when refreshing
  101. newsrcdir();
  102. ok(! system("mkdir -p $srcdir/foo"));
  103. ok(! system("touch $srcdir/foo/index.html"));
  104. setupiki("initial setup");
  105. ok(! system("touch $srcdir/foo.mdwn"));
  106. refreshiki("page rendered same as existing rawhtml file in refresh");
  107. # Inverse moved when refreshing
  108. newsrcdir();
  109. ok(! system("mkdir -p $srcdir/foo"));
  110. ok(! system("touch $srcdir/foo/index.html"));
  111. setupiki("initial setup");
  112. ok(! system("mv $srcdir/foo/index.html $srcdir/foo.mdwn"));
  113. refreshiki("rawhtml file moved to page in refresh");
  114. # Present during setup
  115. newsrcdir();
  116. ok(! system("touch $srcdir/foo.mdwn"));
  117. ok(! system("mkdir -p $srcdir/foo"));
  118. ok(! system("touch $srcdir/foo/index.html"));
  119. setupiki("rawhtml file rendered same as existing page in setup");
  120. # cleanup
  121. ok(! system("rm -rf t/tmp"));