private function getDependencyList(Task $task) { if (isset($this->marked[$task->getName()])) { return array(); } $this->marked[$task->getName()] = true; $path = array(); $deps = $this->asTasks($task->getDependencies()); foreach ($deps as $dep) { $path = array_merge($path, $this->getDependencyList($dep)); } $path[] = $task->getName(); return $path; }
public function run($fn) { $src = $this->src; $target = $this->target; parent::run(function () use($src, $target, $fn) { if (!file_exists($target) || filemtime($target) < filemtime($src)) { $fn($src, $target); } }); return $this; }
public function __construct($name) { parent::__construct($name); }
/** * Register a task for this executor. */ public function registerTask(Task $task) { $this->tasks[$task->getName()] = $task; }
$task($req); }); // this is obviously useless but it acts as a proof-of-concept beforeEach(function ($self) { $self->task = new Task('a'); }); it('should throw an exception if argument passed to before is invalid', function ($self) { $task = $self->task; $invokedWith = function ($with) use(&$task) { return function () use($with, &$task) { $task->before($with); }; }; the('task before method', $invokedWith('foo'))->shouldProduce('InvalidArgumentException'); the('task before method', $invokedWith(null))->shouldProduce('InvalidArgumentException'); $other = new Task('b'); $other->dependsOn('c'); the('task before method', $invokedWith($other))->shouldProduce('InvalidArgumentException'); }); it('should pass the request and itself as arguments to the invoked action', function ($self) { $task = $self->task; $task['run'] = false; $task->run(function ($req, $task) { the($req)->shouldHaveKey('f'); theValueOf($req['f'])->shouldBe(true); $task['run'] = true; }); $self->invoke($task, array('-f')); theValueOf($task['run'])->shouldBe(true); }); it('should accept a callable as argument to before', function ($self) {