Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add 'markTestSkipped' method to test suite, improves report

  • Loading branch information...
commit deca4fa30c07a56764ba3a3df201ae54e7a5985d 1 parent 5df5153
@remicollet authored
Showing with 29 additions and 12 deletions.
  1. +7 −7 tests/TestRedis.php
  2. +22 −5 tests/test.php
View
14 tests/TestRedis.php
@@ -389,7 +389,7 @@ public function testIncrByFloat()
{
// incrbyfloat is new in 2.6.0
if (version_compare($this->version, "2.5.0", "lt")) {
- return;
+ $this->markTestSkipped();
}
$this->redis->delete('key');
@@ -1632,7 +1632,7 @@ public function testInfoCommandStats() {
// INFO COMMANDSTATS is new in 2.6.0
if (version_compare($this->version, "2.5.0", "lt")) {
- return;
+ $this->markTestSkipped();
}
$info = $this->redis->info("COMMANDSTATS");
@@ -2988,7 +2988,7 @@ private function checkSerializer($mode) {
public function testDumpRestore() {
if (version_compare($this->version, "2.5.0", "lt")) {
- return;
+ $this->markTestSkipped();
}
$this->redis->del('foo');
@@ -3053,7 +3053,7 @@ private function array_diff_recursive($aArray1, $aArray2) {
public function testScript() {
if (version_compare($this->version, "2.5.0", "lt")) {
- return;
+ $this->markTestSkipped();
}
// Flush any scripts we have
@@ -3085,7 +3085,7 @@ public function testScript() {
public function testEval() {
if (version_compare($this->version, "2.5.0", "lt")) {
- return;
+ $this->markTestSkipped();
}
// Basic single line response tests
@@ -3203,7 +3203,7 @@ public function testEval() {
public function testEvalSHA() {
if (version_compare($this->version, "2.5.0", "lt")) {
- return;
+ $this->markTestSkipped();
}
// Flush any loaded scripts
@@ -3301,7 +3301,7 @@ public function testReconnectSelect() {
public function testTime() {
if (version_compare($this->version, "2.5.0", "lt")) {
- return;
+ $this->markTestSkipped();
}
$time_arr = $this->redis->time();
View
27 tests/test.php
@@ -4,6 +4,7 @@
class TestSuite {
public static $errors = array();
+ public static $warnings = array();
protected function assertFalse($bool) {
$this->assertTrue(!$bool);
@@ -14,7 +15,6 @@ protected function assertTrue($bool) {
return;
$bt = debug_backtrace(false);
- $count = count($bt);
self::$errors []= sprintf("Assertion failed: %s:%d (%s)\n",
$bt[0]["file"], $bt[0]["line"], $bt[1]["function"]);
}
@@ -24,12 +24,19 @@ protected function assertEquals($a, $b) {
return;
$bt = debug_backtrace(false);
- $count = count($bt);
self::$errors []= sprintf("Assertion failed (%s !== %s): %s:%d (%s)\n",
print_r($a, true), print_r($b, true),
$bt[0]["file"], $bt[0]["line"], $bt[1]["function"]);
}
+ protected function markTestSkipped($msg='') {
+ $bt = debug_backtrace(false);
+ self::$warnings []= sprintf("Skipped test: %s:%d (%s) %s\n",
+ $bt[0]["file"], $bt[0]["line"], $bt[1]["function"], $msg);
+
+ throw new Exception($msg);
+ }
+
public static function run($className) {
$rc = new ReflectionClass($className);
@@ -43,11 +50,21 @@ public static function run($className) {
$count = count($className::$errors);
$rt = new $className;
- $rt->setUp();
- $rt->$name();
- echo ($count === count($className::$errors)) ? "." : "F";
+ try {
+ $rt->setUp();
+ $rt->$name();
+ echo ($count === count($className::$errors)) ? "." : "F";
+ } catch (Exception $e) {
+ if ($e instanceof RedisException) {
+ $className::$errors[] = "Uncaught exception '".$e->getMessage()."' ($name)\n";
+ echo 'F';
+ } else {
+ echo 'S';
+ }
+ }
}
echo "\n";
+ echo implode('', $className::$warnings);
if(empty($className::$errors)) {
echo "All tests passed.\n";
Please sign in to comment.
Something went wrong with that request. Please try again.