You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@grails.apache.org by ma...@apache.org on 2025/11/19 14:11:34 UTC
(grails-core) 01/01: test: fix flaky `PerTestRecordingSpec`
This is an automated email from the ASF dual-hosted git repository.
matrei pushed a commit to branch fix-recording-test
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 57d468e955cb68eedac649fcbeadd1c00aff6017
Author: Mattias Reichel <ma...@gmail.com>
AuthorDate: Wed Nov 19 15:11:10 2025 +0100
test: fix flaky `PerTestRecordingSpec`
---
.../groovy/org/demo/spock/PerTestRecordingSpec.groovy | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/grails-test-examples/geb/src/integration-test/groovy/org/demo/spock/PerTestRecordingSpec.groovy b/grails-test-examples/geb/src/integration-test/groovy/org/demo/spock/PerTestRecordingSpec.groovy
index c60ab7a952..67213bb497 100644
--- a/grails-test-examples/geb/src/integration-test/groovy/org/demo/spock/PerTestRecordingSpec.groovy
+++ b/grails-test-examples/geb/src/integration-test/groovy/org/demo/spock/PerTestRecordingSpec.groovy
@@ -19,6 +19,8 @@
package org.demo.spock
+import java.nio.file.Files
+
import spock.lang.Stepwise
import grails.plugin.geb.ContainerGebSpec
@@ -43,9 +45,6 @@ class PerTestRecordingSpec extends ContainerGebSpec {
when: 'visiting another page than the previous test'
to(UploadPage)
- and: 'pausing to ensure the recorded file size is different'
- Thread.sleep(1000)
-
then: 'the page loads correctly'
title == 'Upload Test'
}
@@ -86,15 +85,12 @@ class PerTestRecordingSpec extends ContainerGebSpec {
recordingFiles != null
recordingFiles.length >= 2 // At least 2 files for the first two test methods
- and: 'the recording files should have different content (different sizes)'
+ and: 'the recording files should have different content'
// Sort by last modified time to get the most recent files
def sortedFiles = recordingFiles.sort { it.lastModified() }
def secondLastFile = sortedFiles[sortedFiles.length - 2]
def lastFile = sortedFiles[sortedFiles.length - 1]
-
- // Files should have different sizes (allowing for small variations due to timing)
- long sizeDifference = Math.abs(lastFile.length() - secondLastFile.length())
- sizeDifference > 1000 // Expect at least 1KB difference
+ Files.mismatch(lastFile.toPath(), secondLastFile.toPath()) != -1
}
private static boolean isVideoFile(File file) {