Skip to content

Commit b441453

Browse files
committed
CliTester: more robust watch mode.
It recovers from errors due to missing files etc.
1 parent 8ca6144 commit b441453

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Runner/CliTester.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,18 @@ private function watch(Runner $runner): void
259259
foreach ($this->options['--watch'] as $directory) {
260260
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory)) as $file) {
261261
if (substr($file->getExtension(), 0, 3) === 'php' && substr($file->getBasename(), 0, 1) !== '.') {
262-
$state[(string) $file] = md5_file((string) $file);
262+
$state[(string) $file] = @md5_file((string) $file); // @ file could be deleted in the meantime
263263
}
264264
}
265265
}
266266
if ($state !== $prev) {
267267
$prev = $state;
268-
$runner->run();
268+
try {
269+
$runner->run();
270+
} catch (\ErrorException $e) {
271+
$this->displayException($e);
272+
}
273+
echo "\n";
269274
}
270275
echo 'Watching ' . implode(', ', $this->options['--watch']) . ' ' . str_repeat('.', ++$counter % 5) . " \r";
271276
sleep(2);

0 commit comments

Comments
 (0)