|
14 | 14 | $phpBinPath = 'php '; |
15 | 15 | $status = 0; |
16 | 16 | $dir = __DIR__; |
| 17 | +$projectDir = dirname($dir, 2); |
17 | 18 | $driver = $argv[ 1 ] ?? 'Files'; |
18 | 19 | $phpBinPath = $_SERVER['PHP_BIN_PATH'] ?? 'php'; |
19 | 20 | $failedTests = []; |
| 21 | +$skippedTests = []; |
20 | 22 |
|
21 | 23 | /** |
22 | 24 | * @param string $pattern |
|
38 | 40 | foreach ($globCallback(PFC_TEST_DIR . DIRECTORY_SEPARATOR . '*.test.php') as $filename) { |
39 | 41 | $climate->backgroundLightYellow()->blue()->out('---'); |
40 | 42 | $command = "{$phpBinPath} -f {$filename} {$driver}"; |
41 | | - $climate->out("<yellow>phpfastcache@unit-tests</yellow> <blue>{$dir}</blue> <green>#</green> <red>$command</red>"); |
| 43 | + $shortCommand = str_replace(dirname(PFC_TEST_DIR), '~', $command); |
| 44 | + |
| 45 | + $climate->out("<yellow>phpfastcache@unit-tests</yellow> <blue>{$projectDir}</blue> <green>#</green> <red>$shortCommand</red>"); |
42 | 46 |
|
43 | 47 | \exec($command, $output, $return_var); |
44 | 48 | $climate->out('====================================='); |
45 | 49 | $climate->out(\implode("\n", $output)); |
46 | 50 | $climate->out('====================================='); |
47 | 51 | if ($return_var === 0) { |
48 | | - $climate->green("Process finished with exit code $return_var"); |
49 | | - } else { |
50 | | - $climate->red("Process finished with exit code $return_var"); |
51 | | - $status = 255; |
| 52 | + $climate->green("Test finished successfully"); |
| 53 | + } else if($return_var === 1){ |
| 54 | + $climate->red("Test finished with a least one error"); |
| 55 | + $status = 1; |
52 | 56 | $failedTests[] = basename($filename); |
| 57 | + }else{ |
| 58 | + $climate->yellow("Test skipped due to unmeet dependencies"); |
| 59 | + $skippedTests[] = basename($filename); |
53 | 60 | } |
54 | 61 |
|
55 | 62 | $climate->out(''); |
|
62 | 69 | $execTime = gmdate('i\m s\s', (int) round(microtime(true) - $timestamp, 3)); |
63 | 70 | $climate->out('<yellow>Total tests duration: </yellow><light_green>' . $execTime . '</light_green>'); |
64 | 71 |
|
65 | | -if ($status === 0) { |
| 72 | +if (!$failedTests) { |
66 | 73 | $climate->backgroundGreen()->white()->flank('[OK] The build has passed successfully', '#')->out(''); |
67 | 74 | } else { |
68 | 75 | $climate->backgroundRed()->white()->flank('[KO] The build has failed miserably', '~')->out(''); |
69 | | - $climate->red()->out('Tests failed: ' . implode(', ', $failedTests))->out(''); |
| 76 | + $climate->red()->out('[TESTS FAILED] ' . PHP_EOL . '- '. implode(PHP_EOL . '- ', $failedTests))->out(''); |
| 77 | +} |
| 78 | + |
| 79 | +if($skippedTests){ |
| 80 | + $climate->yellow()->out('[TESTS SKIPPED] ' . PHP_EOL . '- '. implode(PHP_EOL . '- ', $skippedTests))->out(''); |
70 | 81 | } |
71 | 82 |
|
72 | 83 | exit($status); |
0 commit comments