Skip to content
This repository was archived by the owner on Dec 8, 2025. It is now read-only.

Conversation

@wang3820
Copy link

@wang3820 wang3820 commented Nov 2, 2023

Flakiness

Nondex was used to check and locate the flakiness in the test. The test can be reproduced using the following command:

mvn install -pl generator -am -DskipTests
mvn -pl generator test -Dtest=com.graphicsfuzz.generator.util.TransformationProbabilitiesTest#testToString
mvn -pl generator edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=com.graphicsfuzz.generator.util.TransformationProbabilitiesTest#testToString

Issue

In the toString method, getDeclaredFields() was called to iterate through all the fields in this class. However, getDeclaredFields() does not guarantee the order of elements returned, according to the Java Documentation: The elements in the returned array are not sorted and are not in any particular order.

Fix

Since the output array of getDeclaredFields() is not in any particular order, the fix sorts the array of fields returned by getDeclaredFields() by field name and then convert the array to string with the original format, except that fields are sorted by name. In the testcase, the expected string is also sorted by field names. This way this testcase constantly passes, resolving any flakiness.

@google-cla
Copy link

google-cla bot commented Nov 2, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant