Skip to content

Commit

Permalink
CliTester: more robust watch mode.
Browse files Browse the repository at this point in the history
It recovers from errors due to missing files etc.
  • Loading branch information
dg committed Oct 24, 2018
1 parent 8ca6144 commit b441453
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Runner/CliTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b441453

Please sign in to comment.