Skip to content
This repository was archived by the owner on Jul 8, 2023. It is now read-only.

Commit 61b0bf3

Browse files
committed
Improvements to the build system.
1 parent efc59f5 commit 61b0bf3

File tree

3 files changed

+83
-4
lines changed

3 files changed

+83
-4
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ web: install $(shell find doc assets/web test/fixture/verification)
3737
make doc-img
3838
scripts/build-web
3939

40+
open-web:
41+
open http://localhost:8000/
42+
4043
serve: web
4144
php -S 0.0.0.0:8000 -t web
4245

@@ -46,7 +49,7 @@ publish: web
4649
test-fixtures:
4750
scripts/build-test-fixtures
4851

49-
.PHONY: test coverage open-coverage lint install examples edge-cases benchmarks integration output-examples doc-img serve publish test-fixtures
52+
.PHONY: test coverage open-coverage lint install examples edge-cases benchmarks integration output-examples doc-img open-web serve publish test-fixtures
5053

5154
vendor/autoload.php: composer.lock
5255
composer install

scripts/build-test-fixtures

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
<?php
33

44
use Eloquent\Asplode\Asplode;
5+
use Eloquent\Phony\Assertion\Exception\AssertionException;
56
use Eloquent\Phony\Hook\FunctionHookGenerator;
67
use Eloquent\Phony\Mock\Builder\MockBuilderFactory;
78
use Eloquent\Phony\Reflection\FeatureDetector;
89
use Eloquent\Phony\Reflection\FunctionSignatureInspector;
10+
use Eloquent\Phony\Test\Phony as TestPhony;
911

1012
$rootPath = dirname(__DIR__);
1113
require $rootPath . '/vendor/autoload.php';
@@ -74,3 +76,77 @@ foreach (scandir($hookGeneratorFixturePath) as $name) {
7476
"<?php\n\n" . $source
7577
);
7678
}
79+
80+
$verificationFixturePath = $fixturePath . '/verification';
81+
82+
function visualizeAnsi($data)
83+
{
84+
return preg_replace_callback(
85+
'/(\x9B|\x1B\[)([0-?]*[ -\/]*[@-~])/',
86+
function ($matches) {
87+
if ("\033[" !== $matches[1]) {
88+
throw new RuntimeException('Unexpected ANSI sequence.');
89+
}
90+
91+
switch ($matches[2]) {
92+
case '0m': return '%RESET%';
93+
case '1m': return '%BOLD%';
94+
case '2m': return '%FAINT%';
95+
96+
case '31m': return '%RED%';
97+
case '32m': return '%GREEN%';
98+
case '33m': return '%YELLOW%';
99+
case '36m': return '%CYAN%';
100+
}
101+
102+
throw new RuntimeException(
103+
sprintf(
104+
'Unexpected ANSI code %s.',
105+
var_export($matches[2], true)
106+
)
107+
);
108+
},
109+
$data
110+
);
111+
}
112+
113+
foreach (scandir($verificationFixturePath) as $group) {
114+
if ('.' === $group[0]) {
115+
continue;
116+
}
117+
118+
$groupPath = $verificationFixturePath . '/' . $group;
119+
120+
foreach (scandir($groupPath) as $name) {
121+
if ('.' === $name[0]) {
122+
continue;
123+
}
124+
125+
$thisPath = $groupPath . '/' . $name;
126+
$supportedPath = $thisPath . '/supported.php';
127+
128+
if (is_file($supportedPath)) {
129+
$isSupported = require $supportedPath;
130+
131+
if (!$isSupported) {
132+
continue;
133+
}
134+
}
135+
136+
try {
137+
require $thisPath . '/verification.php';
138+
139+
throw new RuntimeException(
140+
'Verification did not throw an exception.'
141+
);
142+
} catch (AssertionException $e) {
143+
}
144+
145+
file_put_contents(
146+
$thisPath . '/expected',
147+
visualizeAnsi($e->getMessage()) . "\n"
148+
);
149+
150+
TestPhony::reset();
151+
}
152+
}

scripts/build-web

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ Asplode::install();
99

1010
echo 'Generating website... ';
1111

12-
passthru('rm -rf web');
13-
passthru('mkdir -p web');
14-
1512
passthru('mkdir -p build');
1613

1714
$hash = sha1_file('doc/index.md');
@@ -76,6 +73,9 @@ $content
7673
$footer
7774
EOD;
7875

76+
passthru('rm -rf web');
77+
passthru('mkdir -p web');
78+
7979
file_put_contents('web/index.html', $content);
8080

8181
passthru('cp -a assets/web/css web/');

0 commit comments

Comments
 (0)