We are trying out test distribution. We print some...
# develocity
n
We are trying out test distribution. We print some file paths during certain test failures. When these tests run remotely the path is the path on the agent. Is there a way to transform these logs so they include the local path instead?
e
I would say your best bet is to add the local path as a task input and use that to write the file paths instead.
n
Just as a string?
e
It could be a
Property<String>
or
DirectoryProperty
or whatever you want. I would create a
CommandLineArgumentProvider
and pass it in to the test task as a system property like is demonstrated here. I would annotate the property with
@Internal
so it doesn't affect cacheability.
n
Ok, and that will just work then?
We're setting it as a system property, or rather the library we use does
e
Well, that would make it available in the test using
System.getProperty
for example. If you are the one creating the file, which is what I thought you were implying from your original message, then you would need to update the code to read the value from the system property. If a library you are using is creating a file then I'm not sure it will work.
It all depends on how it is implemented.
n
So this is what they do today. In a
doFirst
for the test task they have this:
Copy code
systemProperties["paparazzi.build.dir"] = project.layout.buildDirectory.get().toString()
Then that is used to dump the output as well as printing a path to said output to the terminal
e
I'm a little confused because the
doFirst
should still be running on the host, so
project.layout.buildDirectory.get().toString()
should evaluate to the build directory of the local machine and not the agent already. Are you sure that is actually doing anything?
n
Maybe because it's a relative path it works?
Because it's definitely writing images to the build directory. And I've registered it as an output so they do get pulled down
e
The way I understand what you are saying is that your files are being written to the correct place on the build machine, it's just that what you're logging is incorrect because it uses the path on the agent, right?
n
Yeah that's right
I'll get you an example
e
Unless you have direct control over what is being logged, then I'm not sure there is much you can do.
n
I'm logging it
So I do
Copy code
See file:///tmp/test-distribution712665665506011951/rootDir/path/to/module/build/paparazzi/failures/delta-test.png for details.
It should look like this:
Copy code
See file:///Users/nicklas/path/to/repo/path/to/module/build/paparazzi/failures/delta-test.png for details.
e
How do you determine that file path? Can you update it to read from the
paparazzi.build.dir
system property?
n
That's what it does
Or rather, we create a file based on that and print the path (we need to print the absolute path)
e
So you are seeing
project.layout.buildDirectory.get().toString()
evaluate to a relative path?
n
We take that, whatever the output is and do
File(buildDir).resolve(“image.png”)