Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes assertions for some test that failed on Windows 7 and Windows 8.1 #553

Conversation

abelsromero
Copy link
Member

Fixes the first and third issues mentioned in #550 (comment).

Fixes only affect test assertions so they work both for *nix and Windows.

@@ -235,7 +235,7 @@ public void should_be_able_to_read_asset() throws FileNotFoundException {
Document document = asciidoctor.load(DOCUMENT, options);
File inputFile = classpath.getResource("rendersample.asciidoc");
String content = document.readAsset(inputFile.getAbsolutePath(), new HashMap<Object, Object>());
assertThat(content, is(IOUtils.readFull(new FileReader(inputFile))));
assertThat(content, is(IOUtils.readFull(new FileReader(inputFile)).replaceAll("\r","\\")));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, we really want to avoid doing this type of hack, even in tests. I looked at the implementation of IOUtils.readFull and it looks very strange to me. Java should be reading the file the same on all systems, but it's not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upgraded to last version of JDK (131) and error banished 🤷‍♂️ I'll rollback the change.

if (Platform.getNativePlatform().OS == Platform.OS.WINDOWS)
result.contains("""src="${imagesOutDir.absolutePath.replaceAll("\\\\", "//")}/${imageFileName}.png""")
else
result.contains("""src="${imagesOutDir.absolutePath}/${imageFileName}.png""")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should be checking for absolute paths in the output. We would never want the HTML to point to an absolute path. But this is caused by the fact that we're passing an absolute path to imagesdir. I think imagesdir needs to be set to a relative path and then we don't have to worry about replacing any system path separators.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point the usage of 'imagesdir 'was added. We could completely remove it or just set any value for the sake of ensuring imagesdir works as espected.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -27,8 +27,7 @@ class WhenDitaaDiagramIsRendered extends Specification {

given:
String imageFileName = UUID.randomUUID()
File imagesOutDir = testFolder.newFolder()
File createdImage = new File(imagesOutDir, "${imageFileName}.png")
File imagesOutDir = new File(testFolder.root, "images-dir")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without looking at the codenarc report I guess the build failed because this could be a string with single quotes instead of double quotes.
Also I could imagine that codenarc prefers .name over .getName() but I am not sure about that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was checking right now. Really this is my worst PR in years XD but I take it with humor.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that feeling, also happens to me very often at the moment :-D

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It complains about the GString only, but I will change the getName anyway

@robertpanzer
Copy link
Member

Appveyor also made it to our known rouge error.
For some reason the Appveyor integration is missing in the project settings.
Nevertheless it still seems to get the PR notifications and build them, strange.

@robertpanzer robertpanzer merged commit 72c45fa into asciidoctor:asciidoctorj-1.6.0 May 8, 2017
@abelsromero abelsromero deleted the fix/windows7_and_windows81_tests branch December 23, 2021 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants