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

Add better support for providing system properties to the Test task #9092

Open
wolfs opened this issue Feb 8, 2018 · 13 comments
Open

Add better support for providing system properties to the Test task #9092

wolfs opened this issue Feb 8, 2018 · 13 comments
Labels
a:feature A new functionality in:input-normalization fingerprinting in:testing

Comments

@wolfs
Copy link
Member

wolfs commented Feb 8, 2018

Once https://github.com/gradle/build-cache/issues/800 is finished we should provide better support for building argument providers which add system properties to e.g. the test task.

Since we actually want to model something (like a java agent) and not add some generic system property with a relative path it could be enough to provide a helper method which converts a Map<String, Object> to system property command line arguments.

PR: #4709

@wolfs
Copy link
Member Author

wolfs commented Feb 12, 2018

Maybe we want to make things like providing a single input file property with relative path easier by improving the usage of the Runtime API?
Something like this could work:

test.systemProperty('some.file.input', inputs.file('path/to/file').withPathSensitivity(RELATIVE).withStringRepresentation { it.absolutePath })

or

test.systemProperty(inputs.file('path/to/file').withPropertyName('some.file.input').withPathSensitivity(RELATIVE).withStringRepresentation { it.absolutePath })

We could provide outputs in the same way.

@wolfs wolfs self-assigned this Feb 28, 2018
@wolfs
Copy link
Member Author

wolfs commented Mar 1, 2018

I was thinking that we may be providing a DSL like this:

test.systemProperties {
    add('some.property', inputFile(file))
    add('some.input.directory', inputDirectory(dir))
    add('some.output.file', outputFile(dir))
    add('some.output.directory', outputDirectory(dir))
    add('some.ignored.file.path', ignored(file))
}

The inputFile/Directory would add path sensitivity NONE/RELATIVE respectively.
I guess we would register the inputs/outputs under the property name in jvmArgumentProviders.

The arguments for each of those methods would be something we can unpack (Callable/Provider) I guess.

@lptr
Copy link
Member

lptr commented Mar 7, 2018

Let's do this:

test.systemProperties {
    add('some.property', inputFile(otherTask.outputFileProvider))
    add('some.input.directory', inputDirectory(dir))
    add('some.output.file', outputFile(dir))
    add('some.output.directory', outputDirectory(dir))
    add('some.ignored.file.path', ignored(file))
    add('some.value', 'value')
}

@wolfs
Copy link
Member Author

wolfs commented Mar 13, 2018

@wolfs
Copy link
Member Author

wolfs commented Mar 21, 2018

We are waiting for @adammurdoch input on how to proceed here.

@wolfs
Copy link
Member Author

wolfs commented Jun 26, 2018

After some discussion at the world meeting, we should go with a MapProvider for system properties and a map method which changes the type of the provider but captures the origin as inputs.

Something along those lines:

RegularFileProperty inputFile ...

compileJava.systemProperties.put("some.input.file", inputFile.map { it.get().asFile.absolutePath })

@lptr lptr transferred this issue from another repository Apr 15, 2019
@ldaley
Copy link
Member

ldaley commented Jun 26, 2019

It should also be much easier to add inconsequential system properties. A common example is setting java.io.tmp.

@stale
Copy link

stale bot commented Oct 6, 2020

This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution.

@stale stale bot added the stale label Oct 6, 2020
@wolfs
Copy link
Member Author

wolfs commented Oct 7, 2020

We still want to do this sometime.

@stale stale bot removed the stale label Oct 7, 2020
@stale
Copy link

stale bot commented Apr 17, 2022

This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution.

@stale stale bot added the stale label Apr 17, 2022
@wolfs wolfs removed the stale label Apr 19, 2022
@lptr lptr added the in:input-normalization fingerprinting label Jun 7, 2022
@lptr lptr unassigned wolfs Jan 12, 2023
@TWiStErRob
Copy link
Contributor

TWiStErRob commented Jan 26, 2023

Please pick this up again! We need a way to add any Provider to systemProperties. It just came up twice in the last week... for one occurrence is how error-prone it is to do it right now see code (Do you notice the bug with the paparazzi.test.record property? if yes, you can open PR to see the fix.)

@britter
Copy link
Member

britter commented Jan 27, 2023

@TWiStErRob you can always use a custom CommandLineArgumentProvider to pass a provider as a system property.

@TWiStErRob
Copy link
Contributor

Thanks, that's a good workaround, but with limited use cases: as far as I understand it goes around the systemProperties Map DSL and kind-of forcefully adds the argument. For example anyone using tasks.withType<Test> would not be able to observe the presence of the property (let alone the value), not even in doFirst {}.

@ov7a ov7a added the a:feature A new functionality label Sep 5, 2023
@big-guy big-guy added the in:configuration-model lazy api, domain object container label Dec 11, 2023
@lptr lptr removed the @execution label Feb 6, 2024
@mlopatkin mlopatkin removed the in:configuration-model lazy api, domain object container label Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:feature A new functionality in:input-normalization fingerprinting in:testing
Projects
None yet
Development

No branches or pull requests

10 participants