2017 © Pedro Peláez
 

library peridot-watcher-plugin

Watch tests for changes then run them again

image

peridot-php/peridot-watcher-plugin

Watch tests for changes then run them again

  • Thursday, August 17, 2017
  • by brianium
  • Repository
  • 4 Watchers
  • 2 Stars
  • 30,134 Installations
  • PHP
  • 12 Dependents
  • 0 Suggesters
  • 3 Forks
  • 2 Open issues
  • 10 Versions
  • 8 % Grown

The README.md

Peridot Watcher Plugin

Build Status HHVM Status, (*1)

Watch for changes in your Peridot tests and re run them when a change occurs., (*2)

Peridot watcher, (*3)

Usage

We recommend installing this plugin to your project via composer:, (*4)

$ composer require --dev peridot-php/peridot-watcher-plugin:~1.3

You can register the plugin via your peridot.php file., (*5)

<?php
use Evenement\EventEmitterInterface;
use Peridot\Plugin\Watcher\WatcherPlugin;

return function(EventEmitterInterface $emitter) {
    $watcher = new WatcherPlugin($emitter);
};

Registering the plugin will make a --watch option available to the Peridot application:, (*6)

vendor/bin/peridot specs/ --watch

File events

By default, the watcher plugin will look for a "file changed" event, but you can configure the plugin to listen for the following events:, (*7)

  • WatcherInterface::CREATE_EVENT
  • WatcherInterface::MODIFY_EVENT
  • WatcherInterface::DELETE_EVENT
  • WatcherInterface::ALL_EVENT
<?php
use Evenement\EventEmitterInterface;
use Peridot\Plugin\Watcher\WatcherPlugin;
use Peridot\Plugin\Watcher\WatcherInterface;

return function(EventEmitterInterface $emitter) {
    $watcher = new WatcherPlugin($emitter);
    $watcher->setEvents([WatcherInterface::CREATE_EVENT, WatcherInterface::MODIFY_EVENT]);
};

Tracking additional paths

By default, the watcher plugin just monitors the test path. If you want to track additional paths, you can do so in your peridot.php file:, (*8)

<?php
use Evenement\EventEmitterInterface;
use Peridot\Plugin\Watcher\WatcherPlugin;

return function(EventEmitterInterface $emitter) {
    $watcher = new WatcherPlugin($emitter);
    $watcher->track(__DIR__ . '/src');
};

File criteria

The watcher will look for changes in files ending in .php by default. If you want to track additional file types, you can add criteria as regular expressions in your peridot.php file:, (*9)

<?php
use Evenement\EventEmitterInterface;
use Peridot\Plugin\Watcher\WatcherPlugin;

return function(EventEmitterInterface $emitter) {
    $watcher = new WatcherPlugin($emitter);
    $watcher->track(__DIR__ . '/src');
    $watcher->addFileCriteria('/\.js$/');
};

Using the above, you can re run your tests when the source file changes. Since the Peridot watcher re runs your tests in a sub-process, it will actually detect new changes in your source., (*10)

Example specs

Feel free to play around with the example spec using the watch option:, (*11)

$ vendor/bin/peridot -c example/peridot.php example/modifyme.spec.php --watch

Running plugin tests

$ vendor/bin/peridot specs/

Inotify support

The watcher plugin will leverage the Inotify extension if it is available, otherwise it will use a recursive directory strategy to watch for changes., (*12)

Note on IDEs

Some IDEs might choke on ANSI sequences being returned from the watcher process. PHPStorm does not render colors from sub process output, but most terminals will. If using the terminal from your IDE is a must, you may want to run your tests using the --no-colors option., (*13)

The Versions

17/08 2017

dev-master

9999999-dev

Watch tests for changes then run them again

  Sources   Download

MIT

The Requires

 

17/08 2017

1.3.2

1.3.2.0

Watch tests for changes then run them again

  Sources   Download

MIT

The Requires

 

20/09 2016

dev-dep-update

dev-dep-update

Watch tests for changes then run them again

  Sources   Download

MIT

The Requires

 

12/11 2014

1.3.1

1.3.1.0

Watch tests for changes then run them again

  Sources   Download

MIT

The Requires

 

08/11 2014

1.3.0

1.3.0.0

Watch tests for changes then run them again

  Sources   Download

MIT

The Requires

 

07/11 2014

1.2.0

1.2.0.0

Watch tests for changes then run them again

  Sources   Download

MIT

The Requires

 

04/11 2014

1.1.2

1.1.2.0

Watch tests for changes then run them again

  Sources   Download

MIT

The Requires

 

04/11 2014

1.1.1

1.1.1.0

Watch tests for changes then run them again

  Sources   Download

MIT

The Requires

 

04/11 2014

1.1.0

1.1.0.0

Watch tests for changes then run them again

  Sources   Download

MIT

The Requires

 

04/11 2014

1.0.0

1.0.0.0

Watch tests for changes then run them again

  Sources   Download

MIT

The Requires