From: Brion Vibber Date: Tue, 16 Jan 2007 23:26:38 +0000 (+0000) Subject: Add --compare option to show comparison to previous results as with --record, but... X-Git-Tag: 1.31.0-rc.0~54354 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/fiche.php?a=commitdiff_plain;h=1b6d97308b0a079e517fb1bd30a3e5fb2ccd0650;p=lhc%2Fweb%2Fwiklou.git Add --compare option to show comparison to previous results as with --record, but throw away the data at the end. May be useful when fiddling with code, to confirm that you've returned to your original state. --- diff --git a/maintenance/parserTests.inc b/maintenance/parserTests.inc index fca76969bd..e18178a0fc 100644 --- a/maintenance/parserTests.inc +++ b/maintenance/parserTests.inc @@ -93,7 +93,8 @@ class ParserTest { $this->showProgress = !isset( $options['quiet'] ); $this->showFailure = !( isset( $options['quiet'] ) - && isset( $options['record'] ) ); // redundant output + && ( isset( $options['record'] ) + || isset( $options['compare'] ) ) ); // redundant output $this->showOutput = isset( $options['show-output'] ); @@ -107,6 +108,8 @@ class ParserTest { if( isset( $options['record'] ) ) { $this->recorder = new DbTestRecorder( $this->term ); + } elseif( isset( $options['compare'] ) ) { + $this->recorder = new DbTestPreviewer( $this->term ); } else { $this->recorder = new TestRecorder( $this->term ); } @@ -146,8 +149,8 @@ class ParserTest { foreach( $filenames as $filename ) { $ok = $this->runFile( $filename ) && $ok; } - $this->recorder->end(); $this->recorder->report(); + $this->recorder->end(); return $ok; } @@ -949,9 +952,9 @@ class TestRecorder { } class DbTestRecorder extends TestRecorder { - private $db; ///< Database connection to the main DB - private $curRun; ///< run ID number for the current run - private $prevRun; ///< run ID number for the previous run, if any + protected $db; ///< Database connection to the main DB + protected $curRun; ///< run ID number for the current run + protected $prevRun; ///< run ID number for the previous run, if any function __construct( $term ) { parent::__construct( $term ); @@ -1092,4 +1095,14 @@ class DbTestRecorder extends TestRecorder { } +class DbTestPreviewer extends DbTestRecorder { + /** + * Commit transaction and clean up for result recording + */ + function end() { + $this->db->rollback(); + TestRecorder::end(); + } +} + ?>