diff --git a/package.json b/package.json index 9a80a787..cd4697b0 100644 --- a/package.json +++ b/package.json @@ -26,11 +26,11 @@ "scripts": { "build": "node tasks/prepare-binaries.js", "test": "npm run test:smoke && npm run test:js", - "test:smoke": "./bin/asciidoctor-pdf --version", + "test:smoke": "./bin/asciidoctor-web-pdf --version", "test:js": "mocha test/**_test.js", "lint": "standard lib/**.js test/**.js tasks/**js", "publish": "node tasks/publish.js", - "test:update-reference": "docker build -f test/Dockerfile -t asciidoctor-web-pdf/test . && docker run --name asciidoctorwebpdftest asciidoctor-web-pdf/test:latest && docker cp asciidoctorwebpdftest:/app/test/output ./test/reference/" + "test:update-linux-reference": "docker build -f test/Dockerfile -t asciidoctor-web-pdf/test . && docker run --name asciidoctorwebpdftest asciidoctor-web-pdf/test:latest && docker cp asciidoctorwebpdftest:/app/test/output ./test/reference/linux/" }, "repository": { "type": "git", diff --git a/test/helper.js b/test/helper.js index ad30ea31..06fdf8c0 100644 --- a/test/helper.js +++ b/test/helper.js @@ -1,5 +1,6 @@ const ospath = require('path') const fs = require('fs') +const os = require('os') const childProcess = require('child_process') const PNG = require('pngjs').PNG const pixelmatch = require('pixelmatch') @@ -23,11 +24,12 @@ function computeImageDifferences (referenceBuffer, actualBuffer, diffFilename) { } function toVisuallyMatch (referenceFilename, actualPath) { + const platform = os.platform() === 'darwin' ? 'macos' : 'linux' let referencePath if (ospath.isAbsolute(referenceFilename)) { referencePath = referenceFilename } else { - referencePath = ospath.join(__dirname, 'reference', referenceFilename) + referencePath = ospath.join(__dirname, 'reference', platform, referenceFilename) } if (!fs.existsSync(actualPath)) { @@ -45,7 +47,7 @@ function toVisuallyMatch (referenceFilename, actualPath) { let pixels = 0 const tmpFiles = [actualPath] - const currentFilenameRegexp = new RegExp(`${actualBasename}-(?:actual|reference)-([0-9]+).png`) + const currentFilenameRegexp = new RegExp(`${actualBasename}-(?:actual|reference)-(\\d+).png`) const files = fs.readdirSync(imagesOutputDir) const indexes = new Set(files .filter((name) => name.match(currentFilenameRegexp)) diff --git a/test/reference/document-with-counters.pdf b/test/reference/linux/document-with-counters.pdf similarity index 100% rename from test/reference/document-with-counters.pdf rename to test/reference/linux/document-with-counters.pdf diff --git a/test/reference/document-with-left-toc.pdf b/test/reference/linux/document-with-left-toc.pdf similarity index 100% rename from test/reference/document-with-left-toc.pdf rename to test/reference/linux/document-with-left-toc.pdf diff --git a/test/reference/document-with-source-code.pdf b/test/reference/linux/document-with-source-code.pdf similarity index 100% rename from test/reference/document-with-source-code.pdf rename to test/reference/linux/document-with-source-code.pdf diff --git a/test/reference/document-with-stem.pdf b/test/reference/linux/document-with-stem.pdf similarity index 100% rename from test/reference/document-with-stem.pdf rename to test/reference/linux/document-with-stem.pdf diff --git a/test/reference/list.pdf b/test/reference/linux/list.pdf similarity index 100% rename from test/reference/list.pdf rename to test/reference/linux/list.pdf diff --git a/test/reference/page-break-article-preamble_false-section_false-toc_false-title-page-attribute_false.pdf b/test/reference/linux/page-break-article-preamble_false-section_false-toc_false-title-page-attribute_false.pdf similarity index 100% rename from test/reference/page-break-article-preamble_false-section_false-toc_false-title-page-attribute_false.pdf rename to test/reference/linux/page-break-article-preamble_false-section_false-toc_false-title-page-attribute_false.pdf diff --git a/test/reference/page-break-article-preamble_false-section_true-toc_auto-title-page-attribute_false.pdf b/test/reference/linux/page-break-article-preamble_false-section_true-toc_auto-title-page-attribute_false.pdf similarity index 100% rename from test/reference/page-break-article-preamble_false-section_true-toc_auto-title-page-attribute_false.pdf rename to test/reference/linux/page-break-article-preamble_false-section_true-toc_auto-title-page-attribute_false.pdf diff --git a/test/reference/page-break-article-preamble_false-section_true-toc_auto-title-page-attribute_true.pdf b/test/reference/linux/page-break-article-preamble_false-section_true-toc_auto-title-page-attribute_true.pdf similarity index 100% rename from test/reference/page-break-article-preamble_false-section_true-toc_auto-title-page-attribute_true.pdf rename to test/reference/linux/page-break-article-preamble_false-section_true-toc_auto-title-page-attribute_true.pdf diff --git a/test/reference/page-break-article-preamble_false-section_true-toc_false-title-page-attribute_false.pdf b/test/reference/linux/page-break-article-preamble_false-section_true-toc_false-title-page-attribute_false.pdf similarity index 100% rename from test/reference/page-break-article-preamble_false-section_true-toc_false-title-page-attribute_false.pdf rename to test/reference/linux/page-break-article-preamble_false-section_true-toc_false-title-page-attribute_false.pdf diff --git a/test/reference/page-break-article-preamble_false-section_true-toc_false-title-page-attribute_true.pdf b/test/reference/linux/page-break-article-preamble_false-section_true-toc_false-title-page-attribute_true.pdf similarity index 100% rename from test/reference/page-break-article-preamble_false-section_true-toc_false-title-page-attribute_true.pdf rename to test/reference/linux/page-break-article-preamble_false-section_true-toc_false-title-page-attribute_true.pdf diff --git a/test/reference/page-break-article-preamble_true-section_true-toc_auto-title-page-attribute_false.pdf b/test/reference/linux/page-break-article-preamble_true-section_true-toc_auto-title-page-attribute_false.pdf similarity index 100% rename from test/reference/page-break-article-preamble_true-section_true-toc_auto-title-page-attribute_false.pdf rename to test/reference/linux/page-break-article-preamble_true-section_true-toc_auto-title-page-attribute_false.pdf diff --git a/test/reference/page-break-article-preamble_true-section_true-toc_auto-title-page-attribute_true.pdf b/test/reference/linux/page-break-article-preamble_true-section_true-toc_auto-title-page-attribute_true.pdf similarity index 100% rename from test/reference/page-break-article-preamble_true-section_true-toc_auto-title-page-attribute_true.pdf rename to test/reference/linux/page-break-article-preamble_true-section_true-toc_auto-title-page-attribute_true.pdf diff --git a/test/reference/page-break-article-preamble_true-section_true-toc_false-title-page-attribute_false.pdf b/test/reference/linux/page-break-article-preamble_true-section_true-toc_false-title-page-attribute_false.pdf similarity index 100% rename from test/reference/page-break-article-preamble_true-section_true-toc_false-title-page-attribute_false.pdf rename to test/reference/linux/page-break-article-preamble_true-section_true-toc_false-title-page-attribute_false.pdf diff --git a/test/reference/page-break-article-preamble_true-section_true-toc_false-title-page-attribute_true.pdf b/test/reference/linux/page-break-article-preamble_true-section_true-toc_false-title-page-attribute_true.pdf similarity index 100% rename from test/reference/page-break-article-preamble_true-section_true-toc_false-title-page-attribute_true.pdf rename to test/reference/linux/page-break-article-preamble_true-section_true-toc_false-title-page-attribute_true.pdf diff --git a/test/reference/page-break-article-preamble_true-section_true-toc_preamble-title-page-attribute_false.pdf b/test/reference/linux/page-break-article-preamble_true-section_true-toc_preamble-title-page-attribute_false.pdf similarity index 100% rename from test/reference/page-break-article-preamble_true-section_true-toc_preamble-title-page-attribute_false.pdf rename to test/reference/linux/page-break-article-preamble_true-section_true-toc_preamble-title-page-attribute_false.pdf diff --git a/test/reference/page-break-article-preamble_true-section_true-toc_preamble-title-page-attribute_true.pdf b/test/reference/linux/page-break-article-preamble_true-section_true-toc_preamble-title-page-attribute_true.pdf similarity index 100% rename from test/reference/page-break-article-preamble_true-section_true-toc_preamble-title-page-attribute_true.pdf rename to test/reference/linux/page-break-article-preamble_true-section_true-toc_preamble-title-page-attribute_true.pdf diff --git a/test/reference/page-break-book-preamble_false-section_false-toc_false-title-page-attribute_false.pdf b/test/reference/linux/page-break-book-preamble_false-section_false-toc_false-title-page-attribute_false.pdf similarity index 100% rename from test/reference/page-break-book-preamble_false-section_false-toc_false-title-page-attribute_false.pdf rename to test/reference/linux/page-break-book-preamble_false-section_false-toc_false-title-page-attribute_false.pdf diff --git a/test/reference/page-break-book-preamble_false-section_true-toc_auto-title-page-attribute_false.pdf b/test/reference/linux/page-break-book-preamble_false-section_true-toc_auto-title-page-attribute_false.pdf similarity index 100% rename from test/reference/page-break-book-preamble_false-section_true-toc_auto-title-page-attribute_false.pdf rename to test/reference/linux/page-break-book-preamble_false-section_true-toc_auto-title-page-attribute_false.pdf diff --git a/test/reference/page-break-book-preamble_false-section_true-toc_false-title-page-attribute_false.pdf b/test/reference/linux/page-break-book-preamble_false-section_true-toc_false-title-page-attribute_false.pdf similarity index 100% rename from test/reference/page-break-book-preamble_false-section_true-toc_false-title-page-attribute_false.pdf rename to test/reference/linux/page-break-book-preamble_false-section_true-toc_false-title-page-attribute_false.pdf diff --git a/test/reference/page-break-book-preamble_true-section_true-toc_auto-title-page-attribute_false.pdf b/test/reference/linux/page-break-book-preamble_true-section_true-toc_auto-title-page-attribute_false.pdf similarity index 100% rename from test/reference/page-break-book-preamble_true-section_true-toc_auto-title-page-attribute_false.pdf rename to test/reference/linux/page-break-book-preamble_true-section_true-toc_auto-title-page-attribute_false.pdf diff --git a/test/reference/page-break-book-preamble_true-section_true-toc_false-title-page-attribute_false.pdf b/test/reference/linux/page-break-book-preamble_true-section_true-toc_false-title-page-attribute_false.pdf similarity index 100% rename from test/reference/page-break-book-preamble_true-section_true-toc_false-title-page-attribute_false.pdf rename to test/reference/linux/page-break-book-preamble_true-section_true-toc_false-title-page-attribute_false.pdf diff --git a/test/reference/page-break-book-preamble_true-section_true-toc_preamble-title-page-attribute_false.pdf b/test/reference/linux/page-break-book-preamble_true-section_true-toc_preamble-title-page-attribute_false.pdf similarity index 100% rename from test/reference/page-break-book-preamble_true-section_true-toc_preamble-title-page-attribute_false.pdf rename to test/reference/linux/page-break-book-preamble_true-section_true-toc_preamble-title-page-attribute_false.pdf diff --git a/test/reference/repeat-table-elements.pdf b/test/reference/linux/repeat-table-elements.pdf similarity index 100% rename from test/reference/repeat-table-elements.pdf rename to test/reference/linux/repeat-table-elements.pdf diff --git a/test/reference/title-page-background-color.pdf b/test/reference/linux/title-page-background-color.pdf similarity index 100% rename from test/reference/title-page-background-color.pdf rename to test/reference/linux/title-page-background-color.pdf diff --git a/test/reference/macos/document-with-counters.pdf b/test/reference/macos/document-with-counters.pdf new file mode 100644 index 00000000..534540f9 Binary files /dev/null and b/test/reference/macos/document-with-counters.pdf differ diff --git a/test/reference/macos/document-with-left-toc.pdf b/test/reference/macos/document-with-left-toc.pdf new file mode 100644 index 00000000..a41af691 Binary files /dev/null and b/test/reference/macos/document-with-left-toc.pdf differ diff --git a/test/reference/macos/document-with-source-code.pdf b/test/reference/macos/document-with-source-code.pdf new file mode 100644 index 00000000..b34c7157 Binary files /dev/null and b/test/reference/macos/document-with-source-code.pdf differ diff --git a/test/reference/macos/document-with-stem.pdf b/test/reference/macos/document-with-stem.pdf new file mode 100644 index 00000000..38f6e561 Binary files /dev/null and b/test/reference/macos/document-with-stem.pdf differ diff --git a/test/reference/macos/list.pdf b/test/reference/macos/list.pdf new file mode 100644 index 00000000..615dee5a Binary files /dev/null and b/test/reference/macos/list.pdf differ diff --git a/test/reference/macos/page-break-article-preamble_false-section_false-toc_false-title-page-attribute_false.pdf b/test/reference/macos/page-break-article-preamble_false-section_false-toc_false-title-page-attribute_false.pdf new file mode 100644 index 00000000..121ba632 Binary files /dev/null and b/test/reference/macos/page-break-article-preamble_false-section_false-toc_false-title-page-attribute_false.pdf differ diff --git a/test/reference/macos/page-break-article-preamble_false-section_true-toc_auto-title-page-attribute_false.pdf b/test/reference/macos/page-break-article-preamble_false-section_true-toc_auto-title-page-attribute_false.pdf new file mode 100644 index 00000000..a41af691 Binary files /dev/null and b/test/reference/macos/page-break-article-preamble_false-section_true-toc_auto-title-page-attribute_false.pdf differ diff --git a/test/reference/macos/page-break-article-preamble_false-section_true-toc_auto-title-page-attribute_true.pdf b/test/reference/macos/page-break-article-preamble_false-section_true-toc_auto-title-page-attribute_true.pdf new file mode 100644 index 00000000..912f401a Binary files /dev/null and b/test/reference/macos/page-break-article-preamble_false-section_true-toc_auto-title-page-attribute_true.pdf differ diff --git a/test/reference/macos/page-break-article-preamble_false-section_true-toc_false-title-page-attribute_false.pdf b/test/reference/macos/page-break-article-preamble_false-section_true-toc_false-title-page-attribute_false.pdf new file mode 100644 index 00000000..f1dc6654 Binary files /dev/null and b/test/reference/macos/page-break-article-preamble_false-section_true-toc_false-title-page-attribute_false.pdf differ diff --git a/test/reference/macos/page-break-article-preamble_false-section_true-toc_false-title-page-attribute_true.pdf b/test/reference/macos/page-break-article-preamble_false-section_true-toc_false-title-page-attribute_true.pdf new file mode 100644 index 00000000..1ceebec4 Binary files /dev/null and b/test/reference/macos/page-break-article-preamble_false-section_true-toc_false-title-page-attribute_true.pdf differ diff --git a/test/reference/macos/page-break-article-preamble_true-section_true-toc_auto-title-page-attribute_false.pdf b/test/reference/macos/page-break-article-preamble_true-section_true-toc_auto-title-page-attribute_false.pdf new file mode 100644 index 00000000..e13067b7 Binary files /dev/null and b/test/reference/macos/page-break-article-preamble_true-section_true-toc_auto-title-page-attribute_false.pdf differ diff --git a/test/reference/macos/page-break-article-preamble_true-section_true-toc_auto-title-page-attribute_true.pdf b/test/reference/macos/page-break-article-preamble_true-section_true-toc_auto-title-page-attribute_true.pdf new file mode 100644 index 00000000..77c0ecbe Binary files /dev/null and b/test/reference/macos/page-break-article-preamble_true-section_true-toc_auto-title-page-attribute_true.pdf differ diff --git a/test/reference/macos/page-break-article-preamble_true-section_true-toc_false-title-page-attribute_false.pdf b/test/reference/macos/page-break-article-preamble_true-section_true-toc_false-title-page-attribute_false.pdf new file mode 100644 index 00000000..a5cd6cac Binary files /dev/null and b/test/reference/macos/page-break-article-preamble_true-section_true-toc_false-title-page-attribute_false.pdf differ diff --git a/test/reference/macos/page-break-article-preamble_true-section_true-toc_false-title-page-attribute_true.pdf b/test/reference/macos/page-break-article-preamble_true-section_true-toc_false-title-page-attribute_true.pdf new file mode 100644 index 00000000..506b0a91 Binary files /dev/null and b/test/reference/macos/page-break-article-preamble_true-section_true-toc_false-title-page-attribute_true.pdf differ diff --git a/test/reference/macos/page-break-article-preamble_true-section_true-toc_preamble-title-page-attribute_false.pdf b/test/reference/macos/page-break-article-preamble_true-section_true-toc_preamble-title-page-attribute_false.pdf new file mode 100644 index 00000000..d50867ad Binary files /dev/null and b/test/reference/macos/page-break-article-preamble_true-section_true-toc_preamble-title-page-attribute_false.pdf differ diff --git a/test/reference/macos/page-break-article-preamble_true-section_true-toc_preamble-title-page-attribute_true.pdf b/test/reference/macos/page-break-article-preamble_true-section_true-toc_preamble-title-page-attribute_true.pdf new file mode 100644 index 00000000..77c0ecbe Binary files /dev/null and b/test/reference/macos/page-break-article-preamble_true-section_true-toc_preamble-title-page-attribute_true.pdf differ diff --git a/test/reference/macos/page-break-book-preamble_false-section_false-toc_false-title-page-attribute_false.pdf b/test/reference/macos/page-break-book-preamble_false-section_false-toc_false-title-page-attribute_false.pdf new file mode 100644 index 00000000..1f0a1b53 Binary files /dev/null and b/test/reference/macos/page-break-book-preamble_false-section_false-toc_false-title-page-attribute_false.pdf differ diff --git a/test/reference/macos/page-break-book-preamble_false-section_true-toc_auto-title-page-attribute_false.pdf b/test/reference/macos/page-break-book-preamble_false-section_true-toc_auto-title-page-attribute_false.pdf new file mode 100644 index 00000000..912f401a Binary files /dev/null and b/test/reference/macos/page-break-book-preamble_false-section_true-toc_auto-title-page-attribute_false.pdf differ diff --git a/test/reference/macos/page-break-book-preamble_false-section_true-toc_false-title-page-attribute_false.pdf b/test/reference/macos/page-break-book-preamble_false-section_true-toc_false-title-page-attribute_false.pdf new file mode 100644 index 00000000..1ceebec4 Binary files /dev/null and b/test/reference/macos/page-break-book-preamble_false-section_true-toc_false-title-page-attribute_false.pdf differ diff --git a/test/reference/macos/page-break-book-preamble_true-section_true-toc_auto-title-page-attribute_false.pdf b/test/reference/macos/page-break-book-preamble_true-section_true-toc_auto-title-page-attribute_false.pdf new file mode 100644 index 00000000..b95f1950 Binary files /dev/null and b/test/reference/macos/page-break-book-preamble_true-section_true-toc_auto-title-page-attribute_false.pdf differ diff --git a/test/reference/macos/page-break-book-preamble_true-section_true-toc_false-title-page-attribute_false.pdf b/test/reference/macos/page-break-book-preamble_true-section_true-toc_false-title-page-attribute_false.pdf new file mode 100644 index 00000000..63f7f333 Binary files /dev/null and b/test/reference/macos/page-break-book-preamble_true-section_true-toc_false-title-page-attribute_false.pdf differ diff --git a/test/reference/macos/page-break-book-preamble_true-section_true-toc_preamble-title-page-attribute_false.pdf b/test/reference/macos/page-break-book-preamble_true-section_true-toc_preamble-title-page-attribute_false.pdf new file mode 100644 index 00000000..b95f1950 Binary files /dev/null and b/test/reference/macos/page-break-book-preamble_true-section_true-toc_preamble-title-page-attribute_false.pdf differ diff --git a/test/reference/macos/repeat-table-elements.pdf b/test/reference/macos/repeat-table-elements.pdf new file mode 100644 index 00000000..f17c22a4 Binary files /dev/null and b/test/reference/macos/repeat-table-elements.pdf differ diff --git a/test/reference/macos/title-page-background-color.pdf b/test/reference/macos/title-page-background-color.pdf new file mode 100644 index 00000000..6526e416 Binary files /dev/null and b/test/reference/macos/title-page-background-color.pdf differ