asciidoctor / asciidoctorj

:coffee: Java bindings for Asciidoctor. Asciidoctor on the JVM!
http://asciidoctor.org
Apache License 2.0
632 stars 172 forks source link

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

Open abelsromero opened 6 years ago

abelsromero commented 6 years ago

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 commented 6 years ago

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,