From 471789a33fa0cfacb63e127bfacbd8b38933d128 Mon Sep 17 00:00:00 2001 From: Christopher Hertel Date: Mon, 18 May 2026 20:36:07 +0200 Subject: [PATCH] Fix conformance score calculcation --- .gitignore | 2 ++ Makefile | 8 ++++++-- tests/Conformance/score.php | 19 +++++++++++-------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 6dc5d9ec..5ea477c0 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Makefile b/Makefile index 49f0d9ec..667aa046 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/tests/Conformance/score.php b/tests/Conformance/score.php index b33df91e..ddad90f1 100644 --- a/tests/Conformance/score.php +++ b/tests/Conformance/score.php @@ -68,17 +68,20 @@ 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;