Skip to content

Commit ac31ce0

Browse files
committed
Treat empty PHPUnit suites as successful
1 parent 5ac3898 commit ac31ce0

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,7 @@ try {
12361236
pg_log('NO_TEST_FILES');
12371237
pg_log('NOTICE:tests directory not found at ' . $test_dir);
12381238
pg_stage_ok('discover_tests');
1239-
exit(1);
1239+
exit(0);
12401240
}
12411241
list($directories, $suffixes, $prefixes, $excludes, $configured_files) = wp_codebox_phpunit_parse_config(${JSON.stringify(options.phpunitXml)}, $test_dir);
12421242
$test_files = wp_codebox_phpunit_discover($directories, $suffixes, $prefixes, $excludes, $configured_files);
@@ -1261,7 +1261,7 @@ try {
12611261
if (empty($test_files)) {
12621262
pg_log('NO_TEST_FILES');
12631263
pg_stage_ok('discover_tests');
1264-
exit(1);
1264+
exit(0);
12651265
}
12661266
pg_stage_ok('discover_tests');
12671267
} catch (Throwable $e) {
@@ -1587,7 +1587,7 @@ try {
15871587
if (empty($test_files)) {
15881588
core_pg_log('NO_TEST_FILES');
15891589
core_pg_stage_ok('discover_tests');
1590-
exit(1);
1590+
exit(0);
15911591
}
15921592
core_pg_stage_ok('discover_tests');
15931593
} catch (Throwable $e) {

tests/phpunit-project-autoload.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ assert.ok(projectModeCode.includes("$test_files = wp_codebox_phpunit_discover($d
358358
assert.ok(projectModeCode.includes("' files=' . count($configured_files)"))
359359
assert.equal(projectModeCode.match(/return array\(\$directories, \$suffixes, \$prefixes, \$excludes\);/g)?.length ?? 0, 0)
360360
assert.equal(projectModeCode.match(/return \$return_values\(\);/g)?.length, 3)
361+
assert.match(projectModeCode, /if \(empty\(\$test_files\)\) \{\s+pg_log\('NO_TEST_FILES'\);\s+pg_stage_ok\('discover_tests'\);\s+exit\(0\);/)
361362
assertPhpunitParseConfigFallbacksReturnFiveTuple(projectModeCode, "wp_codebox_phpunit_parse_config", "pg_log")
362363
assertSelectedTestFileResolution(projectModeCode)
363364

@@ -466,6 +467,7 @@ assert.ok(coreModeCode.includes("list($directories, $suffixes, $prefixes, $exclu
466467
assert.ok(coreModeCode.includes("$test_files = core_pg_discover_tests($directories, $suffixes, $prefixes, $excludes, $configured_files);"))
467468
assert.equal(coreModeCode.match(/return array\(\$directories, \$suffixes, \$prefixes, \$excludes\);/g)?.length ?? 0, 0)
468469
assert.equal(coreModeCode.match(/return \$return_values\(\);/g)?.length, 3)
470+
assert.match(coreModeCode, /if \(empty\(\$test_files\)\) \{\s+core_pg_log\('NO_TEST_FILES'\);\s+core_pg_stage_ok\('discover_tests'\);\s+exit\(0\);/)
469471
assertPhpunitParseConfigFallbacksReturnFiveTuple(coreModeCode, "core_pg_parse_phpunit_config", "core_pg_log")
470472
for (const privateConstructor of [true, false]) {
471473
assertDiscoveredTestExecutes(projectModeCode, "pg", privateConstructor)

0 commit comments

Comments
 (0)