Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed flaky test #1203

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fixed flaky test #1203

wants to merge 1 commit into from

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.

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant