Open kennyballou opened 1 year ago
Hi @kennyballou,
Thank you for taking the time to contribute to the EvoSuite project. If understood correctly, you're proposing
final String JAVA_CMD = java.nio.file.Paths.get(System.getProperty("java.home"), "bin", "java").toString();
as an alternative to
final String separator = System.getProperty("file.separator");
final String JAVA_CMD = System.getProperty("java.home") + separator + "bin" + separator + "java";
right?
That's correct. I didn't remove the separator
variable because it was used in other locations. The change is limited to a single test. It's possible this pattern can/should be used in other parts of the codebase.
@jose: I think to further explain this change, sometimes the values returned by "java.home" or other environment variables have a trailing path separator, e.g., "/", included; as is the case for me while using Guix. Therefore, the manual separator interpolating version causes the test suite to fail while looking for the Java executable. The Paths.get
version automatically handles trailing slashes and intersperses the appropriate OS separator between path elements.
Instead of relying on the values of the retrieved variables correctly handling trailing slashes, simply use the
Paths
utility methods to combine directory/path objects.