Skip to content

Commit

Permalink
Refactor render tests; use stricter pass criteria (visgl#4157)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress authored Jan 16, 2020
1 parent 60b8edb commit bca2822
Show file tree
Hide file tree
Showing 61 changed files with 2,310 additions and 2,654 deletions.
1 change: 1 addition & 0 deletions docs/api-reference/test-utils/snapshot-test-runner.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ The test renderer and each test case may choose to override the default image di
* `tolerance`
* `threshold`
* `includeAA`
* `includeEmpty`
* `createDiffImage`
* `saveOnFail`
* `saveAs`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function getMin(pts, accessor) {

// Function to convert from aggregation/accessor props (like colorAggregation and getColorWeight) to getValue prop (like getColorValue)
export function getValueFunc(aggregation, accessor) {
const op = AGGREGATION_OPERATION[aggregation.toUpperCase()] || AGGREGATION_OPERATION.SUM;
const op = AGGREGATION_OPERATION[aggregation] || AGGREGATION_OPERATION.SUM;
switch (op) {
case AGGREGATION_OPERATION.MIN:
return pts => getMin(pts, accessor);
Expand Down
2 changes: 1 addition & 1 deletion modules/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@
"gl-matrix": "^3.0.0",
"math.gl": "^3.1.2",
"mjolnir.js": "^2.3.0",
"probe.gl": "^3.2.0"
"probe.gl": "^3.2.1"
}
}
2 changes: 1 addition & 1 deletion modules/test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@deck.gl/core": "^8.0.0",
"@luma.gl/test-utils": "^8.0.1",
"@luma.gl/webgl": "^8.0.1",
"@probe.gl/test-utils": "^3.2.0"
"@probe.gl/test-utils": "^3.2.1"
},
"scripts": {}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"@loaders.gl/polyfills": "^2.0.2",
"@luma.gl/engine": "^8.0.1",
"@luma.gl/test-utils": "^8.0.1",
"@probe.gl/bench": "^3.2.0",
"@probe.gl/test-utils": "^3.2.0",
"@probe.gl/bench": "^3.2.1",
"@probe.gl/test-utils": "^3.2.1",
"babel-loader": "^8.0.0",
"babel-plugin-inline-webgl-constants": "^1.0.2",
"babel-plugin-remove-glsl-comments": "^0.1.0",
Expand Down
38 changes: 38 additions & 0 deletions scripts/print-golden-image.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
Script to retrieve failed screenshot from CI
- In render test, enable `saveOnFail`
- node scripts/print-golden-image.js <image_name> <sx> <sy> <width> <height>
- Copy the printed base64 string
- Use `restore` function in this file to convert string back to image
*/
const {PNG} = require('pngjs');
const fs = require('fs');
const path = require('path');

const INPUT_FILE = path.resolve('./test/render/golden-images', process.argv[2]);
const OUTPUT_FILE = 'out.png';

const SOURCE_X = Number(process.argv[3]) || 0;
const SOURCE_Y = Number(process.argv[4]) || 0;
const WIDTH = Number(process.argv[5]) || 800;
const HEIGHT = Number(process.argv[6]) || 450;

fs.createReadStream(INPUT_FILE)
.pipe(new PNG())
.on('parsed', function() {
const dst = new PNG({width: WIDTH, height: HEIGHT});
// copy to destination
this.bitblt(dst, SOURCE_X, SOURCE_Y, WIDTH, HEIGHT, 0, 0);

dst.pack().pipe(fs.createWriteStream('out.png'))
.on('close', function() {
const buffer = fs.readFileSync('out.png');
console.log(buffer.toString('base64'));
});
});

// Call to convert base64 back to file
function restore(base64, width, height) {
const buffer = Buffer.from(base64, 'base64');
fs.writeFileSync('out.png', buffer);
}
File renamed without changes
File renamed without changes
File renamed without changes
Loading

0 comments on commit bca2822

Please sign in to comment.