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

Test suite failure feedback #735

Merged
merged 5 commits into from
Sep 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion docker/puppeteer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,21 @@ RUN apt-get update && apt-get install -y wget --no-install-recommends \
&& apt-get purge --auto-remove -y curl \
&& rm -rf /src/*.deb

RUN yarn add puppeteer
RUN yarn add puppeteer@1.14.0

RUN groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \
&& mkdir -p /home/pptruser/Downloads \
&& chown -R pptruser:pptruser /home/pptruser \
&& chown -R pptruser:pptruser /node_modules


RUN git clone https://github.com/stefanhaustein/TerminalImageViewer.git \
&& cd TerminalImageViewer/src/main/cpp \
&& make \
&& make install \
&& cd ../../.. \
&& rm -rf TerminalImageViewer

USER pptruser

CMD ["google-chrome-stable"]
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"sinon": "^7.3.1",
"source-map-explorer": "^2.0.1",
"style-loader": "^0.18.2",
"term-img": "^4.1.0",
"ts-loader": "^6.0.4",
"typescript": "~2.9.2",
"webpack": "^4.31.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/perspective-test/jest.all.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ module.exports = {
".html$": "html-loader-jest"
},
automock: false,
setupFiles: ["@finos/perspective-test/src/js/beforeEachSpec.js"]
setupFiles: ["@finos/perspective-test/src/js/beforeEachSpec.js"],
reporters: ["default", "@finos/perspective-test/src/js/reporter.js"]
};
3 changes: 2 additions & 1 deletion packages/perspective-test/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ module.exports = {
".html$": "html-loader-jest"
},
automock: false,
setupFiles: ["@finos/perspective-test/src/js/beforeEachSpec.js"]
setupFiles: ["@finos/perspective-test/src/js/beforeEachSpec.js"],
reporters: ["default", "@finos/perspective-test/src/js/reporter.js"]
};
7 changes: 5 additions & 2 deletions packages/perspective-test/src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,11 @@ test.capture = function capture(name, body, {timeout = 60000, viewport = null, w
} else {
fs.writeFileSync(filename + ".failed.png", screenshot);
if (fs.existsSync(filename + ".png")) {
cp.execSync(`composite ${filename}.png ${filename}.failed.png -compose difference ${filename}.diff.png`);
cp.execSync(`convert ${filename}.diff.png -auto-level ${filename}.diff.png`);
try {
cp.execSync(`compare ${filename}.png ${filename}.failed.png ${filename}.diff.png`);
} catch (e) {
// exits 1
}
}
}

Expand Down
57 changes: 57 additions & 0 deletions packages/perspective-test/src/js/reporter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/******************************************************************************
*
* Copyright (c) 2017, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/

const cp = require("child_process");
const fs = require("fs");
const path = require("path");
const termimg = require("term-img");

module.exports = class ImageViewerReporter {
constructor(globalConfig, options) {
this._globalConfig = globalConfig;
this._options = options;
}

write_img_fallback(filename) {
process.stdout.write("\r");
const diff = cp
.execSync(`tiv -h 60 -w 80 ${filename} 2>&1`)
.toString()
.replace(/Warning.+?$/g, "");
process.stdout.write(diff);
process.stdout.write("\n");
}

write_img(title, ancestors, filename) {
process.stdout.write(`\n ${ancestors.join(" > ")} > ${title}\n\n `);
termimg(filename, {
width: "320px",
height: "240px",
fallback: () => this.write_img_fallback(filename)
});
process.stdout.write("\n");
}

/**
* Runs `tiv` to dump diff images to console in blurry format.
*/
onTestResult(testRunConfig, testResults) {
for (const test of testResults.testResults) {
if (test.status === "failed") {
const ancestors = test.ancestorTitles.map(x => x.replace(".html", ""));
const desc = ancestors.join("/");
const name = test.title.replace(/ /g, "_").replace(/[\.']/g, "");
const filename = `${testRunConfig.path.split("/test")[0]}/screenshots/${desc}/${name}.diff.png`;
if (fs.existsSync(path.join(process.cwd(), filename))) {
this.write_img(test.title, ancestors, filename);
}
}
}
}
};
11 changes: 8 additions & 3 deletions packages/perspective/src/js/perspective.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,14 @@ function create_http_server(assets, host_psp) {
} catch (e) {}
}
}
console.error(`404 ${url}`);
response.writeHead(404);
response.end("", "utf-8");
if (url.indexOf("favicon.ico") > -1) {
response.writeHead(200);
response.end("", "utf-8");
} else {
console.error(`404 ${url}`);
response.writeHead(404);
response.end("", "utf-8");
}
} catch (error) {
if (error.code !== "ENOENT") {
console.error(`500 ${url}`);
Expand Down
22 changes: 18 additions & 4 deletions scripts/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,17 @@ function focus_package() {
value: "perspective-viewer-highcharts"
}
]
},
}
])
.then(new_config => {
CONFIG.add(new_config);
choose_docker();
});
}

function javascript_options() {
inquirer
.prompt([
{
type: "confirm",
name: "PSP_DEBUG",
Expand Down Expand Up @@ -165,7 +175,7 @@ function choose_project() {
if (CONFIG.PSP_PROJECT === "js") {
focus_package();
} else {
CONFIG.write();
choose_docker();
}
});
}
Expand All @@ -182,8 +192,12 @@ function choose_docker() {
])
.then(answers => {
CONFIG.add(answers);
choose_project();
if (CONFIG.PSP_PROJECT === "js") {
javascript_options();
} else {
CONFIG.write();
}
});
}

choose_docker();
choose_project();
7 changes: 6 additions & 1 deletion scripts/test_js.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

require("dotenv").config({path: "./.perspectiverc"});

const minimatch = require("minimatch");
const execSync = require("child_process").execSync;
const fs = require("fs");

Expand Down Expand Up @@ -53,7 +54,11 @@ function jest() {
}

function slow_jest() {
return (IS_WRITE ? "WRITE_TESTS=1 " : "") + 'TZ=UTC node_modules/.bin/lerna exec --scope="@finos/perspective-@(jupyterlab|phosphor)" --concurrency 1 --no-bail -- yarn --silent test:run';
if (!process.env.PACKAGE || minimatch("perspective-phosphor", process.env.PACKAGE) || minimatch("perspective-jupyterlab", process.env.PACKAGE)) {
return (IS_WRITE ? "WRITE_TESTS=1 " : "") + 'TZ=UTC node_modules/.bin/lerna exec --scope="@finos/perspective-@(jupyterlab|phosphor)" --concurrency 1 --no-bail -- yarn --silent test:run';
} else {
return 'echo ""';
}
}

function docker() {
Expand Down
49 changes: 48 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1945,7 +1945,7 @@ ansi-escapes@^3.0.0:
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.2.0.tgz#8780b98ff9dbf5638152d1f1fe5c1d7b4442976b"
integrity sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==

ansi-escapes@^4.2.1:
ansi-escapes@^4.1.0, ansi-escapes@^4.2.1:
version "4.2.1"
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.2.1.tgz#4dccdb846c3eee10f6d64dea66273eab90c37228"
integrity sha512-Cg3ymMAdN10wOk/VYfLV7KCQyv7EDirJ64500sU7n9UlmioEtDuU5Gd+hj73hXSU/ex7tHJSssmyftDdkMLO8Q==
Expand Down Expand Up @@ -2012,6 +2012,13 @@ anymatch@^2.0.0:
micromatch "^3.1.4"
normalize-path "^2.1.1"

app-path@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/app-path/-/app-path-3.2.0.tgz#06d426e0c988885264e0aa0a766dfa2723491633"
integrity sha512-PQPaKXi64FZuofJkrtaO3I5RZESm9Yjv7tkeJaDz4EZMeBBfGtr5MyQ3m5AC7F0HVrISBLatPxAAAgvbe418fQ==
dependencies:
execa "^1.0.0"

aproba@^1.0.3, aproba@^1.1.1:
version "1.2.0"
resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a"
Expand Down Expand Up @@ -2500,6 +2507,11 @@ base64-js@^1.0.2, base64-js@^1.2.1:
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.3.0.tgz#cab1e6118f051095e58b5281aea8c1cd22bfc0e3"
integrity sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==

base64-js@^1.2.3:
version "1.3.1"
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.3.1.tgz#58ece8cb75dd07e71ed08c736abc5fac4dbf8df1"
integrity sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==

base@^0.11.1:
version "0.11.2"
resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f"
Expand Down Expand Up @@ -7796,6 +7808,14 @@ isurl@^1.0.0-alpha5:
has-to-string-tag-x "^1.2.0"
is-object "^1.0.1"

iterm2-version@^4.1.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/iterm2-version/-/iterm2-version-4.2.0.tgz#b78069f747f34a772bc7dc17bda5bd9ed5e09633"
integrity sha512-IoiNVk4SMPu6uTcK+1nA5QaHNok2BMDLjSl5UomrOixe5g4GkylhPwuiGdw00ysSCrXAKNMfFTu+u/Lk5f6OLQ==
dependencies:
app-path "^3.2.0"
plist "^3.0.1"

jest-changed-files@^24.8.0:
version "24.8.0"
resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-24.8.0.tgz#7e7eb21cf687587a85e50f3d249d1327e15b157b"
Expand Down Expand Up @@ -10359,6 +10379,15 @@ pkg-dir@^3.0.0:
dependencies:
find-up "^3.0.0"

plist@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/plist/-/plist-3.0.1.tgz#a9b931d17c304e8912ef0ba3bdd6182baf2e1f8c"
integrity sha512-GpgvHHocGRyQm74b6FWEZZVRroHKE1I0/BTjAmySaohK+cUn+hZpbqXkc3KWgW3gQYkqcQej35FohcT0FRlkRQ==
dependencies:
base64-js "^1.2.3"
xmlbuilder "^9.0.7"
xmldom "0.1.x"

pluralize@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-7.0.0.tgz#298b89df8b93b0221dbf421ad2b1b1ea23fc6777"
Expand Down Expand Up @@ -12755,6 +12784,14 @@ tempfile@^2.0.0:
temp-dir "^1.0.0"
uuid "^3.0.1"

term-img@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/term-img/-/term-img-4.1.0.tgz#5b170961f7aa20b2f3b22deb8ad504beb963a8a5"
integrity sha512-DFpBhaF5j+2f7kheKFc1ajsAUUDGOaNPpKPtiIMxlbfud6mvfFZuWGnTRpaujUa5J7yl6cIw/h6nyr4mSsENPg==
dependencies:
ansi-escapes "^4.1.0"
iterm2-version "^4.1.0"

tern-guess-types@^0.10.0:
version "0.10.0"
resolved "https://registry.yarnpkg.com/tern-guess-types/-/tern-guess-types-0.10.0.tgz#614acf974bd1b86ca2bb60ac6d4bdc4f724bab2b"
Expand Down Expand Up @@ -13882,11 +13919,21 @@ xml@^1.0.1:
resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5"
integrity sha1-eLpyAgApxbyHuKgaPPzXS0ovweU=

xmlbuilder@^9.0.7:
version "9.0.7"
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-9.0.7.tgz#132ee63d2ec5565c557e20f4c22df9aca686b10d"
integrity sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=

xmlcreate@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/xmlcreate/-/xmlcreate-1.0.2.tgz#fa6bf762a60a413fb3dd8f4b03c5b269238d308f"
integrity sha1-+mv3YqYKQT+z3Y9LA8WyaSONMI8=

xmldom@0.1.x:
version "0.1.27"
resolved "https://registry.yarnpkg.com/xmldom/-/xmldom-0.1.27.tgz#d501f97b3bdb403af8ef9ecc20573187aadac0e9"
integrity sha1-1QH5ezvbQDr4757MIFcxh6rawOk=

xregexp@4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-4.0.0.tgz#e698189de49dd2a18cc5687b05e17c8e43943020"
Expand Down