From 3dca46619c8ad4d6ca1879e24208e349ef26db62 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 5 Nov 2019 11:30:11 -0800 Subject: [PATCH 01/16] Skip puppeteer download on unit test runs Fixes #2539 --- azure-pipelines.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 177f581f..2326e981 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,6 +7,8 @@ jobs: - job: Linux pool: vmImage: 'ubuntu-16.04' + variables: + PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1 steps: - task: NodeTool@0 inputs: @@ -42,6 +44,8 @@ jobs: - job: macOS pool: vmImage: 'xcode9-macos10.13' + variables: + PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1 steps: - task: NodeTool@0 inputs: @@ -57,6 +61,8 @@ jobs: - job: Windows pool: vmImage: 'vs2017-win2016' + variables: + PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1 steps: - task: NodeTool@0 inputs: From 70500e31ac4da4468af267c2e3a0113ba4151d00 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 5 Nov 2019 11:36:54 -0800 Subject: [PATCH 02/16] Add yarn cache caching --- azure-pipelines.yml | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2326e981..247395b3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -18,7 +18,12 @@ jobs: inputs: versionSpec: '1.x' displayName: 'Install Yarn' - - script: yarn + - task: CacheBeta@1 + inputs: + key: yarn | $(Agent.OS) | yarn.lock + path: $(YARN_CACHE_FOLDER) + displayName: Cache Yarn packages + - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' - script: yarn test-unit --forbid-only displayName: 'Unit tests' @@ -51,7 +56,12 @@ jobs: inputs: versionSpec: '8.x' displayName: 'Install Node.js' - - script: yarn + - task: CacheBeta@1 + inputs: + key: yarn | $(Agent.OS) | yarn.lock + path: $(YARN_CACHE_FOLDER) + displayName: Cache Yarn packages + - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' - script: yarn test-unit --forbid-only displayName: 'Unit tests' @@ -68,7 +78,12 @@ jobs: inputs: versionSpec: '8.x' displayName: 'Install Node.js' - - script: yarn + - task: CacheBeta@1 + inputs: + key: yarn | $(Agent.OS) | yarn.lock + path: $(YARN_CACHE_FOLDER) + displayName: Cache Yarn packages + - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' - script: yarn test-unit --forbid-only displayName: 'Unit tests' @@ -87,7 +102,12 @@ jobs: inputs: versionSpec: '1.x' displayName: 'Install Yarn' - - script: yarn + - task: CacheBeta@1 + inputs: + key: yarn | $(Agent.OS) | yarn.lock + path: $(YARN_CACHE_FOLDER) + displayName: Cache Yarn packages + - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' - script: | yarn start & @@ -103,7 +123,12 @@ jobs: inputs: versionSpec: '8.x' displayName: 'Install Node.js' - - script: yarn + - task: CacheBeta@1 + inputs: + key: yarn | $(Agent.OS) | yarn.lock + path: $(YARN_CACHE_FOLDER) + displayName: Cache Yarn packages + - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' - script: | yarn start & @@ -130,7 +155,12 @@ jobs: inputs: versionSpec: '1.x' displayName: 'Install Yarn' - - script: yarn + - task: CacheBeta@1 + inputs: + key: yarn | $(Agent.OS) | yarn.lock + path: $(YARN_CACHE_FOLDER) + displayName: Cache Yarn packages + - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' - script: NPM_AUTH_TOKEN="$(NPM_AUTH_TOKEN)" node ./bin/publish.js displayName: 'Package and publish to npm' From 86264d47635a8c360e7fecad10fa3fcfb2af58ee Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 5 Nov 2019 11:42:35 -0800 Subject: [PATCH 03/16] Specify yarn cache folder --- azure-pipelines.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 247395b3..0998781f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -9,6 +9,7 @@ jobs: vmImage: 'ubuntu-16.04' variables: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1 + YARN_CACHE_FOLDER: .yarn-cache steps: - task: NodeTool@0 inputs: @@ -51,6 +52,7 @@ jobs: vmImage: 'xcode9-macos10.13' variables: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1 + YARN_CACHE_FOLDER: .yarn-cache steps: - task: NodeTool@0 inputs: @@ -73,6 +75,7 @@ jobs: vmImage: 'vs2017-win2016' variables: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1 + YARN_CACHE_FOLDER: .yarn-cache steps: - task: NodeTool@0 inputs: @@ -93,6 +96,8 @@ jobs: - job: Linux_IntegrationTests pool: vmImage: 'ubuntu-16.04' + variables: + YARN_CACHE_FOLDER: .yarn-cache steps: - task: NodeTool@0 inputs: @@ -118,6 +123,8 @@ jobs: - job: macOS_IntegrationTests pool: vmImage: 'xcode9-macos10.13' + variables: + YARN_CACHE_FOLDER: .yarn-cache steps: - task: NodeTool@0 inputs: From 5411f60f44c71a4ecf9b3a9e125bf3afa66f700e Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 5 Nov 2019 11:54:32 -0800 Subject: [PATCH 04/16] Try cache node_modules --- azure-pipelines.yml | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0998781f..9ccc8393 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -9,7 +9,6 @@ jobs: vmImage: 'ubuntu-16.04' variables: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1 - YARN_CACHE_FOLDER: .yarn-cache steps: - task: NodeTool@0 inputs: @@ -22,7 +21,7 @@ jobs: - task: CacheBeta@1 inputs: key: yarn | $(Agent.OS) | yarn.lock - path: $(YARN_CACHE_FOLDER) + path: node_modules displayName: Cache Yarn packages - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' @@ -52,7 +51,6 @@ jobs: vmImage: 'xcode9-macos10.13' variables: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1 - YARN_CACHE_FOLDER: .yarn-cache steps: - task: NodeTool@0 inputs: @@ -61,7 +59,7 @@ jobs: - task: CacheBeta@1 inputs: key: yarn | $(Agent.OS) | yarn.lock - path: $(YARN_CACHE_FOLDER) + path: node_modules displayName: Cache Yarn packages - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' @@ -75,7 +73,6 @@ jobs: vmImage: 'vs2017-win2016' variables: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1 - YARN_CACHE_FOLDER: .yarn-cache steps: - task: NodeTool@0 inputs: @@ -84,7 +81,7 @@ jobs: - task: CacheBeta@1 inputs: key: yarn | $(Agent.OS) | yarn.lock - path: $(YARN_CACHE_FOLDER) + path: node_modules displayName: Cache Yarn packages - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' @@ -97,7 +94,6 @@ jobs: pool: vmImage: 'ubuntu-16.04' variables: - YARN_CACHE_FOLDER: .yarn-cache steps: - task: NodeTool@0 inputs: @@ -110,7 +106,7 @@ jobs: - task: CacheBeta@1 inputs: key: yarn | $(Agent.OS) | yarn.lock - path: $(YARN_CACHE_FOLDER) + path: node_modules displayName: Cache Yarn packages - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' @@ -124,7 +120,6 @@ jobs: pool: vmImage: 'xcode9-macos10.13' variables: - YARN_CACHE_FOLDER: .yarn-cache steps: - task: NodeTool@0 inputs: @@ -133,7 +128,7 @@ jobs: - task: CacheBeta@1 inputs: key: yarn | $(Agent.OS) | yarn.lock - path: $(YARN_CACHE_FOLDER) + path: node_modules displayName: Cache Yarn packages - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' @@ -165,7 +160,7 @@ jobs: - task: CacheBeta@1 inputs: key: yarn | $(Agent.OS) | yarn.lock - path: $(YARN_CACHE_FOLDER) + path: node_modules displayName: Cache Yarn packages - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' From 2960d5df53fd7626e121fdf1fe951bb93d75bf2d Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 5 Nov 2019 11:55:06 -0800 Subject: [PATCH 05/16] New cache key --- azure-pipelines.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9ccc8393..4eb35079 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -20,7 +20,7 @@ jobs: displayName: 'Install Yarn' - task: CacheBeta@1 inputs: - key: yarn | $(Agent.OS) | yarn.lock + key: yarn1 | $(Agent.OS) | yarn.lock path: node_modules displayName: Cache Yarn packages - script: yarn --frozen-lockfile @@ -58,7 +58,7 @@ jobs: displayName: 'Install Node.js' - task: CacheBeta@1 inputs: - key: yarn | $(Agent.OS) | yarn.lock + key: yarn1 | $(Agent.OS) | yarn.lock path: node_modules displayName: Cache Yarn packages - script: yarn --frozen-lockfile @@ -80,7 +80,7 @@ jobs: displayName: 'Install Node.js' - task: CacheBeta@1 inputs: - key: yarn | $(Agent.OS) | yarn.lock + key: yarn1 | $(Agent.OS) | yarn.lock path: node_modules displayName: Cache Yarn packages - script: yarn --frozen-lockfile @@ -105,7 +105,7 @@ jobs: displayName: 'Install Yarn' - task: CacheBeta@1 inputs: - key: yarn | $(Agent.OS) | yarn.lock + key: yarn1 | $(Agent.OS) | yarn.lock path: node_modules displayName: Cache Yarn packages - script: yarn --frozen-lockfile @@ -127,7 +127,7 @@ jobs: displayName: 'Install Node.js' - task: CacheBeta@1 inputs: - key: yarn | $(Agent.OS) | yarn.lock + key: yarn1 | $(Agent.OS) | yarn.lock path: node_modules displayName: Cache Yarn packages - script: yarn --frozen-lockfile @@ -159,7 +159,7 @@ jobs: displayName: 'Install Yarn' - task: CacheBeta@1 inputs: - key: yarn | $(Agent.OS) | yarn.lock + key: yarn1 | $(Agent.OS) | yarn.lock path: node_modules displayName: Cache Yarn packages - script: yarn --frozen-lockfile From d2164584d53dfc59362f0e5702b45a6f56554488 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 5 Nov 2019 11:56:44 -0800 Subject: [PATCH 06/16] Fix error in yml --- azure-pipelines.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4eb35079..9117b885 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -93,7 +93,6 @@ jobs: - job: Linux_IntegrationTests pool: vmImage: 'ubuntu-16.04' - variables: steps: - task: NodeTool@0 inputs: @@ -119,7 +118,6 @@ jobs: - job: macOS_IntegrationTests pool: vmImage: 'xcode9-macos10.13' - variables: steps: - task: NodeTool@0 inputs: From c974b273d40c6e2f595539bcc2fa07152ce51fa3 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 5 Nov 2019 12:41:03 -0800 Subject: [PATCH 07/16] Install puppeteer explicitly --- azure-pipelines.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9117b885..ff13e616 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -109,6 +109,8 @@ jobs: displayName: Cache Yarn packages - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' + - script: yarn add puppeteer + displayName: 'Install puppeteer' - script: | yarn start & sleep 10 @@ -130,6 +132,8 @@ jobs: displayName: Cache Yarn packages - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' + - script: yarn add puppeteer + displayName: 'Install puppeteer' - script: | yarn start & sleep 10 From 0630baaf0295d4100c5d40e87463070c3fe316d3 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 5 Nov 2019 12:50:37 -0800 Subject: [PATCH 08/16] Don't cache on integration tests --- azure-pipelines.yml | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ff13e616..aaa2b6ea 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -20,7 +20,7 @@ jobs: displayName: 'Install Yarn' - task: CacheBeta@1 inputs: - key: yarn1 | $(Agent.OS) | yarn.lock + key: yarn2 | $(Agent.OS) | yarn.lock path: node_modules displayName: Cache Yarn packages - script: yarn --frozen-lockfile @@ -58,7 +58,7 @@ jobs: displayName: 'Install Node.js' - task: CacheBeta@1 inputs: - key: yarn1 | $(Agent.OS) | yarn.lock + key: yarn2 | $(Agent.OS) | yarn.lock path: node_modules displayName: Cache Yarn packages - script: yarn --frozen-lockfile @@ -80,7 +80,7 @@ jobs: displayName: 'Install Node.js' - task: CacheBeta@1 inputs: - key: yarn1 | $(Agent.OS) | yarn.lock + key: yarn2 | $(Agent.OS) | yarn.lock path: node_modules displayName: Cache Yarn packages - script: yarn --frozen-lockfile @@ -102,11 +102,6 @@ jobs: inputs: versionSpec: '1.x' displayName: 'Install Yarn' - - task: CacheBeta@1 - inputs: - key: yarn1 | $(Agent.OS) | yarn.lock - path: node_modules - displayName: Cache Yarn packages - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' - script: yarn add puppeteer @@ -125,11 +120,6 @@ jobs: inputs: versionSpec: '8.x' displayName: 'Install Node.js' - - task: CacheBeta@1 - inputs: - key: yarn1 | $(Agent.OS) | yarn.lock - path: node_modules - displayName: Cache Yarn packages - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' - script: yarn add puppeteer @@ -161,7 +151,7 @@ jobs: displayName: 'Install Yarn' - task: CacheBeta@1 inputs: - key: yarn1 | $(Agent.OS) | yarn.lock + key: yarn2 | $(Agent.OS) | yarn.lock path: node_modules displayName: Cache Yarn packages - script: yarn --frozen-lockfile From fc0568074ffb7577680c6646725ce2053a145ada Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 6 Nov 2019 10:37:00 -0800 Subject: [PATCH 09/16] Cache node modules with puppeteer --- azure-pipelines.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index aaa2b6ea..b4a6d940 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -98,6 +98,11 @@ jobs: inputs: versionSpec: '8.x' displayName: 'Install Node.js' + - task: CacheBeta@1 + inputs: + key: yarn_puppeteer | $(Agent.OS) | yarn.lock + path: node_modules + displayName: Cache Yarn packages - task: YarnInstaller@3 inputs: versionSpec: '1.x' @@ -120,6 +125,11 @@ jobs: inputs: versionSpec: '8.x' displayName: 'Install Node.js' + - task: CacheBeta@1 + inputs: + key: yarn_puppeteer | $(Agent.OS) | yarn.lock + path: node_modules + displayName: Cache Yarn packages - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' - script: yarn add puppeteer From d4dbdac73f6bd20764ee2e1626c0f9a4265502c6 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 6 Nov 2019 10:53:42 -0800 Subject: [PATCH 10/16] Don't cache integration test modules --- azure-pipelines.yml | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b4a6d940..7ddb534f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -22,7 +22,7 @@ jobs: inputs: key: yarn2 | $(Agent.OS) | yarn.lock path: node_modules - displayName: Cache Yarn packages + displayName: Cache node modules - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' - script: yarn test-unit --forbid-only @@ -60,7 +60,7 @@ jobs: inputs: key: yarn2 | $(Agent.OS) | yarn.lock path: node_modules - displayName: Cache Yarn packages + displayName: Cache node modules - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' - script: yarn test-unit --forbid-only @@ -82,7 +82,7 @@ jobs: inputs: key: yarn2 | $(Agent.OS) | yarn.lock path: node_modules - displayName: Cache Yarn packages + displayName: Cache node modules - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' - script: yarn test-unit --forbid-only @@ -102,7 +102,7 @@ jobs: inputs: key: yarn_puppeteer | $(Agent.OS) | yarn.lock path: node_modules - displayName: Cache Yarn packages + displayName: Cache node modules - task: YarnInstaller@3 inputs: versionSpec: '1.x' @@ -125,11 +125,6 @@ jobs: inputs: versionSpec: '8.x' displayName: 'Install Node.js' - - task: CacheBeta@1 - inputs: - key: yarn_puppeteer | $(Agent.OS) | yarn.lock - path: node_modules - displayName: Cache Yarn packages - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' - script: yarn add puppeteer @@ -159,11 +154,6 @@ jobs: inputs: versionSpec: '1.x' displayName: 'Install Yarn' - - task: CacheBeta@1 - inputs: - key: yarn2 | $(Agent.OS) | yarn.lock - path: node_modules - displayName: Cache Yarn packages - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' - script: NPM_AUTH_TOKEN="$(NPM_AUTH_TOKEN)" node ./bin/publish.js From d079775690a5e93f4d06971c7cc151912a7e569b Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 6 Nov 2019 11:04:37 -0800 Subject: [PATCH 11/16] Merge coverage check into regular unit test check Fixes #2542 --- azure-pipelines.yml | 17 +++-------------- bin/test.js | 21 ++++++++++++++++++++- package.json | 1 + 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7ddb534f..415f1fb2 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -25,26 +25,15 @@ jobs: displayName: Cache node modules - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' - - script: yarn test-unit --forbid-only + - script: yarn test-coverage --forbid-only displayName: 'Unit tests' - script: yarn lint displayName: 'Lint' - - script: | - NODE_PATH=$(pwd)/out ./node_modules/.bin/nyc ./node_modules/.bin/mocha './out/*test.js' './out/**/*test.js' - ./node_modules/.bin/nyc report --reporter=cobertura - displayName: 'Coverage report' - task: PublishCodeCoverageResults@1 inputs: codeCoverageTool: Cobertura summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/*coverage.xml' displayName: 'Publish coverage' - - task: mspremier.BuildQualityChecks.QualityChecks-task.BuildQualityChecks@6 - displayName: 'Check build quality' - inputs: - checkCoverage: true - coverageType: lines - coverageThreshold: 60 - coverageFailOption: fixed - job: macOS pool: @@ -63,7 +52,7 @@ jobs: displayName: Cache node modules - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' - - script: yarn test-unit --forbid-only + - script: yarn test-coverage --forbid-only displayName: 'Unit tests' - script: yarn lint displayName: 'Lint' @@ -85,7 +74,7 @@ jobs: displayName: Cache node modules - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' - - script: yarn test-unit --forbid-only + - script: yarn test-coverage --forbid-only displayName: 'Unit tests' - script: yarn lint displayName: 'Lint' diff --git a/bin/test.js b/bin/test.js index 3b08d4a1..2b15e907 100644 --- a/bin/test.js +++ b/bin/test.js @@ -28,6 +28,26 @@ if (process.argv.length > 2) { } } +const checkCoverage = flagArgs.indexOf('--coverage') >= 0; + +if (checkCoverage) { + flagArgs.splice(flagArgs.indexOf('--coverage'), 1); + const executable = path.resolve(__dirname, '../node_modules/.bin/nyc'); + const args = ['--check-coverage', '--lines=100', path.resolve(__dirname, '../node_modules/.bin/mocha'), ...testFiles, ...flagArgs]; + console.info('executable', executable); + console.info('args', args); + const run = cp.spawnSync( + executable, + args, + { + cwd: path.resolve(__dirname, '..'), + env, + stdio: 'inherit' + } + ); + process.exit(run.status); +} + const run = cp.spawnSync( path.resolve(__dirname, '../node_modules/.bin/mocha'), [...testFiles, ...flagArgs], @@ -37,5 +57,4 @@ const run = cp.spawnSync( stdio: 'inherit' } ); - process.exit(run.status); diff --git a/package.json b/package.json index 0150569d..c33c48bd 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "posttest": "npm run lint", "test-api": "mocha \"**/*.api.js\"", "test-unit": "node ./bin/test.js", + "test-coverage": "node ./bin/test.js --coverage", "build": "tsc -b ./tsconfig.all.json", "prepare": "npm run setup", "setup": "npm run build", From 030a8bda80359623fd4a80cce7ee2c8d5dd2508f Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 6 Nov 2019 11:08:39 -0800 Subject: [PATCH 12/16] Set coverage lines threshold to 60% --- bin/test.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/test.js b/bin/test.js index 2b15e907..94b4ac7b 100644 --- a/bin/test.js +++ b/bin/test.js @@ -6,6 +6,8 @@ const cp = require('child_process'); const path = require('path'); +const COVERAGE_LINES_THRESHOLD = 60; + // Add `out` to the NODE_PATH so absolute paths can be resolved. const env = { ...process.env }; env.NODE_PATH = path.resolve(__dirname, '../out'); @@ -33,7 +35,7 @@ const checkCoverage = flagArgs.indexOf('--coverage') >= 0; if (checkCoverage) { flagArgs.splice(flagArgs.indexOf('--coverage'), 1); const executable = path.resolve(__dirname, '../node_modules/.bin/nyc'); - const args = ['--check-coverage', '--lines=100', path.resolve(__dirname, '../node_modules/.bin/mocha'), ...testFiles, ...flagArgs]; + const args = ['--check-coverage', `--lines=${COVERAGE_LINES_THRESHOLD}`, path.resolve(__dirname, '../node_modules/.bin/mocha'), ...testFiles, ...flagArgs]; console.info('executable', executable); console.info('args', args); const run = cp.spawnSync( From 48b20e32005d98a905c463c1acf9acc0bd9fd6b7 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 6 Nov 2019 11:08:47 -0800 Subject: [PATCH 13/16] Don't run through nyc on mac and Windows --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 415f1fb2..a4f6ede8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -52,7 +52,7 @@ jobs: displayName: Cache node modules - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' - - script: yarn test-coverage --forbid-only + - script: yarn test-unit --forbid-only displayName: 'Unit tests' - script: yarn lint displayName: 'Lint' @@ -74,7 +74,7 @@ jobs: displayName: Cache node modules - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' - - script: yarn test-coverage --forbid-only + - script: yarn test-unit --forbid-only displayName: 'Unit tests' - script: yarn lint displayName: 'Lint' From fe2f1ea4df1b0b426057944af9d5d352bbd96fc7 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 6 Nov 2019 11:20:52 -0800 Subject: [PATCH 14/16] Get Windows unit tests running again Fixes #2543 --- bin/test.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/test.js b/bin/test.js index 94b4ac7b..bd1784fb 100644 --- a/bin/test.js +++ b/bin/test.js @@ -34,8 +34,8 @@ const checkCoverage = flagArgs.indexOf('--coverage') >= 0; if (checkCoverage) { flagArgs.splice(flagArgs.indexOf('--coverage'), 1); - const executable = path.resolve(__dirname, '../node_modules/.bin/nyc'); - const args = ['--check-coverage', `--lines=${COVERAGE_LINES_THRESHOLD}`, path.resolve(__dirname, '../node_modules/.bin/mocha'), ...testFiles, ...flagArgs]; + const executable = npmBinScript('nyc'); + const args = ['--check-coverage', `--lines=${COVERAGE_LINES_THRESHOLD}`, npmBinScript('mocha'), ...testFiles, ...flagArgs]; console.info('executable', executable); console.info('args', args); const run = cp.spawnSync( @@ -51,7 +51,7 @@ if (checkCoverage) { } const run = cp.spawnSync( - path.resolve(__dirname, '../node_modules/.bin/mocha'), + npmBinScript('mocha'), [...testFiles, ...flagArgs], { cwd: path.resolve(__dirname, '..'), @@ -59,4 +59,9 @@ const run = cp.spawnSync( stdio: 'inherit' } ); + +function npmBinScript(script) { + return path.resolve(__dirname, `../node_modules/.bin/` + (process.platform === 'win32' ? `${script}.cmd` : script)); +} + process.exit(run.status); From 31afe5b30545da59a965ff69ba756c54bbe02308 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 6 Nov 2019 11:23:42 -0800 Subject: [PATCH 15/16] test-coverage -> test-unit-coverage --- azure-pipelines.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a4f6ede8..1ee66ddb 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -25,7 +25,7 @@ jobs: displayName: Cache node modules - script: yarn --frozen-lockfile displayName: 'Install dependencies and build' - - script: yarn test-coverage --forbid-only + - script: yarn test-unit-coverage --forbid-only displayName: 'Unit tests' - script: yarn lint displayName: 'Lint' diff --git a/package.json b/package.json index c33c48bd..7ed71741 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "posttest": "npm run lint", "test-api": "mocha \"**/*.api.js\"", "test-unit": "node ./bin/test.js", - "test-coverage": "node ./bin/test.js --coverage", + "test-unit-coverage": "node ./bin/test.js --coverage", "build": "tsc -b ./tsconfig.all.json", "prepare": "npm run setup", "setup": "npm run build", From 08782949648f064620a1cc646d7199cd70842c36 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 6 Nov 2019 11:24:34 -0800 Subject: [PATCH 16/16] Skip Terminal2 tests on Windows --- src/Terminal2.test.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Terminal2.test.ts b/src/Terminal2.test.ts index efb2a446..f7046240 100644 --- a/src/Terminal2.test.ts +++ b/src/Terminal2.test.ts @@ -34,7 +34,6 @@ if (os.platform() === 'darwin') { // filter skipFilenames const FILES = TESTFILES.filter(value => SKIP_FILES.indexOf(value.split('/').slice(-1)[0]) === -1); - describe('Escape Sequence Files', function(): void { this.timeout(1000); @@ -44,6 +43,9 @@ describe('Escape Sequence Files', function(): void { let customHandler: IDisposable | undefined; before(() => { + if (process.platform === 'win32') { + return; + } ptyTerm = (pty as any).open({cols: COLS, rows: ROWS}); slaveEnd = ptyTerm._slave; term = new Terminal({cols: COLS, rows: ROWS}); @@ -51,12 +53,15 @@ describe('Escape Sequence Files', function(): void { }); after(() => { + if (process.platform === 'win32') { + return; + } ptyTerm._master.end(); ptyTerm._master.destroy(); }); FILES.forEach(filename => { - it(filename.split('/').slice(-1)[0], async () => { + (process.platform === 'win32' ? it.skip : it)(filename.split('/').slice(-1)[0], async () => { // reset terminal and handler if (customHandler) { customHandler.dispose();