From 1b6d97308b0a079e517fb1bd30a3e5fb2ccd0650 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 16 Jan 2007 23:26:38 +0000 Subject: [PATCH] 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. --- maintenance/parserTests.inc | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) 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(); + } +} + ?> -- 2.20.1