asciidoctorj icon indicating copy to clipboard operation
asciidoctorj copied to clipboard

Tests fail on Windows + J9 when running from a symlinked path

Open abelsromero opened this issue 7 years ago • 1 comments

ISSUE: Note: This DOES NOT happen with Java8. When running the test (both IntelliJ and shell) inside a path that has been symlinked some test fail.

CAUSE: Some tests (eg. composed_attributes_should_be_built_as_attributes_map) use this method to locate the target expectedFile file:

    String pwd = new File("").getAbsolutePath();

    File inputFile = classpath.getResource("rendersample.asciidoc");
    String inputPath = inputFile.getPath().substring(pwd.length() + 1);
    new AsciidoctorInvoker().invoke("-a", "stylesheet=mystyles.css", "-a", "linkcss", inputPath);
    File expectedFile = new File(inputPath.replaceFirst("\\.asciidoc$", ".html"));

But, when the path is in a symlink, in inputFile you get the real path, but in pwd you get the symlink path. This is what I get:

inputFile:C:\home\personal\github\asciidoctorj\asciidoctorj-core\out\test\resources\rendersample.asciidoc
pwd: C:\home\bin\.babun\cygwin\home\asalgadr\github\asciidoctorj\asciidoctorj-core

Env: Asciidoctorj: 1.5.6-SNASHOT (master) Windows7 Java 9.0.4

abelsromero avatar Feb 22 '18 07:02 abelsromero

Instead of new File("."), we could also do a classpath.getResource(".") to get the pwd. It works in my local, but I am not sure of repercusions in other OSs, need to test on more machines,

abelsromero avatar Feb 22 '18 07:02 abelsromero