Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
com.github.jk1.license.filter.LicenseBundleNormalizerSpec."The regular expression must be matched"
Problem
The test
com.github.jk1.license.filter.LicenseBundleNormalizerSpec."The regular expression must be matched"
asserts two JSON strings for equality. The corresponding data is stored in sets. But the order, in which the data is returned by the Sets, is not deterministic. The test expects the values to be in certain order, even tho two JSON String are considered as equal if the data is in a different order (regarding the specification of JSON).This leads to a flaky test.
This problem was found by the NonDex Engine.
Gradle-License-Report/src/main/groovy/com/github/jk1/license/Model.groovy
Lines 39 to 48 in 5e273f9
Solution
The best solution would be to use JsonAsserts. But since it is unlikely that the owern of the repo would accept a new dependency, it was fixed by making sure the data is returned in a deterministic order.
By changing the
HashSets
toTreeSets
(to guarantee the order of the elements in the JSON string) in theModulData
class and adding the@Sortable
Annotation (needed by theTreeSet
to order the elements in the set) to thePomData
class, determinism is established.Gradle-License-Report/src/main/groovy/com/github/jk1/license/Model.groovy
Lines 39 to 48 in 140ee49
Gradle-License-Report/src/main/groovy/com/github/jk1/license/Model.groovy
Lines 57 to 64 in 140ee49
com.github.jk1.license.ProjectBuilderSpec."it creates modules with license-files"
Problem
The test
com.github.jk1.license.ProjectBuilderSpec."it creates modules with license-files
asserts that two lists contain the same elements. These elements are stored in aList
. But the order, in which the elements in the data structure are returned by the set, is not deterministic. The test expects the values to be in certain order.This leads to a flaky test.
This problem was found by the NonDex Engine.
Gradle-License-Report/src/test/groovy/com/github/jk1/license/ProjectBuilderSpec.groovy
Lines 119 to 121 in 5e273f9
Solution
By sorting the elements in the lists, a deterministic behavior can be guaranteed.
Gradle-License-Report/src/test/groovy/com/github/jk1/license/ProjectBuilderSpec.groovy
Lines 211 to 213 in 140ee49
Reproduce
To reproduce follow the steps:
./gradlew build -x test
apply plugin: 'edu.illinois.nondex'