Skip to content

Loading…

[WIP] Load external phakefiles #43

Open
wants to merge 2 commits into from

1 participant

@clue
Collaborator

This is a work-in-progress to add support for loading external phakefiles.

Closes #16 (Define tasks in tasks directory with separate files).
Also refs #31 (Do not chdir() to phakefile directory)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 24, 2013
  1. @clue
  2. @clue

    Test load_phakefile()

    clue committed
Showing with 40 additions and 10 deletions.
  1. +4 −0 lib/functions.php
  2. +16 −10 tests/BuilderTest.php
  3. +15 −0 tests/fixtures/load-others.php
  4. +5 −0 tests/fixtures/load-sub.php
View
4 lib/functions.php
@@ -43,6 +43,10 @@ function desc($description) {
builder()->desc($description);
}
+function load_runfile($path) {
+ builder()->load_runfile($path);
+}
+
/**
* Writes arguments to stdout, each separated by a space
* @param string $str...
View
26 tests/BuilderTest.php
@@ -67,18 +67,24 @@ public function testOrder()
$builder->get_application()->invoke('default');
}
- public function testGroups()
+ public function testLoadOthers()
{
$builder = new Builder();
- $builder->load_runfile($this->getFixture('groups.php'));
-
- $this->expectOutputString(<<<EOF
-a:b
-b:a
-
-EOF
-);
- $builder->get_application()->invoke('default');
+ $builder->load_runfile($this->getFixture('load-others.php'));
+
+ $tasks = $builder->get_application()->get_tasks();
+ $this->assertEquals(
+ array(
+ 'main',
+ 'main:default',
+ 'empty',
+ 'sub',
+ 'sub:sub',
+ 'sub:sub:default',
+ 'link'
+ ),
+ array_keys($tasks)
+ );
}
}
View
15 tests/fixtures/load-others.php
@@ -0,0 +1,15 @@
+<?php
+
+group('main', function () {
+ load_runfile(__DIR__ . '/Default.php');
+});
+
+group('empty', function () {
+ load_runfile(__DIR__ . '/Empty.php');
+});
+
+group('sub', function () {
+ load_runfile(__DIR__ . '/load-sub.php');
+});
+
+task('link', 'main:default');
View
5 tests/fixtures/load-sub.php
@@ -0,0 +1,5 @@
+<?php
+
+group('sub', function () {
+ load_runfile(__DIR__ . '/Default.php');
+});
Something went wrong with that request. Please try again.