Centrally set a system property that gets passed to all tests in a sub-directory?

Jaikiran Pai jai.forums2013 at gmail.com
Mon Nov 22 03:22:43 UTC 2021

Thank you Jon.

The original use case where I felt the need for this was in context of 
https://bugs.openjdk.java.net/browse/JDK-8277507 where I wanted to 
introduce this diagnostic system property for launched test cases under 
a specific test directory. Given that the issue affected all the tests 
in that directory (there were around 20 tests spread across 2 
sub-directories), I didn't want to change each one of them separately.

I ended up using a different way to achieve this, but that's mainly 
because I realized later that these tests were launching a separate 
process (using ProcessBuilder) after they were launched by jtreg. So 
this ability to add this property centrally from a TEST.properties 
wouldn't have helped anyway. But I think this might be a useful 
enhancement in general. Do you think this is worth filing a JBS enhancement?


On 21/11/21 9:08 pm, Jonathan Gibbons wrote:
> Sorry, there is no such feature.
> -- Jon
> On 11/21/21 2:00 AM, Jaikiran Pai wrote:
>> Is there a way in jtreg where a particular Java system property can 
>> be passed to all tests that run in othervm mode and belong to a 
>> particular sub-directory in the test root?
>> Something like "othervm.test.java.opts"? What I'm trying to solve is 
>> instead of editing each of the 10+ test classes that have a @run 
>> testng/othervm or @run main/othervm to include -Dfoo=bar in the test 
>> definition, I would like to have a TEST.properties for that 
>> sub-directory which would contain this system property to be set 
>> while launching those tests? I have been looking the documentation 
>> https://openjdk.java.net/jtreg/tag-spec.html#config but couldn't find 
>> anything that would help in this case.
>> -Jaikiran

More information about the jtreg-use mailing list