2018-08-22 13:35:32 +00:00
|
|
|
const isDocker = require('is-docker')();
|
2018-08-09 14:00:02 +00:00
|
|
|
|
2018-08-22 13:35:32 +00:00
|
|
|
module.exports = function(config) {
|
|
|
|
// Set the default values to be what are needed when testing the
|
|
|
|
// WebAssembly build locally.
|
|
|
|
let cfg = {
|
2018-08-09 14:00:02 +00:00
|
|
|
// frameworks to use
|
|
|
|
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
|
|
|
frameworks: ['jasmine'],
|
|
|
|
|
|
|
|
// list of files / patterns to load in the browser
|
|
|
|
files: [
|
|
|
|
{ pattern: 'npm-wasm/bin/test/pathkit.wasm', included:false, served:true},
|
|
|
|
{ pattern: 'tests/*.json', included:false, served:true},
|
[PathKit] Adding test infrastructure to support Gold output
To get the gold images out of the browser tests, this adds
testReporter.js and pathkit_aggregator.go. testReporter bundles
up the output as a base64 encoded PNG and sends it over the local
network to pathkit_aggregator. pathkit_aggregator will keep
a list of test results reported in this way and write the PNGs
to /OUT of the container (which is the swarming output directory).
Finally, after all the tests are run, the helper script "test_pathkit.sh"
makes a POST request that creates the JSON file that gold expects
(following the schema https://github.com/google/skia-buildbot/blob/master/golden/docs/INGESTION.md)
pathkit_aggregator takes many command line arguments which control
the keys that Gold needs in order to ingest and handle the data.
Of note, this creates a new set (i.e. source_type) of gold images
called "pathkit", which will distinguish it from "gm", "image", etc.
There will be at least 2 sub-sets of "pathkit" images, "canvas" and "svg",
(representing the 2 output types of PathKit). This CL doesn't
quite handle SVG yet, as it needs a way to convert SVG to PNG in the
browser and will be addressed in a follow up CL.
A "standard" gm is sized at 600x600. This was arbitrarily picked.
Note that the functions in testReporter.js return Promises based
on the fetch requests to post the data. This eliminates the race
condition between the /report_gold_data and /dump_json since
running the karma tests won't return until all reports are done.
Other changes of note:
- Adds go to karma-chrome-tests container.
- renames recipe_modules/build/wasm.py -> pathkit.py to be consistent with
the name of test_pathkit.py and make for easier grepping.
- Increases the JS test timeout to 10s (up from 5) to hopefully avoid
the flakes seen in the Debug Test.
Bug: skia:8216
Change-Id: Ic2cad54f3d19cc16601cf2e9a87798db1e6887a2
Reviewed-on: https://skia-review.googlesource.com/147042
Reviewed-by: Stephan Altmueller <stephana@google.com>
2018-08-15 17:45:28 +00:00
|
|
|
'tests/testReporter.js',
|
2018-08-09 14:00:02 +00:00
|
|
|
'npm-wasm/bin/test/pathkit.js',
|
2019-03-12 13:20:32 +00:00
|
|
|
'tests/pathkitinit.js',
|
2018-08-09 14:00:02 +00:00
|
|
|
'tests/*.spec.js'
|
|
|
|
],
|
|
|
|
|
2018-08-10 19:53:16 +00:00
|
|
|
proxies: {
|
2018-10-12 19:21:17 +00:00
|
|
|
'/pathkit/': '/base/npm-wasm/bin/test/'
|
2018-08-10 19:53:16 +00:00
|
|
|
},
|
|
|
|
|
2018-08-09 14:00:02 +00:00
|
|
|
// test results reporter to use
|
|
|
|
// possible values: 'dots', 'progress'
|
|
|
|
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
|
|
|
reporters: ['progress'],
|
|
|
|
|
|
|
|
// web server port
|
|
|
|
port: 4444,
|
|
|
|
|
|
|
|
// enable / disable colors in the output (reporters and logs)
|
|
|
|
colors: true,
|
|
|
|
|
|
|
|
// level of logging
|
|
|
|
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
|
|
|
logLevel: config.LOG_INFO,
|
|
|
|
|
|
|
|
// enable / disable watching file and executing tests whenever any file changes
|
|
|
|
autoWatch: true,
|
|
|
|
|
2019-03-12 13:20:32 +00:00
|
|
|
browserDisconnectTimeout: 20000,
|
|
|
|
browserNoActivityTimeout: 20000,
|
2018-08-17 19:00:43 +00:00
|
|
|
|
2018-08-09 14:00:02 +00:00
|
|
|
// start these browsers
|
|
|
|
browsers: ['Chrome'],
|
|
|
|
|
|
|
|
// Continuous Integration mode
|
|
|
|
// if true, Karma captures browsers, runs the tests and exits
|
|
|
|
singleRun: false,
|
|
|
|
|
|
|
|
// Concurrency level
|
|
|
|
// how many browser should be started simultaneous
|
|
|
|
concurrency: Infinity,
|
2018-08-22 13:35:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (isDocker) {
|
|
|
|
// See https://hackernoon.com/running-karma-tests-with-headless-chrome-inside-docker-ae4aceb06ed3
|
|
|
|
cfg.browsers = ['ChromeHeadlessNoSandbox'],
|
|
|
|
cfg.customLaunchers = {
|
|
|
|
ChromeHeadlessNoSandbox: {
|
2019-11-21 17:49:16 +00:00
|
|
|
base: 'ChromeHeadless',
|
|
|
|
flags: [
|
2018-08-22 13:35:32 +00:00
|
|
|
// Without this flag, we see an error:
|
|
|
|
// Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted
|
2019-11-21 17:49:16 +00:00
|
|
|
'--no-sandbox',
|
|
|
|
// may help tests be less flaky
|
|
|
|
// https://peter.sh/experiments/chromium-command-line-switches/#browser-test
|
|
|
|
'--browser-test',
|
|
|
|
// This can also help avoid crashes/timeouts:
|
|
|
|
// https://github.com/GoogleChrome/puppeteer/issues/1834
|
|
|
|
'--disable-dev-shm-usage',
|
|
|
|
],
|
2018-08-22 13:35:32 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (process.env.ASM_JS) {
|
|
|
|
console.log('asm.js is under test');
|
|
|
|
cfg.files = [
|
|
|
|
{ pattern: 'npm-asmjs/bin/test/pathkit.js.mem', included:false, served:true},
|
|
|
|
{ pattern: 'tests/*.json', included:false, served:true},
|
|
|
|
'tests/testReporter.js',
|
|
|
|
'npm-asmjs/bin/test/pathkit.js',
|
2019-03-12 13:20:32 +00:00
|
|
|
'tests/pathkitinit.js',
|
2018-08-22 13:35:32 +00:00
|
|
|
'tests/*.spec.js'
|
|
|
|
];
|
|
|
|
|
|
|
|
cfg.proxies = {
|
2018-10-12 19:21:17 +00:00
|
|
|
'/pathkit/': '/base/npm-asmjs/bin/test/'
|
2018-08-22 13:35:32 +00:00
|
|
|
};
|
|
|
|
} else {
|
|
|
|
console.log('wasm is under test');
|
|
|
|
}
|
|
|
|
|
|
|
|
config.set(cfg);
|
2018-08-09 14:00:02 +00:00
|
|
|
}
|