This is an automated email from the ASF dual-hosted git repository.

csutherl pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
     new 02184b3bde Add a Maven-style test profile system for selective test 
execution using -Dtest.profile=<name> without polluting the ant -projecthelp 
output. Profile test patterns are in the a newly introduced 
build.properties.test-profiles file. GitHub Actions CI configuration is also 
updated to use the 'smoke' profile since it was created using the ci.yml list 
as it's source.
02184b3bde is described below

commit 02184b3bde6de79755eef65217a42d9f2b43f526
Author: Coty Sutherland <[email protected]>
AuthorDate: Tue Nov 18 15:13:19 2025 -0500

    Add a Maven-style test profile system for selective test execution using 
-Dtest.profile=<name> without polluting the ant -projecthelp output.
    Profile test patterns are in the a newly introduced 
build.properties.test-profiles file.
    GitHub Actions CI configuration is also updated to use the 'smoke' profile 
since it was created using the ci.yml list as it's source.
---
 .github/workflows/ci.yml         |   2 +-
 build.xml                        | 106 ++++++++++++++++++++++++++++++++++---
 test-profiles.properties.default | 109 +++++++++++++++++++++++++++++++++++++++
 webapps/docs/changelog.xml       |   6 +++
 4 files changed, 214 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a337de8f70..65e79da38f 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -46,7 +46,7 @@ jobs:
       run: |
         ant -noinput echoproperties deploy embed test-nio test-status
       env:
-        ANT_OPTS: -Dtest.openssl.exists=false -Dtest.excludePerformance=true 
-Dtest.exclude=jakarta/servlet/http/TestHttpServletResponseSendError.java,org/apache/catalina/authenticator/TestFormAuthenticatorA.java,org/apache/catalina/authenticator/TestFormAuthenticatorB.java,org/apache/catalina/authenticator/TestFormAuthenticatorC.java,org/apache/catalina/authenticator/TestSSOnonLoginAndBasicAuthenticator.java,org/apache/catalina/authenticator/TestSSOnonLoginAndDigestAuthenticator.java,or
 [...]
+        ANT_OPTS: -Dtest.openssl.exists=false -Dtest.excludePerformance=true 
-Dtest.profile=smoke
 
     - name: Upload logs
       if: ${{ !cancelled() }}
diff --git a/build.xml b/build.xml
index d650aa54c8..015e3930e8 100644
--- a/build.xml
+++ b/build.xml
@@ -198,7 +198,7 @@
   <property name="tomcat-jdbc-src.jar" 
value="${tomcat.pool}/tomcat-jdbc-src.jar"/>
 
   <!-- Tests To Run -->
-  <property name="test.name" value="**/Test*.java"/>
+  <!-- NOTE: test.name default is set in -test-profile-init target to allow 
profile override -->
   <property name="test.formatter" 
value="-Dorg.apache.juli.formatter=java.util.logging.SimpleFormatter"/>
   <property name="test.relaxTiming" value="false"/>
 
@@ -1949,14 +1949,104 @@
   <property name="junit.formatter.usefile" value="true" />
   <property name="junit.formatter.extension" value=".txt" />
 
+  <!-- ==================== Test Profile System ==================== -->
+  <!--
+    Property-based test profiles for convenient, selective test execution.
+
+    Usage: ant test -Dtest.profile=<profile-name>
+
+    Precedence: test.entry > test.profile > default
+    If test.entry is set, the profile is ignored to maintain backward 
compatibility.
+
+    Profile patterns are defined in test-profiles.properties test.profile 
properties
+    to keep this file readable.
+  -->
+
+  <!-- ================= Initialize Test Profile Property Values 
================ -->
+
+  <!-- We read test profile definitions from 
"test-profiles.properties.default"   -->
+  <!-- and also from "test-profiles.properties" if it exists.                  
   -->
+  <!-- The values in "test-profiles.properties" have stronger preference.      
   -->
+  <!-- If you want to customize your build, you can either change the values   
   -->
+  <!-- directly in the default file, or create a new test-profiles.properties 
and -->
+  <!-- set the values there. This way you don't have to change a file which    
   -->
+  <!-- is part of the original project source code.                            
   -->
+  <!-- See "test-profiles.properties.default" in the top level directory for 
some -->
+  <!-- property values you may customize.                                      
   -->
+  <property file="${user.home}/test-profiles.properties"/>
+  <property file="test-profiles.properties"/>
+  <property file="test-profiles.properties.default"/>
+
+  <!-- Macro to set test pattern based on profile name -->
+  <macrodef name="set-profile-pattern">
+    <attribute name="profile"/>
+    <sequential>
+      <!-- Set test.name property based on the profile attribute -->
+      <condition property="test.name" value="${test.profile.smoke}">
+        <equals arg1="@{profile}" arg2="smoke"/>
+      </condition>
+      <condition property="test.name" value="${test.profile.catalina}">
+        <equals arg1="@{profile}" arg2="catalina"/>
+      </condition>
+      <condition property="test.name" value="${test.profile.coyote}">
+        <equals arg1="@{profile}" arg2="coyote"/>
+      </condition>
+      <condition property="test.name" value="${test.profile.performance}">
+        <equals arg1="@{profile}" arg2="performance"/>
+      </condition>
+      <condition property="test.name" value="${test.profile.tribes}">
+        <equals arg1="@{profile}" arg2="tribes"/>
+      </condition>
+      <condition property="test.name" value="${test.profile.buildutil}">
+        <equals arg1="@{profile}" arg2="buildutil"/>
+      </condition>
+    </sequential>
+  </macrodef>
+
+  <!-- New internal target to initialize tests before moving to test target -->
+  <target name="-test-profile-init" if="test.profile" unless="test.entry">
+    <set-profile-pattern profile="${test.profile}"/>
+
+    <!-- Validate that the profile exists -->
+    <fail message="Unknown test profile '${test.profile}'. Check 
test-profiles.properties[.default] for available profiles.">
+      <condition>
+        <not><isset property="test.name"/></not>
+      </condition>
+    </fail>
+
+    <!-- Special handling for performance profile: disable default exclusion 
-->
+    <condition property="test.excludePerformance" value="false">
+      <equals arg1="${test.profile}" arg2="performance"/>
+    </condition>
+
+    <!-- Special handling for buildutil profile: include buildutil tests -->
+    <condition property="test.includeBuildutil" value="true">
+      <equals arg1="${test.profile}" arg2="buildutil"/>
+    </condition>
+
+    <!-- Special handling for tribes profile: include old slow/flaky tribes 
tests -->
+    <condition property="test.includeTribes" value="true">
+      <equals arg1="${test.profile}" arg2="tribes"/>
+    </condition>
+
+    <echo message="Test profile: ${test.profile}"/>
+  </target>
+
+  <!-- Set default test.name if no profile specified, using ant's immutability 
feature -->
+  <target name="-test-name-default" depends="-test-profile-init">
+    <property name="test.name" value="**/Test*.java"/>
+  </target>
+
+  <!-- ==================== End of Test Profile System ==================== -->
+
   <target name="test" description="Runs the JUnit test cases"
-          depends="test-nio,test-nio2,coverage-report,test-status" />
+          
depends="-test-name-default,test-nio,test-nio2,coverage-report,test-status" />
 
   <target name="test-clean" description="Runs the JUnit test cases"
-          
depends="clean-classes,test-nio,test-nio2,coverage-report,test-status" />
+          
depends="clean-classes,-test-name-default,test-nio,test-nio2,coverage-report,test-status"
 />
 
   <target name="test-only" description="Runs the JUnit test cases, without 
compilation"
-          depends="test-only-nio,test-only-nio2,test-status" />
+          
depends="-test-name-default,test-only-nio,test-only-nio2,test-status" />
 
   <target name="test-status"
           description="Analyses logs directory and reports on skipped tests, 
test failures and test errors">
@@ -2112,14 +2202,14 @@
             <fileset dir="test" includes="${test.name}" 
excludes="${test.exclude}">
               <!-- Exclude helper classes -->
               <exclude name="**/Tester*.java" />
-              <!-- Exclude the tests known to fail -->
-              <exclude name="org/apache/catalina/tribes/test/**" />
+              <!-- Exclude old tribes tests (slow/flaky, excluded since 2011, 
unless explicitly requested via tribes profile) -->
+              <exclude name="org/apache/catalina/tribes/test/**" 
unless="test.includeTribes" />
               <!-- Exclude the OpenSSL tests unless OpenSSL is available -->
               <exclude name="org/apache/tomcat/util/net/openssl/ciphers/**" 
unless="${test.openssl.exists}" />
               <!-- Exclude performance tests. E.g. on systems with 
slow/inconsistent timing -->
               <exclude name="**/*Performance.java" 
if="${test.excludePerformance}" />
-              <!-- Exclude tests that Gump can't compile -->
-              <exclude name="org/apache/tomcat/buildutil/**" />
+              <!-- Exclude tests that Gump can't compile (unless explicitly 
requested via buildutil profile) -->
+              <exclude name="org/apache/tomcat/buildutil/**" 
unless="test.includeBuildutil" />
               <!-- Exclude tests that require large heaps -->
               <exclude name="**/*LargeHeap.java" 
unless="${test.includeLargeHeap}" />
               <!--
diff --git a/test-profiles.properties.default b/test-profiles.properties.default
new file mode 100644
index 0000000000..6f73385b38
--- /dev/null
+++ b/test-profiles.properties.default
@@ -0,0 +1,109 @@
+# -----------------------------------------------------------------------------
+# 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.
+# -----------------------------------------------------------------------------
+# test-profiles.properties
+#
+# This file contains test profile pattern definitions for ant test targets.
+# These patterns are used by the test profile system in build.xml.
+#
+# To add a new profile:
+#   1. Add the property: test.profile.myprofile=pattern
+#   2. Add a condition in build.xml's set-profile-pattern macro
+#
+# -----------------------------------------------------------------------------
+
+# Smoke test profile
+test.profile.smoke=\
+jakarta/servlet/http/TestHttpServletResponseSendError.java,\
+org/apache/catalina/authenticator/TestFormAuthenticatorA.java,\
+org/apache/catalina/authenticator/TestFormAuthenticatorB.java,\
+org/apache/catalina/authenticator/TestFormAuthenticatorC.java,\
+org/apache/catalina/authenticator/TestSSOnonLoginAndBasicAuthenticator.java,\
+org/apache/catalina/authenticator/TestSSOnonLoginAndDigestAuthenticator.java,\
+org/apache/catalina/core/TestAsyncContextImpl.java,\
+org/apache/catalina/core/TestAsyncContextStateChanges.java,\
+org/apache/catalina/core/TestStandardContextResources.java,\
+org/apache/catalina/core/TestStandardWrapper.java,\
+org/apache/catalina/loader/TestVirtualContext.java,\
+org/apache/catalina/mapper/TestMapperWebapps.java,\
+org/apache/catalina/nonblocking/TestNonBlockingAPI.java,\
+org/apache/catalina/servlets/TestDefaultServletEncodingPassThroughBom.java,\
+org/apache/catalina/servlets/TestDefaultServletEncodingWithBom.java,\
+org/apache/catalina/servlets/TestDefaultServletEncodingWithoutBom.java,\
+org/apache/catalina/servlets/TestDefaultServletIfMatchRequests.java,\
+org/apache/catalina/servlets/TestDefaultServlet.java,\
+org/apache/catalina/servlets/TestDefaultServletOptions.java,\
+org/apache/catalina/servlets/TestWebdavServletOptionsFile.java,\
+org/apache/catalina/startup/TestContextConfig.java,\
+org/apache/catalina/startup/TestHostConfigAutomaticDeploymentA.java,\
+org/apache/catalina/startup/TestHostConfigAutomaticDeploymentB.java,\
+org/apache/catalina/startup/TestHostConfigAutomaticDeploymentC.java,\
+org/apache/catalina/valves/rewrite/TestRewriteValve.java,\
+org/apache/catalina/valves/TestStuckThreadDetectionValve.java,\
+org/apache/coyote/ajp/TestAbstractAjpProcessor.java,\
+org/apache/coyote/http11/filters/TestChunkedInputFilter.java,\
+org/apache/coyote/http11/TestHttp11InputBufferCRLF.java,\
+org/apache/coyote/http11/TestHttp11InputBuffer.java,\
+org/apache/coyote/http11/TestHttp11Processor.java,\
+org/apache/coyote/http2/TestAsync.java,\
+org/apache/coyote/http2/TestHttp2ConnectionTimeouts.java,\
+org/apache/coyote/http2/TestHttp2Limits.java,\
+org/apache/coyote/http2/TestHttp2Section_6_8.java,\
+org/apache/coyote/http2/TestHttp2Timeouts.java,\
+org/apache/coyote/http2/TestStreamQueryString.java,\
+org/apache/el/TestELInJsp.java,\
+org/apache/jasper/compiler/TestCompiler.java,\
+org/apache/jasper/compiler/TestEncodingDetector.java,\
+org/apache/jasper/compiler/TestGenerator.java,\
+org/apache/jasper/compiler/TestJspConfig.java,\
+org/apache/jasper/compiler/TestJspDocumentParser.java,\
+org/apache/jasper/compiler/TestValidator.java,\
+org/apache/jasper/optimizations/TestELInterpreterTagSetters.java,\
+org/apache/jasper/optimizations/TestStringInterpreterTagSetters.java,\
+org/apache/jasper/runtime/TestCustomHttpJspPage.java,\
+org/apache/jasper/runtime/TestJspContextWrapper.java,\
+org/apache/jasper/runtime/TestJspRuntimeLibrary.java,\
+org/apache/jasper/runtime/TestPageContextImpl.java,\
+org/apache/jasper/servlet/TestTldScanner.java,\
+org/apache/naming/resources/TestWarDirContext.java,\
+org/apache/naming/TestEnvEntry.java,\
+org/apache/tomcat/util/net/TestClientCert.java,\
+org/apache/tomcat/util/net/TestCustomSslTrustManager.java,\
+org/apache/tomcat/util/net/TestSSLHostConfigCompat.java,\
+org/apache/tomcat/util/net/TestSsl.java,\
+org/apache/tomcat/websocket/server/TestSlowClient.java,\
+org/apache/tomcat/websocket/server/TestWsRemoteEndpointImplServerDeadlock.java,\
+org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java,\
+org/apache/tomcat/websocket/TestWsWebSocketContainer.java,\
+org/apache/tomcat/websocket/TestWsWebSocketContainerTimeoutServer.java,\
+org/apache/catalina/tribes/group/interceptors/TestTcpFailureDetector.java,\
+org/apache/catalina/filters/TestRateLimitFilter.java,\
+jakarta/servlet/http/TestHttpServletDoHeadInvalidWrite*.java,\
+jakarta/servlet/http/TestHttpServletDoHeadValidWrite*.java
+
+# Component test profiles
+test.profile.catalina=**/catalina/**/*Test*.java
+test.profile.coyote=**/coyote/**/*Test*.java
+
+# Performance test profile
+test.profile.performance=**/*Performance.java
+
+# Tribes test profile
+test.profile.tribes=**/tribes/**/*Test*.java
+
+# Build utility test profile: Tests for build tools (normally excluded)
+# Note: These tests depend on classes not in output JARs and are excluded by 
default
+test.profile.buildutil=**/buildutil/**/*Test*.java
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 01ce832ec3..95c4626dae 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -202,6 +202,12 @@
   </subsection>
   <subsection name="Other">
     <changelog>
+      <add>
+        Add test profile system for selective test execution. Profiles can be
+        specified via <code>-Dtest.profile=&lt;name&gt;</code> to run specific
+        test subsets without using patterns directly. Profile patterns are
+        defined in <code>test-profiles.properties</code>. (csutherl)
+      </add>
       <update>
         Update file extension to media type mappings to align with the current
         list used by the Apache Web Server (httpd). (markt)


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to