This is an automated email from the ASF dual-hosted git repository.
snazy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git
The following commit(s) were added to refs/heads/main by this push:
new 8e344c7d2 Build: Capture jcstress output in a log file (#2890)
8e344c7d2 is described below
commit 8e344c7d282bd27318be73e881bc15bc429c1fce
Author: Robert Stupp <[email protected]>
AuthorDate: Mon Oct 27 11:03:09 2025 +0100
Build: Capture jcstress output in a log file (#2890)
The jcstress output is pretty verbose and prints a lot to the console.
This change captures the output in a log file. In case of a test failure,
the output is logged to the console, but only in case of a failure.
---
persistence/nosql/idgen/impl/build.gradle.kts | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/persistence/nosql/idgen/impl/build.gradle.kts
b/persistence/nosql/idgen/impl/build.gradle.kts
index 1b7e6cf1b..24599ae09 100644
--- a/persistence/nosql/idgen/impl/build.gradle.kts
+++ b/persistence/nosql/idgen/impl/build.gradle.kts
@@ -17,6 +17,10 @@
* under the License.
*/
+import com.github.erizo.gradle.JcstressTask
+import java.io.FileOutputStream
+import java.nio.file.Files
+
plugins {
id("org.kordamp.gradle.jandex")
alias(libs.plugins.jmh)
@@ -72,7 +76,7 @@ tasks.named("check") { dependsOn("jcstress") }
jcstress { jcstressDependency = libs.jcstress.core.get().toString() }
-tasks.named("jcstress") {
+tasks.named<JcstressTask>("jcstress") {
inputs.properties(
System.getProperties()
.mapKeys { it.key.toString() }
@@ -85,4 +89,25 @@ tasks.named("jcstress") {
inputs.files(jcstressRuntime)
inputs.files(configurations.runtimeClasspath)
outputs.dir(layout.buildDirectory.dir("reports/jcstress"))
+
+ if (!System.getProperty("jcstress-no-capture").toBoolean()) {
+ // Capture jcstress output in a log file, dump that in case of a failure.
+
+ val logDir =
project.layout.buildDirectory.dir("reports/jcstress").get().asFile
+ val logFile = File(logDir, "jcstress.log")
+ var logStream: FileOutputStream? = null
+
+ actions.addFirst {
+ logStream = FileOutputStream(logFile)
+ standardOutput = logStream
+ errorOutput = logStream
+ }
+
+ actions.addLast {
+ logStream?.close()
+ if (state.failure != null) {
+ logger.error("jcstress output\n{}", Files.readString(logFile.toPath()))
+ }
+ }
+ }
}