Skip to content

Commit 61a6e0d

Browse files
committed
Merge pull request phpredis#243 from remicollet/master
Skipped tests
2 parents 3e9f43b + deca4fa commit 61a6e0d

File tree

2 files changed

+29
-12
lines changed

2 files changed

+29
-12
lines changed

tests/TestRedis.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ public function testIncrByFloat()
389389
{
390390
// incrbyfloat is new in 2.6.0
391391
if (version_compare($this->version, "2.5.0", "lt")) {
392-
return;
392+
$this->markTestSkipped();
393393
}
394394

395395
$this->redis->delete('key');
@@ -1632,7 +1632,7 @@ public function testInfoCommandStats() {
16321632

16331633
// INFO COMMANDSTATS is new in 2.6.0
16341634
if (version_compare($this->version, "2.5.0", "lt")) {
1635-
return;
1635+
$this->markTestSkipped();
16361636
}
16371637

16381638
$info = $this->redis->info("COMMANDSTATS");
@@ -2988,7 +2988,7 @@ private function checkSerializer($mode) {
29882988
public function testDumpRestore() {
29892989

29902990
if (version_compare($this->version, "2.5.0", "lt")) {
2991-
return;
2991+
$this->markTestSkipped();
29922992
}
29932993

29942994
$this->redis->del('foo');
@@ -3053,7 +3053,7 @@ private function array_diff_recursive($aArray1, $aArray2) {
30533053
public function testScript() {
30543054

30553055
if (version_compare($this->version, "2.5.0", "lt")) {
3056-
return;
3056+
$this->markTestSkipped();
30573057
}
30583058

30593059
// Flush any scripts we have
@@ -3085,7 +3085,7 @@ public function testScript() {
30853085
public function testEval() {
30863086

30873087
if (version_compare($this->version, "2.5.0", "lt")) {
3088-
return;
3088+
$this->markTestSkipped();
30893089
}
30903090

30913091
// Basic single line response tests
@@ -3203,7 +3203,7 @@ public function testEval() {
32033203
public function testEvalSHA() {
32043204

32053205
if (version_compare($this->version, "2.5.0", "lt")) {
3206-
return;
3206+
$this->markTestSkipped();
32073207
}
32083208

32093209
// Flush any loaded scripts
@@ -3301,7 +3301,7 @@ public function testReconnectSelect() {
33013301
public function testTime() {
33023302

33033303
if (version_compare($this->version, "2.5.0", "lt")) {
3304-
return;
3304+
$this->markTestSkipped();
33053305
}
33063306

33073307
$time_arr = $this->redis->time();

tests/test.php

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
class TestSuite {
55

66
public static $errors = array();
7+
public static $warnings = array();
78

89
protected function assertFalse($bool) {
910
$this->assertTrue(!$bool);
@@ -14,7 +15,6 @@ protected function assertTrue($bool) {
1415
return;
1516

1617
$bt = debug_backtrace(false);
17-
$count = count($bt);
1818
self::$errors []= sprintf("Assertion failed: %s:%d (%s)\n",
1919
$bt[0]["file"], $bt[0]["line"], $bt[1]["function"]);
2020
}
@@ -24,12 +24,19 @@ protected function assertEquals($a, $b) {
2424
return;
2525

2626
$bt = debug_backtrace(false);
27-
$count = count($bt);
2827
self::$errors []= sprintf("Assertion failed (%s !== %s): %s:%d (%s)\n",
2928
print_r($a, true), print_r($b, true),
3029
$bt[0]["file"], $bt[0]["line"], $bt[1]["function"]);
3130
}
3231

32+
protected function markTestSkipped($msg='') {
33+
$bt = debug_backtrace(false);
34+
self::$warnings []= sprintf("Skipped test: %s:%d (%s) %s\n",
35+
$bt[0]["file"], $bt[0]["line"], $bt[1]["function"], $msg);
36+
37+
throw new Exception($msg);
38+
}
39+
3340
public static function run($className) {
3441

3542
$rc = new ReflectionClass($className);
@@ -43,11 +50,21 @@ public static function run($className) {
4350

4451
$count = count($className::$errors);
4552
$rt = new $className;
46-
$rt->setUp();
47-
$rt->$name();
48-
echo ($count === count($className::$errors)) ? "." : "F";
53+
try {
54+
$rt->setUp();
55+
$rt->$name();
56+
echo ($count === count($className::$errors)) ? "." : "F";
57+
} catch (Exception $e) {
58+
if ($e instanceof RedisException) {
59+
$className::$errors[] = "Uncaught exception '".$e->getMessage()."' ($name)\n";
60+
echo 'F';
61+
} else {
62+
echo 'S';
63+
}
64+
}
4965
}
5066
echo "\n";
67+
echo implode('', $className::$warnings);
5168

5269
if(empty($className::$errors)) {
5370
echo "All tests passed.\n";

0 commit comments

Comments
 (0)