Changed phpunit Makefile to require 'make destructive' to run the test suites as...
authorBrion Vibber <brion@users.mediawiki.org>
Sun, 3 Oct 2010 21:25:33 +0000 (21:25 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sun, 3 Oct 2010 21:25:33 +0000 (21:25 +0000)
Looks like somebody's snuck a bunch of destructive tests into the default PHPUnit test suite;
this is unsafe and could cause admins and developers to damage their wikis contents accidentally,
not realizing that their main page will be deleted etc.

Tests should be split up into those which alter the live database and those that don't; only
those which are non-destructive should run unless explicitly requested.

maintenance/tests/phpunit/Makefile
maintenance/tests/phpunit/README
maintenance/tests/phpunit/TODO

index 1f6539e..d57ee5d 100644 (file)
@@ -1,11 +1,23 @@
-.PHONY: help test phpunit install coverage
+.PHONY: help test phpunit install coverage warning destructive
 
 SHELL = /bin/sh
 CONFIG_FILE = $(shell pwd)/suite.xml
 FLAGS = 
 PU = phpunit --configuration ${CONFIG_FILE}
 
-all test: phpunit
+all test: warning
+
+warning:
+       @echo "WARNING -- these tests are DESTRUCTIVE and will alter your wiki."
+       @echo "DO NOT RUN THESE TESTS on a production wiki."
+       @echo ""
+       @echo "Until the default suites are made non-destructive, you can run"
+       @echo "the destructive tests like so:"
+       @echo ""
+       @echo "  make destructive"
+       @echo ""
+
+destructive: phpunit
 
 phpunit:
        ${PU}
index f0f84c3..ce78270 100644 (file)
@@ -3,6 +3,12 @@
 Some quickie unit tests done with the PHPUnit testing framework. To run the
 test suite, run 'make test' in this (maintenance/tests/phpunit) directory.
 
+=== WARNING ===
+
+The current versions of some of these tests are DESTRUCTIVE AND WILL ALTER
+YOUR WIKI'S CONTENTS. DO NOT RUN ON A PRODUCTION SYSTEM OR ONE WHERE YOU
+NEED TO RETAIN YOUR DATA.
+
 === Installation ===
 
 PHPUnit is no longer maintained by PEAR. To get the current version of
index b9f3a3a..76f38c1 100644 (file)
@@ -1,5 +1,9 @@
 == Things To Do ==
 
+* DEFAULT TESTS NEED TO MADE NON-DESTRUCTIVE. Any destructive tests which alter the contents of the live wiki need to
+be protected with an explicit confirmation so people exploring their system don't accidentally destroy their main page
+or register user accounts with default passwords.
+
 * Most of the tests are named poorly; naming should describe a use case in story-like language, not simply identify the
 unit under test. An example would be the difference between testCalculate and testAddingIntegersTogetherWorks.
 * Many of the tests make multiple assertions, and are thus not unitary tests. By using data-providers and more use-case