Skip to content

Commit 1e9e86e

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix/1838-cloudflare-bounded-browser
2 parents e9ab6bb + 4e5874b commit 1e9e86e

7 files changed

Lines changed: 198 additions & 79 deletions

packages/runtime-playground/src/php-bootstrap.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function bootstrapPhpCode(spec: RuntimeCreateSpec, code: string, args: st
2727

2828
const command = splitLeadingStrictTypesDeclare(code)
2929

30-
return `<?php
30+
const bootstrapped = `<?php
3131
${command.strictTypesDeclare ? `${command.strictTypesDeclare}\n` : ""}${phpFatalDiagnosticPhp()}
3232
${failureDiagnosticFile ? phpFailureDiagnosticFilePhp(failureDiagnosticFile) : ""}
3333
${phpCliStreamConstants()}
@@ -43,6 +43,18 @@ ${wpCliBridge ? `putenv(${JSON.stringify(`WP_CODEBOX_TERMINAL_ACTION_URL=${wpCli
4343
putenv(${JSON.stringify(`WP_CODEBOX_TERMINAL_ACTION_TOKEN=${wpCliBridge.token}`)});
4444
` : ""}
4545
${command.body}`
46+
47+
return failureDiagnosticFile ? phpFailureDiagnosticWrapperPhp(bootstrapped, failureDiagnosticFile) : bootstrapped
48+
}
49+
50+
function phpFailureDiagnosticWrapperPhp(code: string, path: string): string {
51+
return `<?php
52+
try {
53+
eval('?>' . base64_decode(${JSON.stringify(Buffer.from(code, "utf8").toString("base64"))}));
54+
} catch (Throwable $wp_codebox_bootstrap_throwable) {
55+
@file_put_contents(${JSON.stringify(path)}, 'STAGE_FAIL:bootstrap:' . get_class($wp_codebox_bootstrap_throwable) . ': ' . $wp_codebox_bootstrap_throwable->getMessage() . ' at ' . $wp_codebox_bootstrap_throwable->getFile() . ':' . $wp_codebox_bootstrap_throwable->getLine() . "\\n", FILE_APPEND);
56+
throw $wp_codebox_bootstrap_throwable;
57+
}`
4658
}
4759

4860
function phpFailureDiagnosticFilePhp(path: string): string {

packages/runtime-playground/src/phpunit-command-handlers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@ try {
12341234
pg_log('NO_TEST_FILES');
12351235
pg_log('NOTICE:tests directory not found at ' . $test_dir);
12361236
pg_stage_ok('discover_tests');
1237-
exit(1);
1237+
exit(0);
12381238
}
12391239
list($directories, $suffixes, $prefixes, $excludes, $configured_files) = wp_codebox_phpunit_parse_config(${JSON.stringify(options.phpunitXml)}, $test_dir);
12401240
$test_files = wp_codebox_phpunit_discover($directories, $suffixes, $prefixes, $excludes, $configured_files);
@@ -1259,7 +1259,7 @@ try {
12591259
if (empty($test_files)) {
12601260
pg_log('NO_TEST_FILES');
12611261
pg_stage_ok('discover_tests');
1262-
exit(1);
1262+
exit(0);
12631263
}
12641264
pg_stage_ok('discover_tests');
12651265
} catch (Throwable $e) {
@@ -1585,7 +1585,7 @@ try {
15851585
if (empty($test_files)) {
15861586
core_pg_log('NO_TEST_FILES');
15871587
core_pg_stage_ok('discover_tests');
1588-
exit(1);
1588+
exit(0);
15891589
}
15901590
core_pg_stage_ok('discover_tests');
15911591
} catch (Throwable $e) {

0 commit comments

Comments
 (0)