J. King 3 months ago
parent
commit
c7d4d8c262
2 changed files with 46 additions and 37 deletions
  1. 7
    6
      .gitignore
  2. 39
    31
      RoboFile.php

+ 7
- 6
.gitignore View File

@@ -1,11 +1,12 @@
1 1
 # Temporary files and dependencies
2 2
 
3
-vendor/
4
-documentation/
5
-tests/coverage/
6
-arsse.db*
7
-config.php
8
-.php_cs.cache
3
+/vendor/
4
+/vendor-bin/*/vendor
5
+/documentation/
6
+/tests/coverage/
7
+/arsse.db*
8
+/config.php
9
+/.php_cs.cache
9 10
 
10 11
 
11 12
 # Windows files

+ 39
- 31
RoboFile.php View File

@@ -2,17 +2,12 @@
2 2
 
3 3
 use Robo\Result;
4 4
 
5
-/**
6
- * This is project's console commands configuration for Robo task runner.
7
- *
8
- * @see http://robo.li/
9
- */
10 5
 class RoboFile extends \Robo\Tasks {
11 6
     const BASE = __DIR__.\DIRECTORY_SEPARATOR;
12 7
     const BASE_TEST = self::BASE."tests".\DIRECTORY_SEPARATOR;
13 8
 
14 9
     /**
15
-     * Runs the full test suite
10
+     * Runs the typical test suite
16 11
      *
17 12
      * Arguments passed to the task are passed on to PHPUnit. Thus one may, for
18 13
      * example, run the following command and get the expected results:
@@ -22,21 +17,17 @@ class RoboFile extends \Robo\Tasks {
22 17
      * Please see the PHPUnit documentation for available options.
23 18
     */
24 19
     public function test(array $args): Result {
25
-        // start the built-in PHP server, which is required for some of the tests
26
-        $this->taskServer(8000)->host("localhost")->dir(self::BASE_TEST."docroot")->rawArg("-n")->arg(self::BASE_TEST."server.php")->background()->run();
27
-        // run tests
28
-        $execpath = realpath(self::BASE."vendor-bin/phpunit/vendor/phpunit/phpunit/phpunit");
29
-        $confpath = realpath(self::BASE_TEST."phpunit.xml");
30
-        return $this->taskExec("php")->arg($execpath)->option("-c", $confpath)->args($args)->run();
20
+        return $this->runTests("php", "typical", $args);
31 21
     }
32 22
 
33 23
     /**
34 24
      * Runs the full test suite
35 25
      *
36
-     * This is an alias of the "test" task.
26
+     * This includes pedantic tests which may help to identify problems.
27
+     * See help for the "test" task for more details.
37 28
     */
38 29
     public function testFull(array $args): Result {
39
-        return $this->test($args);
30
+        return $this->runTests("php", "full", $args);
40 31
     }
41 32
 
42 33
     /**
@@ -45,27 +36,33 @@ class RoboFile extends \Robo\Tasks {
45 36
      * See help for the "test" task for more details.
46 37
     */
47 38
     public function testQuick(array $args): Result {
48
-        return $this->test(array_merge(["--exclude-group", "slow,optional"], $args));
39
+        return $this->runTests("php", "quick", $args);
49 40
     }
50 41
 
51 42
     /** Produces a code coverage report
52 43
      *
53 44
      * By default this task produces an HTML-format coverage report in
54
-     * arsse/tests/coverage/. Additional reports may be produced by passing
45
+     * tests/coverage/. Additional reports may be produced by passing
55 46
      * arguments to this task as one would to PHPUnit.
56 47
      *
57 48
      * Robo first tries to use phpdbg and will fall back to Xdebug if available.
58 49
      * Because Xdebug slows down non-coverage tasks, however, phpdbg is highly
59
-     * recommanded is debugging facilities are not otherwise needed.
50
+     * recommended if debugging facilities are not otherwise needed.
60 51
     */
61 52
     public function coverage(array $args): Result {
62
-        // start the built-in PHP server, which is required for some of the tests
63
-        $this->taskServer(8000)->host("localhost")->dir(self::BASE_TEST."docroot")->rawArg("-n")->arg(self::BASE_TEST."server.php")->background()->run();
64 53
         // run tests with code coverage reporting enabled
65 54
         $exec = $this->findCoverageEngine();
66
-        $execpath = realpath(self::BASE."vendor-bin/phpunit/vendor/phpunit/phpunit/phpunit");
67
-        $confpath = realpath(self::BASE_TEST."phpunit.xml");
68
-        return $this->taskExec($exec)->arg($execpath)->option("-c", $confpath)->option("--coverage-html", self::BASE_TEST."coverage")->args($args)->run();
55
+        return $this->runTests($exec, "typical", array_merge(["--coverage-html", self::BASE_TEST."coverage"], $args));
56
+    }
57
+
58
+    /** Runs the coding standards fixer */
59
+    public function clean($opts = ['demo|d' => false]): Result {
60
+        $t = $this->taskExec(realpath(self::BASE."vendor/bin/php-cs-fixer"));
61
+        $t->arg("fix");
62
+        if ($opts['demo']) {
63
+            $t->args("--dry-run", "--diff")->option("--diff-format", "udiff");
64
+        }
65
+        return $t->run();
69 66
     }
70 67
 
71 68
     protected function findCoverageEngine(): string {
@@ -79,6 +76,26 @@ class RoboFile extends \Robo\Tasks {
79 76
         }
80 77
     }
81 78
 
79
+    protected function runTests(string $executor, string $set, array $args) : Result {
80
+        switch ($set) {
81
+            case "typical":
82
+                $set = ["--exclude-group", "optional"];
83
+                break;
84
+            case "quick":
85
+                $set = ["--exclude-group", "optional,slow"];
86
+                break;
87
+            case "full":
88
+                $set = [];
89
+                break;
90
+            default:
91
+                throw new \Exception;
92
+        }
93
+        $execpath = realpath(self::BASE."vendor-bin/phpunit/vendor/phpunit/phpunit/phpunit");
94
+        $confpath = realpath(self::BASE_TEST."phpunit.xml");
95
+        $this->taskServer(8000)->host("localhost")->dir(self::BASE_TEST."docroot")->rawArg("-n")->arg(self::BASE_TEST."server.php")->background()->run();
96
+        return $this->taskExec($executor)->arg($execpath)->option("-c", $confpath)->args(array_merge($set, $args))->run();
97
+    }
98
+
82 99
     /** Packages a given commit of the software into a release tarball
83 100
      *
84 101
      * The version to package may be any Git tree-ish identifier: a tag, a branch,
@@ -128,13 +145,4 @@ class RoboFile extends \Robo\Tasks {
128 145
         $this->_exec("git worktree prune");
129 146
         return $out;
130 147
     }
131
-
132
-    public function clean($opts = ['demo|d' => false]): Result {
133
-        $t = $this->taskExec(realpath(self::BASE."vendor/bin/php-cs-fixer"));
134
-        $t->arg("fix");
135
-        if ($opts['demo']) {
136
-            $t->args("--dry-run", "--diff")->option("--diff-format", "udiff");
137
-        }
138
-        return $t->run();
139
-    }
140 148
 }

Loading…
Cancel
Save