Skip to content

Commit 6f202a9

Browse files
committed
Allow partly parallel Maven execution
This partly fixes Maven execution in parallel forks, because it postpones evaluating of the rootFolder (`user.dir` value) until it is really needed during execution. Without the fix the path could be evaluated in the main process, meaning the `user.dir` is not set correctly to the tested module. It still does not allow reusing of the forks (reuseForks parameter in maven-surefire-plugin and maven-failsafe-plugin), but at least allows parallel execution (forkCount greater than 1). When reusing the forks, the SnapshotSystemJUnit5.finishedAllTests() complains that it was called more than once, so the reuseForks has to be disabled (set to false). This partly fixes #551. Signed-off-by: Oldřich Jedlička <[email protected]>
1 parent 319a1b9 commit 6f202a9

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

jvm/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
## [Unreleased]
1414
### Fixed
1515
- Unsupported test sources (such as `FieldSource`) no longer cause the JUnit5 runner to crash. ([#550](https://github.com/diffplug/selfie/pull/550) fixes [#549](https://github.com/diffplug/selfie/issues/549))
16+
- Partly allow parallel Maven execution with surefire and failsafe plugins with `forkCount` greater than one by making evaluation of few properties lazy. This postpones evaluation into the forks. Still, due to internal Selfie state tracking, this needs to be run with `reuseForks` set to `false`. ([#557](https://github.com/diffplug/selfie/pull/557) partly fixes [#551](https://github.com/diffplug/selfie/issues/551))
1617
### Changed
1718
- Bump minimum required Kotest from `5.4.0` to `5.6.0` ([#535](https://github.com/diffplug/selfie/pull/535))
1819
- required to fix `java.lang.NoSuchMethodError: 'long kotlin.time.Duration$Companion.milliseconds-UwyO8pc(long)'`

jvm/selfie-runner-junit5/src/main/kotlin/com/diffplug/selfie/junit5/SnapshotFileLayoutJUnit5.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2023-2024 DiffPlug
2+
* Copyright (C) 2023-2025 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,13 +27,16 @@ class SnapshotFileLayoutJUnit5(settings: SelfieSettingsAPI, override val fs: FS)
2727
internal val smuggledError =
2828
AtomicReference<Throwable?>(
2929
if (settings is SelfieSettingsSmuggleError) settings.error else null)
30-
override val rootFolder = TypedPath.ofFolder(settings.rootFolder.absolutePath)
31-
private val otherSourceRoots = settings.otherSourceRoots
30+
internal val settings = settings
31+
override val rootFolder: TypedPath by lazy {
32+
TypedPath.ofFolder(settings.rootFolder.absolutePath)
33+
}
34+
private val otherSourceRoots: List<java.io.File> by lazy { settings.otherSourceRoots }
3235
override val allowMultipleEquivalentWritesToOneLocation =
3336
settings.allowMultipleEquivalentWritesToOneLocation
3437
override val javaDontUseTripleQuoteLiterals = settings.javaDontUseTripleQuoteLiterals
3538
val snapshotFolderName = settings.snapshotFolderName
36-
internal val unixNewlines = inferDefaultLineEndingIsUnix(rootFolder, fs)
39+
internal val unixNewlines: Boolean by lazy { inferDefaultLineEndingIsUnix(rootFolder, fs) }
3740
val extension: String = ".ss"
3841
private val cache =
3942
SourcePathCache(this::computePathForCall, Runtime.getRuntime().availableProcessors() * 4)

jvm/selfie-runner-kotest/src/commonMain/kotlin/com/diffplug/selfie/kotest/SnapshotFileLayoutKotest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2024 DiffPlug
2+
* Copyright (C) 2024-2025 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)