You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ds...@apache.org on 2026/10/16 12:58:05 UTC
(tomcat) branch main updated (f687aee436 -> 764112d922)
This is an automated email from the ASF dual-hosted git repository.
dsoumis pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
from f687aee436 Add credit to the changelog
new 8ebd9f3423 Add JaCoCo XML output to the coverage-report target
new 764112d922 Add PR diff-coverage workflow (report-only)
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.github/scripts/select-tests.sh | 56 ++++++++++++++++++++++++
.github/scripts/select-tests.test.sh | 66 ++++++++++++++++++++++++++++
.github/workflows/coverage.yml | 85 ++++++++++++++++++++++++++++++++++++
build.xml | 1 +
webapps/docs/changelog.xml | 5 +++
5 files changed, 213 insertions(+)
create mode 100755 .github/scripts/select-tests.sh
create mode 100644 .github/scripts/select-tests.test.sh
create mode 100644 .github/workflows/coverage.yml
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 02/02: Add PR diff-coverage workflow (report-only)
Posted by ds...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dsoumis pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 764112d92298a70dcb1c6ed9d9b8a034a4c66390
Author: Dimitris Soumis <ji...@gmail.com>
AuthorDate: Fri Oct 16 00:54:02 2026 +0300
Add PR diff-coverage workflow (report-only)
---
.github/scripts/select-tests.sh | 56 ++++++++++++++++++++++++
.github/scripts/select-tests.test.sh | 66 ++++++++++++++++++++++++++++
.github/workflows/coverage.yml | 85 ++++++++++++++++++++++++++++++++++++
3 files changed, 207 insertions(+)
diff --git a/.github/scripts/select-tests.sh b/.github/scripts/select-tests.sh
new file mode 100755
index 0000000000..78691bd0a4
--- /dev/null
+++ b/.github/scripts/select-tests.sh
@@ -0,0 +1,56 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Reads changed file paths on stdin (one repo-relative path per line) and
+# prints a comma-separated Ant <fileset> includes value selecting the mirror
+# test package (test/<pkg>/Test*.java) of each changed java/ source file whose
+# mirror package exists and contains at least one Test*.java. Prints nothing
+# if none match.
+#
+# Usage: git diff --name-only --diff-filter=d <base>...HEAD | select-tests.sh
+set -euo pipefail
+
+repo_root="${SELECT_TESTS_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)}"
+
+declare -A seen=() # dedupe set, keyed by include pattern
+includes=() # ordered list of include patterns to emit
+
+while IFS= read -r path; do
+ # Consider only source files under java/ ending in .java.
+ case "$path" in
+ java/*.java) ;;
+ *) continue ;;
+ esac
+
+ # Package dir: strip the leading java/ and the trailing /<Class>.java.
+ pkg="$(dirname "${path#java/}")"
+ [ "$pkg" = "." ] && continue
+
+ # Exact mirror package, non-recursive.
+ include="${pkg}/Test*.java"
+ [ -n "${seen[$include]:-}" ] && continue
+
+ # Only select it if the mirror package actually has a Test*.java.
+ if compgen -G "${repo_root}/test/${pkg}/Test*.java" > /dev/null; then
+ seen[$include]=1
+ includes+=("$include")
+ fi
+done
+
+if [ "${#includes[@]}" -gt 0 ]; then
+ printf '%s\n' "${includes[@]}" | sort | paste -sd, -
+fi
diff --git a/.github/scripts/select-tests.test.sh b/.github/scripts/select-tests.test.sh
new file mode 100644
index 0000000000..3dde33164c
--- /dev/null
+++ b/.github/scripts/select-tests.test.sh
@@ -0,0 +1,66 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -euo pipefail
+
+script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+script="${script_dir}/select-tests.sh"
+
+fixture="$(mktemp -d)"
+trap 'rm -rf "$fixture"' EXIT
+
+mkdir -p "$fixture/test/org/apache/tomcat/util/http/parser"
+touch "$fixture/test/org/apache/tomcat/util/http/parser/TestHttpParser.java"
+touch "$fixture/test/org/apache/tomcat/util/http/parser/TestMediaType.java"
+
+run() { SELECT_TESTS_ROOT="$fixture" bash "$script"; }
+
+fail=0
+assert_eq() {
+ local desc="$1" expected="$2" actual="$3"
+ if [ "$expected" = "$actual" ]; then
+ echo "ok - $desc"
+ else
+ echo "FAIL - $desc"; echo " expected: [$expected]"; echo " actual: [$actual]"; fail=1
+ fi
+}
+
+# 1. Source file with a mirror test package -> include for that package.
+out="$(printf '%s\n' 'java/org/apache/tomcat/util/http/parser/MediaType.java' | run)"
+assert_eq "maps source to mirror test package" \
+ "org/apache/tomcat/util/http/parser/Test*.java" "$out"
+
+# 2. Source file whose mirror package has no tests -> nothing.
+out="$(printf '%s\n' 'java/org/apache/catalina/Host.java' | run)"
+assert_eq "skips source with no mirror test package" "" "$out"
+
+# 3. Two source files in the same package -> deduped to one include.
+out="$(printf '%s\n' \
+ 'java/org/apache/tomcat/util/http/parser/MediaType.java' \
+ 'java/org/apache/tomcat/util/http/parser/HttpParser.java' | run)"
+assert_eq "dedupes same package" \
+ "org/apache/tomcat/util/http/parser/Test*.java" "$out"
+
+# 4. Non-source paths are ignored.
+out="$(printf '%s\n' 'build.xml' 'test/foo/TestBar.java' 'README.md' | run)"
+assert_eq "ignores non-java-source paths" "" "$out"
+
+# 5. Empty input -> empty output.
+out="$(printf '' | run)"
+assert_eq "empty input yields empty output" "" "$out"
+
+exit "$fail"
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
new file mode 100644
index 0000000000..be532fcf22
--- /dev/null
+++ b/.github/workflows/coverage.yml
@@ -0,0 +1,85 @@
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+name: Diff Coverage
+
+on:
+ pull_request:
+ branches:
+ - main
+
+permissions:
+ contents: read
+
+env:
+ LC_ALL: en_US.UTF-8
+
+jobs:
+ diff-coverage:
+ name: targeted tests
+ runs-on: ubuntu-latest
+ steps:
+ - name: Git Checkout
+ uses: actions/checkout@v7
+ with:
+ fetch-depth: 0
+
+ - name: Set up Java
+ uses: actions/setup-java@v6
+ with:
+ java-version: 21
+ distribution: zulu
+
+ - name: Set up Python
+ uses: actions/setup-python@v5
+ with:
+ python-version: '3.x'
+
+ - name: Install diff-cover
+ run: pip install diff-cover
+
+ - name: Determine base ref
+ id: base
+ run: echo "ref=origin/${{ github.event.pull_request.base.ref }}" >> "$GITHUB_OUTPUT"
+
+ - name: Select targeted tests
+ id: select
+ run: |
+ includes="$(git diff --name-only --diff-filter=d "${{ steps.base.outputs.ref }}"...HEAD \
+ | bash .github/scripts/select-tests.sh)"
+ echo "includes=$includes" >> "$GITHUB_OUTPUT"
+ if [ -z "$includes" ]; then
+ echo "No targeted tests for the changed files; skipping coverage." >> "$GITHUB_STEP_SUMMARY"
+ else
+ echo "Targeted tests: \`$includes\`" >> "$GITHUB_STEP_SUMMARY"
+ fi
+
+ - name: Run targeted tests with coverage
+ if: steps.select.outputs.includes != ''
+ run: |
+ ant -noinput deploy test-nio coverage-report \
+ -Dtest.coverage=true \
+ -Dtest.name="${{ steps.select.outputs.includes }}"
+ env:
+ ANT_OPTS: -Dtest.openssl.exists=false -Dtest.excludePerformance=true
+
+ - name: Report diff coverage
+ if: steps.select.outputs.includes != ''
+ run: |
+ diff-cover output/coverage/jacoco.xml \
+ --compare-branch "${{ steps.base.outputs.ref }}" \
+ --src-roots java \
+ --format markdown:diff-cover.md
+ {
+ echo '## Diff coverage (targeted tests)'
+ cat diff-cover.md
+ } >> "$GITHUB_STEP_SUMMARY"
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 01/02: Add JaCoCo XML output to the coverage-report target
Posted by ds...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dsoumis pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 8ebd9f3423a2a32db884fed583fb6f6588987e5c
Author: Dimitris Soumis <ji...@gmail.com>
AuthorDate: Thu Oct 15 20:30:54 2026 +0300
Add JaCoCo XML output to the coverage-report target
---
build.xml | 1 +
webapps/docs/changelog.xml | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/build.xml b/build.xml
index 2305c90012..307bd92897 100644
--- a/build.xml
+++ b/build.xml
@@ -2310,6 +2310,7 @@
</sourcefiles>
</structure>
<html destdir="${coverage.out}"/>
+ <xml destfile="${coverage.out}/jacoco.xml"/>
</jacoco:report>
</target>
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index f21a2a80ff..0d18041ff2 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -785,6 +785,11 @@
<update>
Add directory prefix to embedded ZIP packaging. (schultz)
</update>
+ <add>
+ Generate a JaCoCo XML coverage report
+ (<code>output/coverage/jacoco.xml</code>) alongside the existing HTML
+ report when the build is run with code coverage enabled. (dsoumis)
+ </add>
<!-- Entries for backport and removal before 12.0.0-M1 below this line -->
</changelog>
</subsection>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org