From 3f0ebdd8ecc7914e6db7c9a5935cfe2e0e9d5159 Mon Sep 17 00:00:00 2001 From: maxjeffos <44034094+maxjeffos@users.noreply.github.com> Date: Mon, 14 Sep 2020 16:52:58 -0400 Subject: [PATCH 1/4] chore: add test:test suite to test --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c1350820ed..10571067c0 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "test:system": "tap test/system/*.test.* -Rspec --timeout=300 --node-arg=-r --node-arg=ts-node/register", "test:jest": "jest test/*.spec.ts", "test:test": "tap test/*.test.* -Rspec --timeout=300 --node-arg=-r --node-arg=ts-node/register", - "test": "npm run test:acceptance && npm run test:system && npm run test:jest", + "test": "npm run test:acceptance && npm run test:system && npm run test:test && npm run test:jest", "test-windows": "tap test/acceptance/**/*.test.* -Rspec --timeout=300 --node-arg=-r --node-arg=ts-node/register && npm run test:system && npm run test:test", "lint": "run-p --aggregate-output lint:*", "lint:js": "eslint --color --cache 'src/**/*.{js,ts}'", From c4de9779811ab449dd01796005878c71732ffc90 Mon Sep 17 00:00:00 2001 From: maxjeffos <44034094+maxjeffos@users.noreply.github.com> Date: Tue, 15 Sep 2020 19:00:41 -0400 Subject: [PATCH 2/4] test: make cpp jest tests work on windows --- test/ecosystems.spec.ts | 10 ++++++++++ .../cpp-project/debug-display-windows.txt | 15 +++++++++++++++ test/fixtures/cpp-project/display-windows.txt | 10 ++++++++++ test/fixtures/cpp-project/error-windows.txt | 2 ++ 4 files changed, 37 insertions(+) create mode 100644 test/fixtures/cpp-project/debug-display-windows.txt create mode 100644 test/fixtures/cpp-project/display-windows.txt create mode 100644 test/fixtures/cpp-project/error-windows.txt diff --git a/test/ecosystems.spec.ts b/test/ecosystems.spec.ts index 9a7ecf4aa8..30cadb24e5 100644 --- a/test/ecosystems.spec.ts +++ b/test/ecosystems.spec.ts @@ -5,6 +5,12 @@ import * as ecosystems from '../src/lib/ecosystems'; import * as request from '../src/lib/request/promise'; import { Options } from '../src/lib/types'; import { TestCommandResult } from '../src/cli/commands/types'; +const osName = require('os-name'); + +const isWindows = + osName() + .toLowerCase() + .indexOf('windows') === 0; describe('ecosystems', () => { describe('getPlugin', () => { @@ -48,6 +54,10 @@ describe('ecosystems', () => { const cwd = process.cwd(); function readFixture(filename: string) { + if (isWindows) { + filename = filename.replace('.txt', '-windows.txt'); + } + const filePath = path.join(fixturePath, filename); return fs.readFileSync(filePath, 'utf-8'); } diff --git a/test/fixtures/cpp-project/debug-display-windows.txt b/test/fixtures/cpp-project/debug-display-windows.txt new file mode 100644 index 0000000000..6508bfa175 --- /dev/null +++ b/test/fixtures/cpp-project/debug-display-windows.txt @@ -0,0 +1,15 @@ +Fingerprints +52d1b046047db9ea0c581cafd4c68fe5 add.cpp +aeca71a6e39f99a24ecf4c088eee9cb8 add.h +ad3365b3370ef6b1c3e778f875055f19 main.cpp + +Dependencies +add@1.2.3 + +Issues +✗ Cross-site Scripting (XSS) [medium] + https://snyk.io/vuln/cpp:add:20161130 + in add@1.2.3 + fix version 1.2.4 + +Tested 1 dependency for known issues, found 1 issue. diff --git a/test/fixtures/cpp-project/display-windows.txt b/test/fixtures/cpp-project/display-windows.txt new file mode 100644 index 0000000000..d3b0c43b94 --- /dev/null +++ b/test/fixtures/cpp-project/display-windows.txt @@ -0,0 +1,10 @@ +Dependencies +add@1.2.3 + +Issues +✗ Cross-site Scripting (XSS) [medium] + https://snyk.io/vuln/cpp:add:20161130 + in add@1.2.3 + fix version 1.2.4 + +Tested 1 dependency for known issues, found 1 issue. diff --git a/test/fixtures/cpp-project/error-windows.txt b/test/fixtures/cpp-project/error-windows.txt new file mode 100644 index 0000000000..61a920da3c --- /dev/null +++ b/test/fixtures/cpp-project/error-windows.txt @@ -0,0 +1,2 @@ +Errors +Could not test dependencies in . From cadcc1a6d364ad7690dbf1e11fe26f92e477b3ae Mon Sep 17 00:00:00 2001 From: maxjeffos <44034094+maxjeffos@users.noreply.github.com> Date: Tue, 15 Sep 2020 19:03:27 -0400 Subject: [PATCH 3/4] chore: make jest test suite run on windows --- jest.config.js | 11 +++++++++-- package.json | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/jest.config.js b/jest.config.js index 262874bc32..05bab2228e 100644 --- a/jest.config.js +++ b/jest.config.js @@ -5,6 +5,13 @@ module.exports = { collectCoverage: false, // not collecting coverage for now collectCoverageFrom: ['src/**/*.ts'], coverageReporters: ['text-summary', 'html'], - testMatch: ['**/*.spec.ts'], // Remove when all tests are using Jest - modulePathIgnorePatterns: ['/test/.*fixtures'], + testMatch: [ + '/test/*.spec.ts', + '\\test\\*.spec.ts', // for Windows + ], + modulePathIgnorePatterns: [ + '/test/.*fixtures', + '/test/acceptance/*', + '/test/acceptance/workspaces/*' // to avoid `jest-haste-map: Haste module naming collision` errors + ], }; diff --git a/package.json b/package.json index 10571067c0..bd25632312 100644 --- a/package.json +++ b/package.json @@ -28,10 +28,10 @@ "test:common": "npm run check-tests && npm run lint && node --require ts-node/register src/cli test --org=snyk", "test:acceptance": "tap test/acceptance/**/*.test.* test/acceptance/*.test.* -Rspec --timeout=300 --node-arg=-r --node-arg=ts-node/register", "test:system": "tap test/system/*.test.* -Rspec --timeout=300 --node-arg=-r --node-arg=ts-node/register", - "test:jest": "jest test/*.spec.ts", + "test:jest": "jest", "test:test": "tap test/*.test.* -Rspec --timeout=300 --node-arg=-r --node-arg=ts-node/register", "test": "npm run test:acceptance && npm run test:system && npm run test:test && npm run test:jest", - "test-windows": "tap test/acceptance/**/*.test.* -Rspec --timeout=300 --node-arg=-r --node-arg=ts-node/register && npm run test:system && npm run test:test", + "test-windows": "tap test/acceptance/**/*.test.* -Rspec --timeout=300 --node-arg=-r --node-arg=ts-node/register && npm run test:system && npm run test:test && npm run test:jest", "lint": "run-p --aggregate-output lint:*", "lint:js": "eslint --color --cache 'src/**/*.{js,ts}'", "lint:formatting": "prettier --check '{src,test,scripts}/**/*.{js,ts}'", From ded859a74499e17510f346afc22f69c257b57223 Mon Sep 17 00:00:00 2001 From: maxjeffos <44034094+maxjeffos@users.noreply.github.com> Date: Thu, 17 Sep 2020 13:56:14 -0400 Subject: [PATCH 4/4] chore: align acceptance test execution --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index bd25632312..b59dd5a684 100644 --- a/package.json +++ b/package.json @@ -27,11 +27,12 @@ "prepare": "npm run build", "test:common": "npm run check-tests && npm run lint && node --require ts-node/register src/cli test --org=snyk", "test:acceptance": "tap test/acceptance/**/*.test.* test/acceptance/*.test.* -Rspec --timeout=300 --node-arg=-r --node-arg=ts-node/register", + "test:acceptance-windows": "tap test/acceptance/**/*.test.* -Rspec --timeout=300 --node-arg=-r --node-arg=ts-node/register", "test:system": "tap test/system/*.test.* -Rspec --timeout=300 --node-arg=-r --node-arg=ts-node/register", "test:jest": "jest", "test:test": "tap test/*.test.* -Rspec --timeout=300 --node-arg=-r --node-arg=ts-node/register", "test": "npm run test:acceptance && npm run test:system && npm run test:test && npm run test:jest", - "test-windows": "tap test/acceptance/**/*.test.* -Rspec --timeout=300 --node-arg=-r --node-arg=ts-node/register && npm run test:system && npm run test:test && npm run test:jest", + "test-windows": "npm run test:acceptance-windows && npm run test:system && npm run test:test && npm run test:jest", "lint": "run-p --aggregate-output lint:*", "lint:js": "eslint --color --cache 'src/**/*.{js,ts}'", "lint:formatting": "prettier --check '{src,test,scripts}/**/*.{js,ts}'",