We sure can - you'd have to derive the default option for
tests.asserts from the seed, much like it's done for file encoding:

https://github.com/apache/lucene-solr/blob/master/gradle/testing/randomization.gradle#L94-L97

This has to be done on the build side, not at runtime, because once
the JVM starts, it's too late (assertions are either on or off).

D.

On Fri, Feb 19, 2021 at 1:08 PM Michael McCandless
<luc...@mikemccandless.com> wrote:
>
> Ahh, you are right, Dawid!  I thought our test infra had the randomization of 
> enabling or disabling assertions, but it looks like it is our Jenkins jobs 
> that contain the randomization.
>
> Could we somehow move the randomness into our test infrastructure?  E.g. it 
> would have helped Gautam (and other developers in the future) catch that 
> subtle but nasty bug in his PR during private development rather than later 
> in random Jenkins runs.  If I remember right, we originally added this 
> randomization precisely because we had such a bug, and the bug got released 
> and later caught and fixed in a subsequent release.
>
> Or is that a bad idea for some reason :)
>
> Mike McCandless
>
> http://blog.mikemccandless.com
>
>
> On Fri, Feb 19, 2021 at 3:44 AM Dawid Weiss <dawid.we...@gmail.com> wrote:
>>
>> Run, for example:
>>
>> gradlew -p lucene testOpts
>>
>> to see the options available. Notice this one:
>>
>>   tests.asserts            = true     # Enables or disables assertions mode.
>>
>> and run your tests with:
>>
>> gradlew -p lucene -Ptests.asserts=false test
>>
>> From IDE level you can disable assertions with -Dtests.asserts=false
>> (and not adding -ea).
>>
>> D.
>>
>> On Thu, Feb 18, 2021 at 3:45 AM Gautam Worah <worah.gau...@gmail.com> wrote:
>> >
>> > Hi Folks,
>> >
>> > I was working on PR LUCENE-9476 when we found cases where `asserts` in 
>> > test cases were always enabled. To verify whether this was true, I wrote a 
>> > simple test case that called assert 1000 times, modified a variable and 
>> > then checked its value. This test case always passed because `assert` was 
>> > always enabled.
>> >
>> > Mike McCandless mentioned in the PR that Lucene earlier had the capability 
>> > to randomly disable `asserts` so that there were no accidental cases of 
>> > developers relying on `asserts` always being enabled. We may have lost 
>> > this feature when the project transitioned to Gradle.
>> > When I change the default value of `tests.asserts` in randomization.gradle 
>> > to false, the test fails promptly.
>> >
>> > Has anyone else noticed this/knows more about this?
>> >
>> > Thanks,
>> > Gautam Worah.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
>> For additional commands, e-mail: dev-h...@lucene.apache.org
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to