From 203ff3872fadfa67b971fef72dee24bae9e46837 Mon Sep 17 00:00:00 2001 From: Amir Omidi Date: Fri, 18 Oct 2019 17:21:40 -0700 Subject: [PATCH] Test run list proposal (#7617) * Test run list propsal * fixed ts errors * added js file * excluding testSetup.js file from hygiene * moved ignore line to indententationFilter --- build/gulpfile.hygiene.js | 3 +- build/testSetup.js | 57 +++++++++++++++++++++++++++++++++ build/testSetup.ts | 67 +++++++++++++++++++++++++++++++++++++++ runlist.json | 12 +++++++ 4 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 build/testSetup.js create mode 100644 build/testSetup.ts create mode 100644 runlist.json diff --git a/build/gulpfile.hygiene.js b/build/gulpfile.hygiene.js index 498c9e8bff..f4ce8c9b9a 100644 --- a/build/gulpfile.hygiene.js +++ b/build/gulpfile.hygiene.js @@ -56,6 +56,7 @@ const indentationFilter = [ '!src/vs/base/node/terminateProcess.sh', '!src/vs/base/node/cpuUsage.sh', '!test/assert.js', + '!build/testSetup.js', // except specific folders '!test/automation/out/**', @@ -193,7 +194,7 @@ const tslintBaseFilter = [ '!extensions/**/*.test.ts', '!extensions/html-language-features/server/lib/jquery.d.ts', '!extensions/big-data-cluster/src/bigDataCluster/controller/apiGenerated.ts', // {{SQL CARBON EDIT}}, - '!extensions/big-data-cluster/src/bigDataCluster/controller/tokenApiGenerated.ts' // {{SQL CARBON EDIT}} + '!extensions/big-data-cluster/src/bigDataCluster/controller/tokenApiGenerated.ts' // {{SQL CARBON EDIT}}, ]; const sqlFilter = ['src/sql/**']; // {{SQL CARBON EDIT}} diff --git a/build/testSetup.js b/build/testSetup.js new file mode 100644 index 0000000000..c1072d8495 --- /dev/null +++ b/build/testSetup.js @@ -0,0 +1,57 @@ +"use strict"; +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the Source EULA. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +const fs = require('fs').promises; +const path = require('path'); +const readConfiguration = (async () => { + const parseConfigString = ((content) => { + try { + const result = JSON.parse(content); + return result; + } + catch (ex) { + console.log('Could NOT parse TEST_RUN_LIST:', content); + } + }); + // Attempt to read from an enviornment variable + const testRunlist = process.env['TEST_RUN_LIST']; + if (testRunlist && testRunlist !== '') { + const result = parseConfigString(testRunlist); + if (result) { + console.log('Using the environment test run list:', result); + return result; + } + } + // Attempt to read from a config file + let testRunPath = process.env['TEST_RUN_LIST_FILE']; + if (!testRunPath || testRunPath === '') { + testRunPath = path.resolve(__dirname, '..', 'runlist.json'); + } + try { + const contents = await fs.readFile(testRunPath); + return parseConfigString(contents); + } + catch (ex) { + console.log(`error reading file ${testRunPath}:`, ex); + } +}); +(async () => { + const keys = process.argv.slice(2); + const configuration = await readConfiguration(); + if (!configuration) { + console.log('no configuration was setup'); + return; + } + const testList = []; + keys.forEach((key) => { + const arr = configuration[key]; + if (arr) { + testList.push(...arr); + } + }); + const result = `(${testList.join('|')})`; + console.log(result); + process.env['TEST_GREP'] = result; +})(); diff --git a/build/testSetup.ts b/build/testSetup.ts new file mode 100644 index 0000000000..1620319d25 --- /dev/null +++ b/build/testSetup.ts @@ -0,0 +1,67 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the Source EULA. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +const fs = require('fs').promises; +const path = require('path'); + +interface IntegrationTestConfig { + [key: string]: string[]; +} + +const readConfiguration = (async (): Promise => { + const parseConfigString = ((content: string): (IntegrationTestConfig | void) => { + try { + const result = JSON.parse(content); + return result as IntegrationTestConfig; + } catch (ex) { + console.log('Could NOT parse TEST_RUN_LIST:', content); + } + }); + + // Attempt to read from an enviornment variable + const testRunlist = process.env['TEST_RUN_LIST']; + if (testRunlist && testRunlist !== '') { + const result = parseConfigString(testRunlist); + if (result) { + console.log('Using the environment test run list:', result); + return result; + } + } + + // Attempt to read from a config file + let testRunPath = process.env['TEST_RUN_LIST_FILE']; + if (!testRunPath || testRunPath === '') { + testRunPath = path.resolve(__dirname, '..', 'runlist.json'); + } + + try { + const contents = await fs.readFile(testRunPath); + return parseConfigString(contents); + } catch (ex) { + console.log(`error reading file ${testRunPath}:`, ex); + } +}); + +(async (): Promise => { + const keys = process.argv.slice(2); + + const configuration = await readConfiguration(); + + if (!configuration) { + console.log('no configuration was setup'); + return; + } + + const testList: string[] = []; + keys.forEach((key) => { + const arr = configuration[key]; + if (arr) { + testList.push(...arr); + } + }); + + const result = `(${testList.join('|')})`; + console.log(result); + process.env['TEST_GREP'] = result; +})(); diff --git a/runlist.json b/runlist.json new file mode 100644 index 0000000000..f3e37e13fc --- /dev/null +++ b/runlist.json @@ -0,0 +1,12 @@ +{ + "setup": [ + "setup integration tests", + "setup extension tests" + ], + "pr": [ + "dacpac.*" + ], + "windows": [ + "bds.*" + ] +}