From e156d97bf1e8069beff4dbd6491ba3139cdf99bc Mon Sep 17 00:00:00 2001 From: Gant Date: Thu, 1 Mar 2018 20:20:01 -0600 Subject: [PATCH 01/13] improved integraiton testing :white_check_mark: --- .../solidarity-check/check-valid.ts | 46 +++++++++++++++++++ .../sandbox/solidarity_json/.solidarity.json | 6 +-- 2 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 __tests__/integration/solidarity-check/check-valid.ts diff --git a/__tests__/integration/solidarity-check/check-valid.ts b/__tests__/integration/solidarity-check/check-valid.ts new file mode 100644 index 0000000..6fae13f --- /dev/null +++ b/__tests__/integration/solidarity-check/check-valid.ts @@ -0,0 +1,46 @@ +import execa from 'execa' +import tempy from 'tempy' + +const filesystem = require('fs-jetpack') +const SOLIDARITY = `${process.cwd()}/bin/solidarity` +const origCwd = process.cwd() +let originalTimeout + +beforeAll(() => { + // These can be slow on CI + originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL + jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000 +}) + +afterAll(function() { + // Fix timeout change + jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout +}) + +test('default looks for .solidarity file', async done => { + const tempDir = tempy.directory() + filesystem.copy('__tests__/sandbox/solidarity_json/.solidarity.json', `${tempDir}/.solidarity`) + process.chdir(tempDir) + try { + await execa(SOLIDARITY) + done() + } catch (err) { + done.fail() + } +}) + +test('also looks for .solidarity.json file', async done => { + const tempDir = tempy.directory() + filesystem.copy('__tests__/sandbox/solidarity_json/.solidarity.json', `${tempDir}/.solidarity.json`) + process.chdir(tempDir) + try { + await execa(SOLIDARITY) + done() + } catch (err) { + done.fail() + } +}) + +afterEach(() => { + process.chdir(origCwd) +}) diff --git a/__tests__/sandbox/solidarity_json/.solidarity.json b/__tests__/sandbox/solidarity_json/.solidarity.json index c46d251..786968b 100644 --- a/__tests__/sandbox/solidarity_json/.solidarity.json +++ b/__tests__/sandbox/solidarity_json/.solidarity.json @@ -2,10 +2,6 @@ "requirements": { "NPM": [{ "rule": "cli", "binary": "npm" }], "Yarn": [{ "rule": "cli", "binary": "yarn", "semver": "^1.0.0", "version": "--version" }], - "Node": [{ "rule": "cli", "binary": "node", "semver": ">=7.6.0", "error": "Upgrade to latest node >= 7.6 please."}], - "TypeScript Active": [ - { "rule": "dir", "location": "./src", "error": "Did you get this code from npm? Try github!" }, - { "rule": "dir", "location": "./dist", "error": "You haven't compiled. Run the build script!" } - ] + "Node": [{ "rule": "cli", "binary": "node", "semver": ">=7.6.0", "error": "Upgrade to latest node >= 7.6 please."}] } } From 0db8d99e1fbad294234105d3f77f6df31373dafc Mon Sep 17 00:00:00 2001 From: Gant Date: Thu, 1 Mar 2018 21:28:20 -0600 Subject: [PATCH 02/13] verified basic commands --- .../__snapshots__/check-valid.ts.snap | 56 +++++++++++++++++++ .../solidarity-check/check-valid.ts | 23 +++++++- .../solidarity-report/report-basic.ts | 42 ++++++++++++++ 3 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 __tests__/integration/solidarity-check/__snapshots__/check-valid.ts.snap create mode 100644 __tests__/integration/solidarity-report/report-basic.ts diff --git a/__tests__/integration/solidarity-check/__snapshots__/check-valid.ts.snap b/__tests__/integration/solidarity-check/__snapshots__/check-valid.ts.snap new file mode 100644 index 0000000..ffaee90 --- /dev/null +++ b/__tests__/integration/solidarity-check/__snapshots__/check-valid.ts.snap @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`also looks for .solidarity.json file 1`] = ` +Object { + "cmd": "/Users/gantman/Documents/Projects/js/rn/node_packages/solidarity/bin/solidarity", + "code": 0, + "failed": false, + "killed": false, + "signal": null, + "stderr": "", + "stdout": " +✔︎ Solidarity checks valid", + "timedOut": false, +} +`; + +exports[`default looks for .solidarity file 1`] = ` +Object { + "cmd": "/Users/gantman/Documents/Projects/js/rn/node_packages/solidarity/bin/solidarity", + "code": 0, + "failed": false, + "killed": false, + "signal": null, + "stderr": "", + "stdout": " +✔︎ Solidarity checks valid", + "timedOut": false, +} +`; + +exports[`silent flag works 1`] = ` +Object { + "cmd": "/Users/gantman/Documents/Projects/js/rn/node_packages/solidarity/bin/solidarity --silent", + "code": 0, + "failed": false, + "killed": false, + "signal": null, + "stderr": "", + "stdout": "", + "timedOut": false, +} +`; + +exports[`verbose flag works 1`] = ` +Object { + "cmd": "/Users/gantman/Documents/Projects/js/rn/node_packages/solidarity/bin/solidarity --verbose", + "code": 0, + "failed": false, + "killed": false, + "signal": null, + "stderr": "", + "stdout": " +✔︎ Solidarity checks valid", + "timedOut": false, +} +`; diff --git a/__tests__/integration/solidarity-check/check-valid.ts b/__tests__/integration/solidarity-check/check-valid.ts index 6fae13f..aed0064 100644 --- a/__tests__/integration/solidarity-check/check-valid.ts +++ b/__tests__/integration/solidarity-check/check-valid.ts @@ -22,7 +22,7 @@ test('default looks for .solidarity file', async done => { filesystem.copy('__tests__/sandbox/solidarity_json/.solidarity.json', `${tempDir}/.solidarity`) process.chdir(tempDir) try { - await execa(SOLIDARITY) + await execa(SOLIDARITY).then(result => expect(result).toMatchSnapshot()) done() } catch (err) { done.fail() @@ -34,7 +34,26 @@ test('also looks for .solidarity.json file', async done => { filesystem.copy('__tests__/sandbox/solidarity_json/.solidarity.json', `${tempDir}/.solidarity.json`) process.chdir(tempDir) try { - await execa(SOLIDARITY) + await execa(SOLIDARITY).then(result => expect(result).toMatchSnapshot()) + done() + } catch (err) { + done.fail() + } +}) + +test('verbose flag works', async done => { + try { + await execa(SOLIDARITY, ['--verbose']).then(result => expect(result).toMatchSnapshot()) + done() + } catch (err) { + const x = err + done.fail() + } +}) + +test('silent flag works', async done => { + try { + await execa(SOLIDARITY, ['--silent']).then(result => expect(result).toMatchSnapshot()) done() } catch (err) { done.fail() diff --git a/__tests__/integration/solidarity-report/report-basic.ts b/__tests__/integration/solidarity-report/report-basic.ts new file mode 100644 index 0000000..5fbafd6 --- /dev/null +++ b/__tests__/integration/solidarity-report/report-basic.ts @@ -0,0 +1,42 @@ +import execa from 'execa' +import tempy from 'tempy' + +const filesystem = require('fs-jetpack') +const SOLIDARITY = `${process.cwd()}/bin/solidarity` +const origCwd = process.cwd() +let originalTimeout + +beforeAll(() => { + // These can be slow on CI + originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL + jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000 + const tempDir = tempy.directory() + filesystem.copy('__tests__/sandbox/solidarity_json/.solidarity.json', `${tempDir}/.solidarity`) + process.chdir(tempDir) +}) + +afterAll(function() { + // Fix timeout change + jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout +}) + +test('solidarity report works', async done => { + try { + execa(SOLIDARITY, ['report']).then(result => { + // check a few from the report + expect(result.stdout.includes('OS')).toBeTruthy() + expect(result.stdout.includes('CPU')).toBeTruthy() + expect(result.stdout.includes('Report Info')).toBeTruthy() + expect(result.stdout.includes('yarn')).toBeTruthy() + expect(result.stdout.includes('node')).toBeTruthy() + expect(result.code).toBe(0) + done() + }) + } catch (err) { + done.fail() + } +}) + +afterEach(() => { + process.chdir(origCwd) +}) From 7141494b16104aaf57c4ffc8567ce5f1256836d7 Mon Sep 17 00:00:00 2001 From: Gant Date: Thu, 1 Mar 2018 21:52:49 -0600 Subject: [PATCH 03/13] testing empty snapshot --- .../__snapshots__/snapshot-nada.ts.snap | 18 ++++++++++ .../solidarity-snapshot/snapshot-nada.ts | 36 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 __tests__/integration/solidarity-snapshot/__snapshots__/snapshot-nada.ts.snap create mode 100644 __tests__/integration/solidarity-snapshot/snapshot-nada.ts diff --git a/__tests__/integration/solidarity-snapshot/__snapshots__/snapshot-nada.ts.snap b/__tests__/integration/solidarity-snapshot/__snapshots__/snapshot-nada.ts.snap new file mode 100644 index 0000000..247be5d --- /dev/null +++ b/__tests__/integration/solidarity-snapshot/__snapshots__/snapshot-nada.ts.snap @@ -0,0 +1,18 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`solidarity report works 1`] = ` +Object { + "cmd": "/bin/sh -c echo n | /Users/gantman/Documents/Projects/js/rn/node_packages/solidarity/bin/solidarity snapshot", + "code": 0, + "failed": false, + "killed": false, + "signal": null, + "stderr": "", + "stdout": "? No \`.solidarity\` file found for this project. Would you like to create one? ( +Y/n) ? No \`.solidarity\` file found for this project. Would you like to create one? ( +Y/n) ? No \`.solidarity\` file found for this project. Would you like to create one? ? No \`.solidarity\` file found for this project. Would you like to create one? f +alse +[?25hNothing to do ¯\\\\_(ツ)_/¯", + "timedOut": false, +} +`; diff --git a/__tests__/integration/solidarity-snapshot/snapshot-nada.ts b/__tests__/integration/solidarity-snapshot/snapshot-nada.ts new file mode 100644 index 0000000..6fb9108 --- /dev/null +++ b/__tests__/integration/solidarity-snapshot/snapshot-nada.ts @@ -0,0 +1,36 @@ +import execa from 'execa' +import tempy from 'tempy' + +const SOLIDARITY = `${process.cwd()}/bin/solidarity` +const origCwd = process.cwd() +let originalTimeout + +beforeAll(() => { + // These can be slow on CI + originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL + jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000 + const tempDir = tempy.directory() + process.chdir(tempDir) +}) + +afterAll(function() { + // Fix timeout change + jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout +}) + +test('solidarity report works', async done => { + try { + execa.shell(`echo n | ${SOLIDARITY} snapshot`).then(result => { + // check a few from the report + expect(result).toMatchSnapshot() + expect(result.code).toBe(0) + done() + }) + } catch (err) { + done.fail() + } +}) + +afterEach(() => { + process.chdir(origCwd) +}) From 6b76f6e1336276c2d86f8e5e4bf34a462ea23ae9 Mon Sep 17 00:00:00 2001 From: Gant Date: Thu, 1 Mar 2018 22:33:04 -0600 Subject: [PATCH 04/13] handle errors better --- __tests__/command_helpers/getVersion.ts | 2 +- __tests__/command_helpers/removeNonVersionCharacters.ts | 2 +- src/extensions/functions/checkCLI.ts | 8 +++++++- src/extensions/functions/getVersion.ts | 2 +- src/extensions/functions/removeNonVersionCharacters.ts | 2 +- src/extensions/functions/updateRequirement.ts | 8 +++++++- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/__tests__/command_helpers/getVersion.ts b/__tests__/command_helpers/getVersion.ts index 94e758d..a2ab5a5 100644 --- a/__tests__/command_helpers/getVersion.ts +++ b/__tests__/command_helpers/getVersion.ts @@ -43,6 +43,6 @@ describe('getVersion', () => { } catch (e) { result = e } - expect(result).toEqual(" No version was detected from the output of the binary 'ls'") + expect(result).toEqual("No version was detected from the output of the binary 'ls'") }) }) diff --git a/__tests__/command_helpers/removeNonVersionCharacters.ts b/__tests__/command_helpers/removeNonVersionCharacters.ts index 2aaaec9..77db01f 100644 --- a/__tests__/command_helpers/removeNonVersionCharacters.ts +++ b/__tests__/command_helpers/removeNonVersionCharacters.ts @@ -13,7 +13,7 @@ test('parse the result', () => { test('throws an error when there is no version output', () => { const line = 'Homebrew without versions' const rule = { binary: 'ls' } - const errorMessage = ` No version was detected from the output of the binary '${rule.binary}'` + const errorMessage = `No version was detected from the output of the binary '${rule.binary}'` expect(() => { removeNonVersionCharacters(rule, line) }).toThrowError(errorMessage) diff --git a/src/extensions/functions/checkCLI.ts b/src/extensions/functions/checkCLI.ts index 80f7007..2807d87 100644 --- a/src/extensions/functions/checkCLI.ts +++ b/src/extensions/functions/checkCLI.ts @@ -15,7 +15,13 @@ module.exports = async (rule: CLIRule, context: SolidarityRunContext): Promise { const matchIndex = rule.matchIndex || 0 return foundVersions[matchIndex] } else { - throw ` No version was detected from the output of the binary '${rule.binary}'` + throw `No version was detected from the output of the binary '${rule.binary}'` } } diff --git a/src/extensions/functions/updateRequirement.ts b/src/extensions/functions/updateRequirement.ts index ac11efe..9c4f842 100644 --- a/src/extensions/functions/updateRequirement.ts +++ b/src/extensions/functions/updateRequirement.ts @@ -25,7 +25,13 @@ module.exports = async ( // Handle CLI rule update case 'cli': if (!rule.semver) return [] - const updateResult = await checkCLIForUpdates(rule, context) + let updateResult + try { + updateResult = await checkCLIForUpdates(rule, context) + } catch (e) { + spinner.fail(e) + return [] + } const lineMessage = rule.line ? ` line ${rule.line} at` : '' ruleString = `Keep ${rule.binary}${lineMessage} ${rule.semver}` if (updateResult) { From 3dbf7280066061f4131748511eadd6f2acdc9e3a Mon Sep 17 00:00:00 2001 From: Gant Date: Thu, 1 Mar 2018 23:01:43 -0600 Subject: [PATCH 05/13] fix snapshots to not be machine specific --- .../__snapshots__/check-valid.ts.snap | 52 +++---------------- .../solidarity-check/check-valid.ts | 16 ++++-- .../__snapshots__/snapshot-nada.ts.snap | 13 +---- .../solidarity-snapshot/snapshot-nada.ts | 2 +- 4 files changed, 22 insertions(+), 61 deletions(-) diff --git a/__tests__/integration/solidarity-check/__snapshots__/check-valid.ts.snap b/__tests__/integration/solidarity-check/__snapshots__/check-valid.ts.snap index ffaee90..2077041 100644 --- a/__tests__/integration/solidarity-check/__snapshots__/check-valid.ts.snap +++ b/__tests__/integration/solidarity-check/__snapshots__/check-valid.ts.snap @@ -1,56 +1,18 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`also looks for .solidarity.json file 1`] = ` -Object { - "cmd": "/Users/gantman/Documents/Projects/js/rn/node_packages/solidarity/bin/solidarity", - "code": 0, - "failed": false, - "killed": false, - "signal": null, - "stderr": "", - "stdout": " -✔︎ Solidarity checks valid", - "timedOut": false, -} +" +✔︎ Solidarity checks valid" `; exports[`default looks for .solidarity file 1`] = ` -Object { - "cmd": "/Users/gantman/Documents/Projects/js/rn/node_packages/solidarity/bin/solidarity", - "code": 0, - "failed": false, - "killed": false, - "signal": null, - "stderr": "", - "stdout": " -✔︎ Solidarity checks valid", - "timedOut": false, -} +" +✔︎ Solidarity checks valid" `; -exports[`silent flag works 1`] = ` -Object { - "cmd": "/Users/gantman/Documents/Projects/js/rn/node_packages/solidarity/bin/solidarity --silent", - "code": 0, - "failed": false, - "killed": false, - "signal": null, - "stderr": "", - "stdout": "", - "timedOut": false, -} -`; +exports[`silent flag works 1`] = `""`; exports[`verbose flag works 1`] = ` -Object { - "cmd": "/Users/gantman/Documents/Projects/js/rn/node_packages/solidarity/bin/solidarity --verbose", - "code": 0, - "failed": false, - "killed": false, - "signal": null, - "stderr": "", - "stdout": " -✔︎ Solidarity checks valid", - "timedOut": false, -} +" +✔︎ Solidarity checks valid" `; diff --git a/__tests__/integration/solidarity-check/check-valid.ts b/__tests__/integration/solidarity-check/check-valid.ts index aed0064..d71d59d 100644 --- a/__tests__/integration/solidarity-check/check-valid.ts +++ b/__tests__/integration/solidarity-check/check-valid.ts @@ -22,7 +22,9 @@ test('default looks for .solidarity file', async done => { filesystem.copy('__tests__/sandbox/solidarity_json/.solidarity.json', `${tempDir}/.solidarity`) process.chdir(tempDir) try { - await execa(SOLIDARITY).then(result => expect(result).toMatchSnapshot()) + await execa(SOLIDARITY).then(result => { + expect(result.stdout).toMatchSnapshot() + }) done() } catch (err) { done.fail() @@ -34,7 +36,9 @@ test('also looks for .solidarity.json file', async done => { filesystem.copy('__tests__/sandbox/solidarity_json/.solidarity.json', `${tempDir}/.solidarity.json`) process.chdir(tempDir) try { - await execa(SOLIDARITY).then(result => expect(result).toMatchSnapshot()) + await execa(SOLIDARITY).then(result => { + expect(result.stdout).toMatchSnapshot() + }) done() } catch (err) { done.fail() @@ -43,7 +47,9 @@ test('also looks for .solidarity.json file', async done => { test('verbose flag works', async done => { try { - await execa(SOLIDARITY, ['--verbose']).then(result => expect(result).toMatchSnapshot()) + await execa(SOLIDARITY, ['--verbose']).then(result => { + expect(result.stdout).toMatchSnapshot() + }) done() } catch (err) { const x = err @@ -53,7 +59,9 @@ test('verbose flag works', async done => { test('silent flag works', async done => { try { - await execa(SOLIDARITY, ['--silent']).then(result => expect(result).toMatchSnapshot()) + await execa(SOLIDARITY, ['--silent']).then(result => { + expect(result.stdout).toMatchSnapshot() + }) done() } catch (err) { done.fail() diff --git a/__tests__/integration/solidarity-snapshot/__snapshots__/snapshot-nada.ts.snap b/__tests__/integration/solidarity-snapshot/__snapshots__/snapshot-nada.ts.snap index 247be5d..6ffc40d 100644 --- a/__tests__/integration/solidarity-snapshot/__snapshots__/snapshot-nada.ts.snap +++ b/__tests__/integration/solidarity-snapshot/__snapshots__/snapshot-nada.ts.snap @@ -1,18 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`solidarity report works 1`] = ` -Object { - "cmd": "/bin/sh -c echo n | /Users/gantman/Documents/Projects/js/rn/node_packages/solidarity/bin/solidarity snapshot", - "code": 0, - "failed": false, - "killed": false, - "signal": null, - "stderr": "", - "stdout": "? No \`.solidarity\` file found for this project. Would you like to create one? ( +"? No \`.solidarity\` file found for this project. Would you like to create one? ( Y/n) ? No \`.solidarity\` file found for this project. Would you like to create one? ( Y/n) ? No \`.solidarity\` file found for this project. Would you like to create one? ? No \`.solidarity\` file found for this project. Would you like to create one? f alse -[?25hNothing to do ¯\\\\_(ツ)_/¯", - "timedOut": false, -} +[?25hNothing to do ¯\\\\_(ツ)_/¯" `; diff --git a/__tests__/integration/solidarity-snapshot/snapshot-nada.ts b/__tests__/integration/solidarity-snapshot/snapshot-nada.ts index 6fb9108..26ddce4 100644 --- a/__tests__/integration/solidarity-snapshot/snapshot-nada.ts +++ b/__tests__/integration/solidarity-snapshot/snapshot-nada.ts @@ -22,7 +22,7 @@ test('solidarity report works', async done => { try { execa.shell(`echo n | ${SOLIDARITY} snapshot`).then(result => { // check a few from the report - expect(result).toMatchSnapshot() + expect(result.stdout).toMatchSnapshot() expect(result.code).toBe(0) done() }) From 310bfa5609a332e64ec69a03e59a70da4175b81c Mon Sep 17 00:00:00 2001 From: Gant Date: Thu, 1 Mar 2018 23:17:57 -0600 Subject: [PATCH 06/13] fixup tests for windows --- __tests__/integration/solidarity-check/check-invalid.ts | 3 ++- __tests__/integration/solidarity-check/check-valid.ts | 9 +++++---- __tests__/integration/solidarity-report/report-basic.ts | 5 +++-- .../integration/solidarity-snapshot/snapshot-nada.ts | 3 ++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/__tests__/integration/solidarity-check/check-invalid.ts b/__tests__/integration/solidarity-check/check-invalid.ts index 95f178e..374bd34 100644 --- a/__tests__/integration/solidarity-check/check-invalid.ts +++ b/__tests__/integration/solidarity-check/check-invalid.ts @@ -1,7 +1,8 @@ import execa from 'execa' import tempy from 'tempy' -const SOLIDARITY = `${process.cwd()}/bin/solidarity` +const path = require('path') +const SOLIDARITY = `${process.cwd()}${path.sep}bin${path.sep}solidarity` const origCwd = process.cwd() let originalTimeout diff --git a/__tests__/integration/solidarity-check/check-valid.ts b/__tests__/integration/solidarity-check/check-valid.ts index d71d59d..26d5f23 100644 --- a/__tests__/integration/solidarity-check/check-valid.ts +++ b/__tests__/integration/solidarity-check/check-valid.ts @@ -1,8 +1,9 @@ import execa from 'execa' import tempy from 'tempy' +const path = require('path') const filesystem = require('fs-jetpack') -const SOLIDARITY = `${process.cwd()}/bin/solidarity` +const SOLIDARITY = `${process.cwd()}${path.sep}bin${path.sep}solidarity` const origCwd = process.cwd() let originalTimeout @@ -19,7 +20,7 @@ afterAll(function() { test('default looks for .solidarity file', async done => { const tempDir = tempy.directory() - filesystem.copy('__tests__/sandbox/solidarity_json/.solidarity.json', `${tempDir}/.solidarity`) + filesystem.copy(`__tests__${path.sep}sandbox${path.sep}solidarity_json${path.sep}.solidarity.json`, `${tempDir}${path.sep}.solidarity`) process.chdir(tempDir) try { await execa(SOLIDARITY).then(result => { @@ -33,7 +34,7 @@ test('default looks for .solidarity file', async done => { test('also looks for .solidarity.json file', async done => { const tempDir = tempy.directory() - filesystem.copy('__tests__/sandbox/solidarity_json/.solidarity.json', `${tempDir}/.solidarity.json`) + filesystem.copy(`__tests__${path.sep}sandbox${path.sep}solidarity_json${path.sep}.solidarity.json`, `${tempDir}${path.sep}.solidarity.json`) process.chdir(tempDir) try { await execa(SOLIDARITY).then(result => { @@ -52,7 +53,7 @@ test('verbose flag works', async done => { }) done() } catch (err) { - const x = err + console.log('\n\n\n', err) done.fail() } }) diff --git a/__tests__/integration/solidarity-report/report-basic.ts b/__tests__/integration/solidarity-report/report-basic.ts index 5fbafd6..dcbd7a6 100644 --- a/__tests__/integration/solidarity-report/report-basic.ts +++ b/__tests__/integration/solidarity-report/report-basic.ts @@ -1,8 +1,9 @@ import execa from 'execa' import tempy from 'tempy' +const path = require('path') const filesystem = require('fs-jetpack') -const SOLIDARITY = `${process.cwd()}/bin/solidarity` +const SOLIDARITY = `${process.cwd()}${path.sep}bin${path.sep}solidarity` const origCwd = process.cwd() let originalTimeout @@ -11,7 +12,7 @@ beforeAll(() => { originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000 const tempDir = tempy.directory() - filesystem.copy('__tests__/sandbox/solidarity_json/.solidarity.json', `${tempDir}/.solidarity`) + filesystem.copy(`__tests__${path.sep}sandbox${path.sep}solidarity_json${path.sep}.solidarity.json`, `${tempDir}${path.sep}.solidarity`) process.chdir(tempDir) }) diff --git a/__tests__/integration/solidarity-snapshot/snapshot-nada.ts b/__tests__/integration/solidarity-snapshot/snapshot-nada.ts index 26ddce4..0f455cc 100644 --- a/__tests__/integration/solidarity-snapshot/snapshot-nada.ts +++ b/__tests__/integration/solidarity-snapshot/snapshot-nada.ts @@ -1,7 +1,8 @@ import execa from 'execa' import tempy from 'tempy' -const SOLIDARITY = `${process.cwd()}/bin/solidarity` +const path = require('path') +const SOLIDARITY = `${process.cwd()}${path.sep}bin${path.sep}solidarity` const origCwd = process.cwd() let originalTimeout From 5b3ddb9a5178e8415ad26cf7831c24173f874bbb Mon Sep 17 00:00:00 2001 From: Gant Date: Thu, 1 Mar 2018 23:29:35 -0600 Subject: [PATCH 07/13] fixing more stuff for windows --- __tests__/integration/solidarity-check/check-valid.ts | 1 - __tests__/sandbox/solidarity_json/.solidarity.json | 1 - 2 files changed, 2 deletions(-) diff --git a/__tests__/integration/solidarity-check/check-valid.ts b/__tests__/integration/solidarity-check/check-valid.ts index 26d5f23..9ef4a46 100644 --- a/__tests__/integration/solidarity-check/check-valid.ts +++ b/__tests__/integration/solidarity-check/check-valid.ts @@ -53,7 +53,6 @@ test('verbose flag works', async done => { }) done() } catch (err) { - console.log('\n\n\n', err) done.fail() } }) diff --git a/__tests__/sandbox/solidarity_json/.solidarity.json b/__tests__/sandbox/solidarity_json/.solidarity.json index 786968b..431b266 100644 --- a/__tests__/sandbox/solidarity_json/.solidarity.json +++ b/__tests__/sandbox/solidarity_json/.solidarity.json @@ -1,7 +1,6 @@ { "requirements": { "NPM": [{ "rule": "cli", "binary": "npm" }], - "Yarn": [{ "rule": "cli", "binary": "yarn", "semver": "^1.0.0", "version": "--version" }], "Node": [{ "rule": "cli", "binary": "node", "semver": ">=7.6.0", "error": "Upgrade to latest node >= 7.6 please."}] } } From 48939b64b0d1e62e4acb76950a4494432ff315aa Mon Sep 17 00:00:00 2001 From: Gant Laborde Date: Fri, 2 Mar 2018 08:39:02 -0600 Subject: [PATCH 08/13] lower bar for tests --- __tests__/integration/solidarity-report/report-basic.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/__tests__/integration/solidarity-report/report-basic.ts b/__tests__/integration/solidarity-report/report-basic.ts index dcbd7a6..e00dfba 100644 --- a/__tests__/integration/solidarity-report/report-basic.ts +++ b/__tests__/integration/solidarity-report/report-basic.ts @@ -28,7 +28,6 @@ test('solidarity report works', async done => { expect(result.stdout.includes('OS')).toBeTruthy() expect(result.stdout.includes('CPU')).toBeTruthy() expect(result.stdout.includes('Report Info')).toBeTruthy() - expect(result.stdout.includes('yarn')).toBeTruthy() expect(result.stdout.includes('node')).toBeTruthy() expect(result.code).toBe(0) done() From caec851c4aa75d2cb436d806b474ed2bd57812b8 Mon Sep 17 00:00:00 2001 From: Gant Laborde Date: Fri, 2 Mar 2018 09:29:56 -0600 Subject: [PATCH 09/13] handling windows problems right --- .../solidarity-check/check-invalid.ts | 4 ++-- .../solidarity-check/check-valid.ts | 18 +++++++++--------- .../solidarity-report/report-basic.ts | 4 ++-- .../__snapshots__/snapshot-nada.ts.snap | 9 --------- .../solidarity-snapshot/snapshot-nada.ts | 6 +++--- 5 files changed, 16 insertions(+), 25 deletions(-) delete mode 100644 __tests__/integration/solidarity-snapshot/__snapshots__/snapshot-nada.ts.snap diff --git a/__tests__/integration/solidarity-check/check-invalid.ts b/__tests__/integration/solidarity-check/check-invalid.ts index 374bd34..43002bc 100644 --- a/__tests__/integration/solidarity-check/check-invalid.ts +++ b/__tests__/integration/solidarity-check/check-invalid.ts @@ -2,7 +2,7 @@ import execa from 'execa' import tempy from 'tempy' const path = require('path') -const SOLIDARITY = `${process.cwd()}${path.sep}bin${path.sep}solidarity` +const SOLIDARITY = `node ${process.cwd()}${path.sep}bin${path.sep}solidarity` const origCwd = process.cwd() let originalTimeout @@ -22,7 +22,7 @@ afterAll(function() { test('default looks for .solidarity file', async done => { try { - await execa(SOLIDARITY) + await execa.shellSync(SOLIDARITY) done.fail() } catch (err) { expect(err.code).not.toBe(0) diff --git a/__tests__/integration/solidarity-check/check-valid.ts b/__tests__/integration/solidarity-check/check-valid.ts index 9ef4a46..542f2f0 100644 --- a/__tests__/integration/solidarity-check/check-valid.ts +++ b/__tests__/integration/solidarity-check/check-valid.ts @@ -3,7 +3,7 @@ import tempy from 'tempy' const path = require('path') const filesystem = require('fs-jetpack') -const SOLIDARITY = `${process.cwd()}${path.sep}bin${path.sep}solidarity` +const SOLIDARITY = `node ${process.cwd()}${path.sep}bin${path.sep}solidarity` const origCwd = process.cwd() let originalTimeout @@ -23,10 +23,10 @@ test('default looks for .solidarity file', async done => { filesystem.copy(`__tests__${path.sep}sandbox${path.sep}solidarity_json${path.sep}.solidarity.json`, `${tempDir}${path.sep}.solidarity`) process.chdir(tempDir) try { - await execa(SOLIDARITY).then(result => { + await execa.shell(SOLIDARITY).then(result => { expect(result.stdout).toMatchSnapshot() + done() }) - done() } catch (err) { done.fail() } @@ -37,10 +37,10 @@ test('also looks for .solidarity.json file', async done => { filesystem.copy(`__tests__${path.sep}sandbox${path.sep}solidarity_json${path.sep}.solidarity.json`, `${tempDir}${path.sep}.solidarity.json`) process.chdir(tempDir) try { - await execa(SOLIDARITY).then(result => { + await execa.shell(SOLIDARITY).then(result => { expect(result.stdout).toMatchSnapshot() + done() }) - done() } catch (err) { done.fail() } @@ -48,10 +48,10 @@ test('also looks for .solidarity.json file', async done => { test('verbose flag works', async done => { try { - await execa(SOLIDARITY, ['--verbose']).then(result => { + await execa.shell(`${SOLIDARITY} --verbose`).then(result => { expect(result.stdout).toMatchSnapshot() + done() }) - done() } catch (err) { done.fail() } @@ -59,10 +59,10 @@ test('verbose flag works', async done => { test('silent flag works', async done => { try { - await execa(SOLIDARITY, ['--silent']).then(result => { + await execa.shell(`${SOLIDARITY} --silent`).then(result => { expect(result.stdout).toMatchSnapshot() + done() }) - done() } catch (err) { done.fail() } diff --git a/__tests__/integration/solidarity-report/report-basic.ts b/__tests__/integration/solidarity-report/report-basic.ts index e00dfba..4803f6b 100644 --- a/__tests__/integration/solidarity-report/report-basic.ts +++ b/__tests__/integration/solidarity-report/report-basic.ts @@ -3,7 +3,7 @@ import tempy from 'tempy' const path = require('path') const filesystem = require('fs-jetpack') -const SOLIDARITY = `${process.cwd()}${path.sep}bin${path.sep}solidarity` +const SOLIDARITY = `node ${process.cwd()}${path.sep}bin${path.sep}solidarity` const origCwd = process.cwd() let originalTimeout @@ -23,7 +23,7 @@ afterAll(function() { test('solidarity report works', async done => { try { - execa(SOLIDARITY, ['report']).then(result => { + execa.shell(`${SOLIDARITY} report`).then(result => { // check a few from the report expect(result.stdout.includes('OS')).toBeTruthy() expect(result.stdout.includes('CPU')).toBeTruthy() diff --git a/__tests__/integration/solidarity-snapshot/__snapshots__/snapshot-nada.ts.snap b/__tests__/integration/solidarity-snapshot/__snapshots__/snapshot-nada.ts.snap deleted file mode 100644 index 6ffc40d..0000000 --- a/__tests__/integration/solidarity-snapshot/__snapshots__/snapshot-nada.ts.snap +++ /dev/null @@ -1,9 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`solidarity report works 1`] = ` -"? No \`.solidarity\` file found for this project. Would you like to create one? ( -Y/n) ? No \`.solidarity\` file found for this project. Would you like to create one? ( -Y/n) ? No \`.solidarity\` file found for this project. Would you like to create one? ? No \`.solidarity\` file found for this project. Would you like to create one? f -alse -[?25hNothing to do ¯\\\\_(ツ)_/¯" -`; diff --git a/__tests__/integration/solidarity-snapshot/snapshot-nada.ts b/__tests__/integration/solidarity-snapshot/snapshot-nada.ts index 0f455cc..55e4422 100644 --- a/__tests__/integration/solidarity-snapshot/snapshot-nada.ts +++ b/__tests__/integration/solidarity-snapshot/snapshot-nada.ts @@ -2,7 +2,7 @@ import execa from 'execa' import tempy from 'tempy' const path = require('path') -const SOLIDARITY = `${process.cwd()}${path.sep}bin${path.sep}solidarity` +const SOLIDARITY = `node ${process.cwd()}${path.sep}bin${path.sep}solidarity` const origCwd = process.cwd() let originalTimeout @@ -22,8 +22,8 @@ afterAll(function() { test('solidarity report works', async done => { try { execa.shell(`echo n | ${SOLIDARITY} snapshot`).then(result => { - // check a few from the report - expect(result.stdout).toMatchSnapshot() + // do not snapshot stdout bc windows bitches + expect(result.stdout.includes('Nothing to do')).toBeTruthy() expect(result.code).toBe(0) done() }) From e121b47135a3d2ed2f2b281206c93c4b384d3992 Mon Sep 17 00:00:00 2001 From: Gant Laborde Date: Fri, 2 Mar 2018 09:44:32 -0600 Subject: [PATCH 10/13] add ugly output to tests for windows --- __tests__/integration/solidarity-check/check-valid.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/__tests__/integration/solidarity-check/check-valid.ts b/__tests__/integration/solidarity-check/check-valid.ts index 542f2f0..5fdbdf3 100644 --- a/__tests__/integration/solidarity-check/check-valid.ts +++ b/__tests__/integration/solidarity-check/check-valid.ts @@ -53,6 +53,7 @@ test('verbose flag works', async done => { done() }) } catch (err) { + console.error('Failed Verbose:', err) done.fail() } }) @@ -64,6 +65,7 @@ test('silent flag works', async done => { done() }) } catch (err) { + console.error('Failed Silent:', err) done.fail() } }) From a57c1a9ab887f7f708d47a444b820c82b58957c0 Mon Sep 17 00:00:00 2001 From: Gant Laborde Date: Fri, 2 Mar 2018 10:11:32 -0600 Subject: [PATCH 11/13] debugging cli --- __tests__/integration/solidarity-check/check-valid.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/__tests__/integration/solidarity-check/check-valid.ts b/__tests__/integration/solidarity-check/check-valid.ts index 5fdbdf3..ad172b3 100644 --- a/__tests__/integration/solidarity-check/check-valid.ts +++ b/__tests__/integration/solidarity-check/check-valid.ts @@ -47,6 +47,9 @@ test('also looks for .solidarity.json file', async done => { }) test('verbose flag works', async done => { + execa.shellSync('node --version') + execa.shellSync('npm --version') + console.warn(`${SOLIDARITY} --verbose`) try { await execa.shell(`${SOLIDARITY} --verbose`).then(result => { expect(result.stdout).toMatchSnapshot() From 975de77070c00587654d1f0ba2da76c419d20589 Mon Sep 17 00:00:00 2001 From: Gant Laborde Date: Fri, 2 Mar 2018 10:19:31 -0600 Subject: [PATCH 12/13] try lowering number for windows CI --- __tests__/integration/solidarity-check/check-valid.ts | 1 - __tests__/sandbox/solidarity_json/.solidarity.json | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/__tests__/integration/solidarity-check/check-valid.ts b/__tests__/integration/solidarity-check/check-valid.ts index ad172b3..2f6a3b8 100644 --- a/__tests__/integration/solidarity-check/check-valid.ts +++ b/__tests__/integration/solidarity-check/check-valid.ts @@ -49,7 +49,6 @@ test('also looks for .solidarity.json file', async done => { test('verbose flag works', async done => { execa.shellSync('node --version') execa.shellSync('npm --version') - console.warn(`${SOLIDARITY} --verbose`) try { await execa.shell(`${SOLIDARITY} --verbose`).then(result => { expect(result.stdout).toMatchSnapshot() diff --git a/__tests__/sandbox/solidarity_json/.solidarity.json b/__tests__/sandbox/solidarity_json/.solidarity.json index 431b266..c132fe1 100644 --- a/__tests__/sandbox/solidarity_json/.solidarity.json +++ b/__tests__/sandbox/solidarity_json/.solidarity.json @@ -1,6 +1,6 @@ { "requirements": { "NPM": [{ "rule": "cli", "binary": "npm" }], - "Node": [{ "rule": "cli", "binary": "node", "semver": ">=7.6.0", "error": "Upgrade to latest node >= 7.6 please."}] + "Node": [{ "rule": "cli", "binary": "node", "semver": ">=4.6.0", "error": "Upgrade to latest node >= 4.6 please."}] } } From 3bca7ad4eaba461d98e49626a850a2300654e56b Mon Sep 17 00:00:00 2001 From: Gant Laborde Date: Fri, 2 Mar 2018 10:33:08 -0600 Subject: [PATCH 13/13] stay in temp dir for test --- __tests__/integration/solidarity-check/check-valid.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/__tests__/integration/solidarity-check/check-valid.ts b/__tests__/integration/solidarity-check/check-valid.ts index 2f6a3b8..c738eaf 100644 --- a/__tests__/integration/solidarity-check/check-valid.ts +++ b/__tests__/integration/solidarity-check/check-valid.ts @@ -47,27 +47,29 @@ test('also looks for .solidarity.json file', async done => { }) test('verbose flag works', async done => { - execa.shellSync('node --version') - execa.shellSync('npm --version') + const tempDir = tempy.directory() + filesystem.copy(`__tests__${path.sep}sandbox${path.sep}solidarity_json${path.sep}.solidarity.json`, `${tempDir}${path.sep}.solidarity`) + process.chdir(tempDir) try { await execa.shell(`${SOLIDARITY} --verbose`).then(result => { expect(result.stdout).toMatchSnapshot() done() }) } catch (err) { - console.error('Failed Verbose:', err) done.fail() } }) test('silent flag works', async done => { + const tempDir = tempy.directory() + filesystem.copy(`__tests__${path.sep}sandbox${path.sep}solidarity_json${path.sep}.solidarity.json`, `${tempDir}${path.sep}.solidarity`) + process.chdir(tempDir) try { await execa.shell(`${SOLIDARITY} --silent`).then(result => { expect(result.stdout).toMatchSnapshot() done() }) } catch (err) { - console.error('Failed Silent:', err) done.fail() } })