From 40b36383ca953202482ba9f017650b5d052c611f Mon Sep 17 00:00:00 2001 From: Paul Taylor Date: Tue, 23 Jan 2018 16:52:55 -0800 Subject: [PATCH] run integration tests with local data for coverage stats --- js/gulp/argv.js | 25 +++++++++++++++++++++++++ js/gulp/test-task.js | 4 +++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/js/gulp/argv.js b/js/gulp/argv.js index 4aee2e0fa9396..8a83820c1fe59 100644 --- a/js/gulp/argv.js +++ b/js/gulp/argv.js @@ -15,6 +15,10 @@ // specific language governing permissions and limitations // under the License. +const fs = require('fs'); +const glob = require('glob'); +const path = require('path'); + const argv = require(`command-line-args`)([ { name: `all`, type: Boolean }, { name: 'update', alias: 'u', type: Boolean }, @@ -36,4 +40,25 @@ argv.module && !modules.length && modules.push(argv.module); (argv.all || !targets.length) && targets.push(`all`); (argv.all || !modules.length) && modules.push(`all`); +if (argv.coverage && (!argv.json_files || !argv.json_files.length)) { + + let [jsonPaths, arrowPaths] = glob + .sync(path.resolve(__dirname, `../test/data/json/`, `*.json`)) + .reduce((paths, jsonPath) => { + const { name } = path.parse(jsonPath); + const [jsonPaths, arrowPaths] = paths; + ['cpp', 'java'].forEach((source) => ['file', 'stream'].forEach((format) => { + const arrowPath = path.resolve(__dirname, `../test/data/${source}/${format}/${name}.arrow`); + if (fs.existsSync(arrowPath)) { + jsonPaths.push(jsonPath); + arrowPaths.push(arrowPath); + } + })); + return paths; + }, [[], []]); + + argv.json_files = jsonPaths; + argv.arrow_files = arrowPaths; +} + module.exports = { argv, targets, modules }; diff --git a/js/gulp/test-task.js b/js/gulp/test-task.js index 885bed0b5ef75..7f655548eb8ef 100644 --- a/js/gulp/test-task.js +++ b/js/gulp/test-task.js @@ -44,7 +44,9 @@ const testOptions = { const testTask = ((cache, execArgv, testOptions) => memoizeTask(cache, function test(target, format, debug = false) { const opts = { ...testOptions }; const args = !debug ? [...execArgv] : [...debugArgv, ...execArgv]; - args.push(`test/${argv.integration ? `integration/*` : `unit/*`}`); + if (!argv.coverage) { + args.push(`test/${argv.integration ? `integration/*` : `unit/*`}`); + } opts.env = { ...opts.env, TEST_TARGET: target, TEST_MODULE: format,