mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-09 15:28:40 +00:00
[3.1.0] When flush fails, fail SimpleTest
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1641 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
1d25be875d
commit
e78df4dc9f
2
NEWS
2
NEWS
@ -80,6 +80,8 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
|
|||||||
. HTMLPURIFIER_STRICT removed; no validation is performed on runtime, only
|
. HTMLPURIFIER_STRICT removed; no validation is performed on runtime, only
|
||||||
during cache generation
|
during cache generation
|
||||||
. Reordered script calls in maintenance/flush.php
|
. Reordered script calls in maintenance/flush.php
|
||||||
|
. Command line scripts now honor exit codes
|
||||||
|
. When --flush fails in unit testers, abort tests and print message
|
||||||
|
|
||||||
3.0.0, released 2008-01-06
|
3.0.0, released 2008-01-06
|
||||||
# HTML Purifier is PHP 5 only! The 2.1.x branch will be maintained
|
# HTML Purifier is PHP 5 only! The 2.1.x branch will be maintained
|
||||||
|
3
TODO
3
TODO
@ -27,9 +27,6 @@ DOCUMENTATION
|
|||||||
IMPORTANT FEATURES
|
IMPORTANT FEATURES
|
||||||
- Get everything into configuration objects (filters, I'm looking at you)
|
- Get everything into configuration objects (filters, I'm looking at you)
|
||||||
- Factor out command line parser into its own class, and unit test it
|
- Factor out command line parser into its own class, and unit test it
|
||||||
- Verbose mode for webtester that includes transcript from command line
|
|
||||||
- Command line maintenance scripts must complain with exit(1) if there are
|
|
||||||
fatal errors
|
|
||||||
- Emit notices when aliases are used (allow muting these errors)
|
- Emit notices when aliases are used (allow muting these errors)
|
||||||
|
|
||||||
CONFIGDOC
|
CONFIGDOC
|
||||||
|
@ -178,3 +178,33 @@ function printTokens($tokens, $index = null) {
|
|||||||
$string .= '</pre>';
|
$string .= '</pre>';
|
||||||
echo $string;
|
echo $string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenient "insta-fail" test-case to add if any outside things fail
|
||||||
|
*/
|
||||||
|
class FailedTest extends UnitTestCase {
|
||||||
|
protected $msg, $details;
|
||||||
|
public function __construct($msg, $details = null) {
|
||||||
|
$this->msg = $msg;
|
||||||
|
$this->details = $details;
|
||||||
|
}
|
||||||
|
public function test() {
|
||||||
|
$this->fail($this->msg);
|
||||||
|
if ($this->details) $this->_reporter->paintFormattedMessage($this->details);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flushes all caches, and fatally errors out if there's a problem.
|
||||||
|
*/
|
||||||
|
function htmlpurifier_flush($php, $reporter) {
|
||||||
|
exec($php . ' ../maintenance/flush.php', $out, $status);
|
||||||
|
if ($status) {
|
||||||
|
$test = new FailedTest(
|
||||||
|
'maintenance/flush.php returned non-zero exit status',
|
||||||
|
wordwrap(implode("\n", $out), 80)
|
||||||
|
);
|
||||||
|
$test->run($reporter);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -59,12 +59,17 @@ if ($AC['disable-phpt'] && $AC['only-phpt']) {
|
|||||||
|
|
||||||
// Shell-script code is executed
|
// Shell-script code is executed
|
||||||
|
|
||||||
|
if ($AC['xml']) {
|
||||||
|
if (!SimpleReporter::inCli()) header('Content-Type: text/xml;charset=UTF-8');
|
||||||
|
$reporter = new XmlReporter();
|
||||||
|
} elseif (SimpleReporter::inCli()) {
|
||||||
|
$reporter = new TextReporter();
|
||||||
|
} else {
|
||||||
|
$reporter = new HTMLPurifier_SimpleTest_Reporter('UTF-8', $AC);
|
||||||
|
}
|
||||||
|
|
||||||
if ($AC['flush']) {
|
if ($AC['flush']) {
|
||||||
if (SimpleReporter::inCli() && !$AC['xml']) {
|
htmlpurifier_flush($AC['php'], $reporter);
|
||||||
passthru($AC['php'] . ' ../maintenance/flush.php');
|
|
||||||
} else {
|
|
||||||
shell_exec($AC['php'] . ' ../maintenance/flush.php');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize and load HTML Purifier
|
// initialize and load HTML Purifier
|
||||||
@ -157,15 +162,6 @@ if ($AC['file']) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($AC['xml']) {
|
|
||||||
if (!SimpleReporter::inCli()) header('Content-Type: text/xml;charset=UTF-8');
|
|
||||||
$reporter = new XmlReporter();
|
|
||||||
} elseif (SimpleReporter::inCli()) {
|
|
||||||
$reporter = new TextReporter();
|
|
||||||
} else {
|
|
||||||
$reporter = new HTMLPurifier_SimpleTest_Reporter('UTF-8', $AC);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($AC['dry']) $reporter->makeDry();
|
if ($AC['dry']) $reporter->makeDry();
|
||||||
|
|
||||||
$test->run($reporter);
|
$test->run($reporter);
|
||||||
|
@ -46,10 +46,15 @@ $aliases = array(
|
|||||||
);
|
);
|
||||||
htmlpurifier_parse_args($AC, $aliases);
|
htmlpurifier_parse_args($AC, $aliases);
|
||||||
|
|
||||||
// Regenerate any necessary files
|
if ($AC['xml']) {
|
||||||
shell_exec($AC['php'] . ' ../maintenance/flush.php');
|
$reporter = new XmlReporter();
|
||||||
|
} else {
|
||||||
|
$reporter = new TextReporter();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Regenerate any necessary files
|
||||||
|
htmlpurifier_flush($AC['php'], $reporter);
|
||||||
|
|
||||||
$test = new TestSuite('HTML Purifier Multiple Versions Test');
|
|
||||||
$file = '';
|
$file = '';
|
||||||
|
|
||||||
$test_files = array();
|
$test_files = array();
|
||||||
@ -59,13 +64,14 @@ if ($AC['file']) {
|
|||||||
if (isset($test_files_lookup[$AC['file']])) {
|
if (isset($test_files_lookup[$AC['file']])) {
|
||||||
$file = '--file=' . $AC['file'];
|
$file = '--file=' . $AC['file'];
|
||||||
} else {
|
} else {
|
||||||
echo "Invalid file passed\n";
|
throw new Exception("Invalid file passed");
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// This allows us to get out of having to do dry runs.
|
// This allows us to get out of having to do dry runs.
|
||||||
$size = count($test_files);
|
$size = count($test_files);
|
||||||
|
|
||||||
|
// Setup the test
|
||||||
|
$test = new TestSuite('HTML Purifier Multiple Versions Test');
|
||||||
foreach ($versions_to_test as $version) {
|
foreach ($versions_to_test as $version) {
|
||||||
$flush = '';
|
$flush = '';
|
||||||
if (is_array($version)) {
|
if (is_array($version)) {
|
||||||
@ -104,11 +110,6 @@ foreach ($versions_to_test as $version) {
|
|||||||
// add more websites, i.e. more configurations to test.
|
// add more websites, i.e. more configurations to test.
|
||||||
$test->addTestCase(new RemoteTestCase('http://htmlpurifier.org/dev/tests/?xml=1', 'http://htmlpurifier.org/dev/tests/?xml=1&dry=1&flush=1'));
|
$test->addTestCase(new RemoteTestCase('http://htmlpurifier.org/dev/tests/?xml=1', 'http://htmlpurifier.org/dev/tests/?xml=1&dry=1&flush=1'));
|
||||||
|
|
||||||
if ($AC['xml']) {
|
|
||||||
$reporter = new XmlReporter();
|
|
||||||
} else {
|
|
||||||
$reporter = new TextReporter();
|
|
||||||
}
|
|
||||||
$test->run($reporter);
|
$test->run($reporter);
|
||||||
|
|
||||||
shell_exec($AC['php'] . ' ../maintenance/flush-definition-cache.php');
|
shell_exec($AC['php'] . ' ../maintenance/flush-definition-cache.php');
|
||||||
|
Loading…
Reference in New Issue
Block a user