Normalize path to avoid surprises

This commit is contained in:
Clément Fournier
2020-06-13 21:52:45 +02:00
parent 0d23c04c1b
commit 4b3d58d4c9

View File

@@ -71,7 +71,11 @@ abstract class BaseTextComparisonTest {
private fun findTestFile(contextClass: Class<*>, resourcePath: String): Path {
val path = contextClass.`package`.name.replace('.', '/')
return srcTestResources.resolve("$path/$resourcePath")
// normalize the path, because if eg we have src/test/resources/some/pack/../other,
// where the directory 'some/pack' does not exist, the file will not be found, even if
// some/other exists. Normalization turns the above path into src/test/resources/some/other
val norm = Paths.get("$path/$resourcePath").normalize()
return srcTestResources.resolve(norm)
}
companion object {