Fix conformance score calculcation (#313)

This commit is contained in:
Christopher Hertel 2026-05-19 14:40:17 +02:00 • committed by GitHub
commit f12ea0ab58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 10 deletions

2
.gitignore vendored
View file

@ -6,6 +6,8 @@ vendor
examples/**/dev.log
examples/**/cache
examples/**/sessions
tests/Conformance/client-conformance.json
tests/Conformance/server-conformance.json
tests/Conformance/results
tests/Conformance/sessions
tests/Conformance/logs/*.log

View file

@ -27,11 +27,15 @@ conformance-server:
docker compose -f tests/Conformance/Fixtures/docker-compose.yml up -d
@echo "Waiting for server to start..."
@sleep 5
cd tests/Conformance && npx @modelcontextprotocol/conformance server --url http://localhost:8000/ || true
rm -rf tests/Conformance/results
cd tests/Conformance && npx @modelcontextprotocol/conformance server --url http://localhost:8000/ --output-dir results || true
php tests/Conformance/score.php server
docker compose -f tests/Conformance/Fixtures/docker-compose.yml down
conformance-client:
cd tests/Conformance && npx @modelcontextprotocol/conformance client --command "php $(CURDIR)/tests/Conformance/client.php" --suite all --expected-failures conformance-baseline.yml || true
rm -rf tests/Conformance/results
cd tests/Conformance && npx @modelcontextprotocol/conformance client --command "php $(CURDIR)/tests/Conformance/client.php" --suite all --expected-failures conformance-baseline.yml --output-dir results || true
php tests/Conformance/score.php client
coverage:
XDEBUG_MODE=coverage vendor/bin/phpunit --testsuite=unit --coverage-html=coverage

View file

@ -68,17 +68,20 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php';
continue;
}
++$total;
foreach ($checks as $check) {
if ('FAILURE' === ($check['status'] ?? null)) {
$failures[] = $file->getRelativePath();
continue 2;
switch ($check['status'] ?? null) {
case 'FAILURE':
$failures[] = $file->getRelativePath();
break;
case 'SUCCESS':
++$passed;
break;
default:
continue 2;
}
}
++$passed;
++$total;
}
}
$pct = $total > 0 ? (int) round($passed / $total * 100) : 0;