Permalink
Browse files

CliTester: more robust watch mode.

It recovers from errors due to missing files etc.
  • Loading branch information...
dg committed Oct 24, 2018
1 parent 8ca6144 commit b4414531d4bc21383bc388c9bf9fade3e7d90d01
Showing with 7 additions and 2 deletions.
  1. +7 βˆ’2 src/Runner/CliTester.php
@@ -259,13 +259,18 @@ private function watch(Runner $runner): void
foreach ($this->options['--watch'] as $directory) {
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory)) as $file) {
if (substr($file->getExtension(), 0, 3) === 'php' && substr($file->getBasename(), 0, 1) !== '.') {
$state[(string) $file] = md5_file((string) $file);
$state[(string) $file] = @md5_file((string) $file); // @ file could be deleted in the meantime
}
}
}
if ($state !== $prev) {
$prev = $state;
$runner->run();
try {
$runner->run();
} catch (\ErrorException $e) {
$this->displayException($e);
}
echo "\n";
}
echo 'Watching ' . implode(', ', $this->options['--watch']) . ' ' . str_repeat('.', ++$counter % 5) . " \r";
sleep(2);

0 comments on commit b441453

Please sign in to comment.