-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
Add de.thetaphi.forbiddenapis to avoid usage of unwanted APIs #348
Conversation
8cc5d35
to
828e7a8
Compare
I did a few replacements (basically "replace structurally" in IDEA), and it seems like the change uncovers true bugs. For instance:
I believe https://github.com/jlink/jqwik/blob/cc952102e3209a20c63e9b1cb6a7c3007a028b91/engine/src/main/java/net/jqwik/engine/execution/JqwikExecutor.java#L49-L51 should not iteratively try moving every test to the beginning of the queue, but it should keep the order of the input set. It think it would be good to keep the order of the tests across executions. |
@jlink , now the PR passes the test for For instance, documentation and others might need
|
I realized I could add It even uncovers an issue in WDYT regarding the new property right in |
If I adjust Arbitrary<List<Integer>> arbitrary = ints.list().ofMaxSize(3); // <-- added ofMaxSize(3)
|
@jlink , I think I found the reason
In other words, the generated value depends on both: If I change |
8acc7dd
to
1c42255
Compare
Wow. It looks like all the tests pass now. I would suggest enabling Gradle Build Scan for the CI runs, and add #349 |
39c81b5
to
b92ad43
Compare
…leSetTests.Shrinking#shrinkAllPairsTogether
…consistent element order
…it causes slow Java compilation
@vlsi Just noticed you've been adding a few commits lately, so a short heads-up: I've pushed off reviewing to make up my mind about two things: A: Should LinkedHashSet really be used in all places where HashSet is currently used?LHS uses more memory, so its use must be warranted. I agree that LHS should replace HS whenever it's used as part of value generation and shrinking, and when it's beneficial to keep the order (eg the snippet you've given from Since I already started to have some B: Should forbiddenapis be used to enforce the usage of the right API?Given that the build is already rather involved and the unknown performance implication of the forbiddenapis plugin, I'd rather not add it to the build. Adding tests (like you did in BTW, #340 should be covered by this PR, right? |
I just rebased since there were merge conflicts |
How are you going to tell if HS is allowable in a given place or not? I believe there are much more important questions, and there's no point in discussing HS vs LHS. The difference would most likely be negligible.
Forbidden APIs build configuration takes less than 20 lines, and the verification takes less than 1 second (see https://scans.gradle.com/s/ob2emuhhhmvzi/timeline?sort=longest&type=de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis), so both items you highlight are not an issue really. |
So far all the generators pass the stricter verification, so I would suggest keeping both verifications: compare repeatable generation with the same starting seed and generation with freshly created generators. |
I see a point. LHS is just the less common set implementation, it requires a motive to be used.
At one point or other I’ll need an exception from the rule and then have to fight the tool. IME those strict tools bring a lot of unwanted effort and gravity that I don’t like. |
LHS is the default in Kotlin when you do |
Everyone’s entitled to their own default. In Java mine is HS. |
See https://github.com/policeman-tools/forbidden-apis/wiki/GradleUsage
See https://github.com/policeman-tools/forbidden-apis/wiki/SignaturesSyntax
Overview
forbidden-apis allows identify the usage of unwanted APIs.
For instance,
Collections#toSet
can yield non-reproducible outcomes, and I believe it is important that Jqwik could reproduce the same generation and shrinking sequences based on the input seed only.See one of the issues in #340
Details
There are out-of-the-box signatures that might be helpful: https://github.com/policeman-tools/forbidden-apis/wiki/BundledSignatures
I hereby agree to the terms of the jqwik Contributor Agreement.