r74238 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74237‎ | r74238 | r74239 >
Date:21:25, 3 October 2010
Author:brion
Status:ok (Comments)
Tags:
Comment:
Changed phpunit Makefile to require 'make destructive' to run the test suites as a temporary safety check.

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.
Modified paths:
  • /trunk/phase3/maintenance/tests/phpunit/Makefile (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/README (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/TODO (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/phpunit/TODO
@@ -1,5 +1,9 @@
22 == Things To Do ==
33
 4+* DEFAULT TESTS NEED TO MADE NON-DESTRUCTIVE. Any destructive tests which alter the contents of the live wiki need to
 5+be protected with an explicit confirmation so people exploring their system don't accidentally destroy their main page
 6+or register user accounts with default passwords.
 7+
48 * Most of the tests are named poorly; naming should describe a use case in story-like language, not simply identify the
59 unit under test. An example would be the difference between testCalculate and testAddingIntegersTogetherWorks.
610 * Many of the tests make multiple assertions, and are thus not unitary tests. By using data-providers and more use-case
Index: trunk/phase3/maintenance/tests/phpunit/Makefile
@@ -1,12 +1,24 @@
2 -.PHONY: help test phpunit install coverage
 2+.PHONY: help test phpunit install coverage warning destructive
33
44 SHELL = /bin/sh
55 CONFIG_FILE = $(shell pwd)/suite.xml
66 FLAGS =
77 PU = phpunit --configuration ${CONFIG_FILE}
88
9 -all test: phpunit
 9+all test: warning
1010
 11+warning:
 12+ @echo "WARNING -- these tests are DESTRUCTIVE and will alter your wiki."
 13+ @echo "DO NOT RUN THESE TESTS on a production wiki."
 14+ @echo ""
 15+ @echo "Until the default suites are made non-destructive, you can run"
 16+ @echo "the destructive tests like so:"
 17+ @echo ""
 18+ @echo " make destructive"
 19+ @echo ""
 20+
 21+destructive: phpunit
 22+
1123 phpunit:
1224 ${PU}
1325
Index: trunk/phase3/maintenance/tests/phpunit/README
@@ -3,6 +3,12 @@
44 Some quickie unit tests done with the PHPUnit testing framework. To run the
55 test suite, run 'make test' in this (maintenance/tests/phpunit) directory.
66
 7+=== WARNING ===
 8+
 9+The current versions of some of these tests are DESTRUCTIVE AND WILL ALTER
 10+YOUR WIKI'S CONTENTS. DO NOT RUN ON A PRODUCTION SYSTEM OR ONE WHERE YOU
 11+NEED TO RETAIN YOUR DATA.
 12+
713 === Installation ===
814
915 PHPUnit is no longer maintained by PEAR. To get the current version of

Comments

#Comment by Hashar (talk | contribs)   23:21, 12 November 2010

Note: this commit does not fix the root cause but at least prevent any issues with a production wiki. Marking 'ok'

Status & tagging log