Skip to content

Commit

Permalink
test: remove shelljs from all tests (#769)
Browse files Browse the repository at this point in the history
  • Loading branch information
armano2 committed Jun 5, 2022
1 parent ba6df7c commit bfe3bf1
Show file tree
Hide file tree
Showing 22 changed files with 438 additions and 395 deletions.
14 changes: 12 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
{
"extends": "standard"
}
"extends": "standard",
"overrides": [
{
"files": [
"packages/*/test{,/*}.js"
],
"env": {
"mocha": true
}
}
]
}
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,15 @@
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"forceable-tty": "^0.1.0",
"git-dummy-commit": "^1.2.0",
"git-tails": "^1.0.0",
"mkdirp": "^1.0.0",
"mocha": "^8.0.0",
"pinkie-promise": "^2.0.0",
"q": "^1.5.1",
"rimraf": "^3.0.2",
"safe-buffer": "5.2.1",
"semver": "^6.0.0",
"shelljs": "^0.8.0",
"sinon": "^12.0.0",
"sinon-chai": "^3.1.0",
"temp": "^0.9.0",
"through2": "^4.0.0",
"tmp": "^0.2.1",
"vinyl": "^2.1.0"
Expand Down
27 changes: 14 additions & 13 deletions packages/conventional-changelog-angular/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@
const conventionalChangelogCore = require('conventional-changelog-core')
const preset = require('../')
const expect = require('chai').expect
const mocha = require('mocha')
const describe = mocha.describe
const it = mocha.it
const gitDummyCommit = require('git-dummy-commit')
const shell = require('shelljs')
const through = require('through2')
const path = require('path')
const fs = require('fs')
const tmp = require('tmp')
const { gitInit, gitDummyCommit, exec } = require('../../../tools/test-tools')
const betterThanBefore = require('better-than-before')()
const preparing = betterThanBefore.preparing

betterThanBefore.setups([
function () {
shell.config.resetForTesting()
shell.cd(__dirname)
shell.rm('-rf', 'tmp')
shell.mkdir('tmp')
shell.cd('tmp')
shell.mkdir('git-templates')
shell.exec('git init --template=./git-templates')
const tmpDir = tmp.dirSync()
process.chdir(tmpDir.name)
gitInit()
fs.writeFileSync('./package.json', JSON.stringify({
name: 'conventional-changelog-core',
repository: {
type: 'git',
url: 'https://github.com/conventional-changelog/conventional-changelog.git'
}
}))

gitDummyCommit(['build: first build setup', 'BREAKING CHANGE: New build system.'])
gitDummyCommit(['ci(travis): add TravisCI pipeline', 'BREAKING CHANGE: Continuously integrated.'])
Expand Down Expand Up @@ -48,7 +49,7 @@ betterThanBefore.setups([
gitDummyCommit(['test(*): more tests', 'BREAKING CHANGE: The Change is huge.'])
},
function () {
shell.exec('git tag v1.0.0')
exec('git tag v1.0.0')
gitDummyCommit('feat: some more features')
},
function () {
Expand Down
36 changes: 15 additions & 21 deletions packages/conventional-changelog-atom/test/test.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,31 @@
'use strict'
const conventionalChangelogCore = require('conventional-changelog-core')
const config = require('../')
const mocha = require('mocha')
const describe = mocha.describe
const it = mocha.it
const before = mocha.before
const expect = require('chai').expect
const gitDummyCommit = require('git-dummy-commit')
const shell = require('shelljs')
const through = require('through2')
const tmp = require('tmp')
const { gitInit, gitDummyCommit } = require('../../../tools/test-tools')

tmp.setGracefulCleanup()

const oldDir = process.cwd()

describe('atom preset', function () {
before(function () {
shell.config.resetForTesting()
shell.cd(__dirname)
shell.rm('-rf', 'tmp')
shell.mkdir('tmp')
shell.cd('tmp')
shell.mkdir('git-templates')
shell.exec('git init --template=./git-templates')
before(() => {
const tmpDir = tmp.dirSync()
process.chdir(tmpDir.name)
gitInit()
gitDummyCommit([':arrow_down: exception-reporting'])
if (process.platform !== 'win32') {
// we need to escape backtick for bash but not for windows
// probably this should be done in git-dummy-commit or shelljs
gitDummyCommit([':bug: \\`updateContentDimensions\\` when model changes'])
} else {
gitDummyCommit([':bug: `updateContentDimensions` when model changes'])
}
gitDummyCommit([':bug: `updateContentDimensions` when model changes'])
gitDummyCommit(['Merge pull request #7881 from atom/bf-upgrade-babel-to-5.6.17'])
gitDummyCommit([':arrow_up: language-gfm@0.79.0'])
gitDummyCommit([':arrow_up: one-dark/light-ui@v1.0.1'])
})

after(() => {
process.chdir(oldDir)
})

it('should work if there is no semver tag', function (done) {
conventionalChangelogCore({
config: config
Expand Down
28 changes: 11 additions & 17 deletions packages/conventional-changelog-cli/test/test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
'use strict'
const concat = require('concat-stream')
const expect = require('chai').expect
const mocha = require('mocha')
const describe = mocha.describe
const it = mocha.it
const before = mocha.before
const after = mocha.after
const shell = require('shelljs')
const spawn = require('child_process').spawn
const fs = require('fs')
const path = require('path')
const rimraf = require('rimraf')
const { gitInit, exec } = require('../../../tools/test-tools')
const readFileSync = fs.readFileSync
const writeFileSync = fs.writeFileSync

Expand All @@ -21,15 +17,13 @@ function originalChangelog () {

describe('cli', function () {
before(function () {
shell.config.resetForTesting()
shell.cd(__dirname)
shell.rm('-rf', 'tmp')
shell.mkdir('tmp')
shell.cd('tmp')
shell.mkdir('git-templates')
shell.exec('git init --template=./git-templates')
process.chdir(__dirname)
rimraf.sync('tmp')
fs.mkdirSync('tmp')
process.chdir('tmp')
gitInit()
writeFileSync('test1', '')
shell.exec('git add --all && git commit -m"First commit"')
exec('git add --all && git commit -m"First commit"')
})

after(function () {
Expand Down Expand Up @@ -356,7 +350,7 @@ describe('cli', function () {

it('--preset should work', function (done) {
writeFileSync('angular', '')
shell.exec('git add --all && git commit -m"fix: fix it!"')
exec('git add --all && git commit -m"fix: fix it!"')
const cp = spawn(process.execPath, [cliPath, '--preset', 'angular'], {
stdio: [process.stdin, null, null]
})
Expand All @@ -368,8 +362,8 @@ describe('cli', function () {
}))
})
it('--preset "conventionalcommits" should work', function (done) {
writeFileSync('angular', '')
shell.exec('git add --all && git commit -m"fix: fix it!"')
writeFileSync('angular', '2')
exec('git add --all && git commit -m"fix: fix it!"')
const cp = spawn(process.execPath, [cliPath, '--preset', 'conventionalcommits'], {
stdio: [process.stdin, null, null]
})
Expand Down
47 changes: 23 additions & 24 deletions packages/conventional-changelog-codemirror/test/test.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
'use strict'
const conventionalChangelogCore = require('conventional-changelog-core')
const config = require('../')
const mocha = require('mocha')
const describe = mocha.describe
const it = mocha.it
const before = mocha.before
const expect = require('chai').expect
const shell = require('shelljs')
const through = require('through2')
const writeFileSync = require('fs').writeFileSync
const fs = require('fs')
const tmp = require('tmp')
const { gitInit, exec } = require('../../../tools/test-tools')

tmp.setGracefulCleanup()
const oldDir = process.cwd()

describe('codemirror preset', function () {
before(function () {
shell.config.resetForTesting()
shell.cd(__dirname)
shell.rm('-rf', 'tmp')
shell.mkdir('tmp')
shell.cd('tmp')
shell.mkdir('git-templates')
shell.exec('git init --template=./git-templates')
before(() => {
const tmpDir = tmp.dirSync()
process.chdir(tmpDir.name)
gitInit()
fs.writeFileSync('test1', '')
exec('git add --all && git commit -m"[tern addon] Use correct primary when selecting variables"')
fs.writeFileSync('test2', '')
exec('git add --all && git commit -m"[tern addon] Fix patch bc026f1 "')
fs.writeFileSync('test3', '')
exec('git add --all && git commit -m"[css mode] Add values for property flex-direction"')
fs.writeFileSync('test4', '')
exec('git add --all && git commit -m"[stylus mode] Fix highlight class after a $var"')
fs.writeFileSync('test5', '')
exec('git add --all && git commit -m"Bad commit"')
})

writeFileSync('test1', '')
shell.exec('git add --all && git commit -m"[tern addon] Use correct primary when selecting variables"')
writeFileSync('test2', '')
shell.exec('git add --all && git commit -m"[tern addon] Fix patch bc026f1 "')
writeFileSync('test3', '')
shell.exec('git add --all && git commit -m"[css mode] Add values for property flex-direction"')
writeFileSync('test4', '')
shell.exec('git add --all && git commit -m"[stylus mode] Fix highlight class after a $var"')
writeFileSync('test5', '')
shell.exec('git add --all && git commit -m"Bad commit"')
after(() => {
process.chdir(oldDir)
})

it('should work if there is no semver tag', function (done) {
Expand Down
30 changes: 15 additions & 15 deletions packages/conventional-changelog-conventionalcommits/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ const conventionalChangelogCore = require('conventional-changelog-core')
const getPreset = require('../')
const preset = getPreset()
const expect = require('chai').expect
const mocha = require('mocha')
const describe = mocha.describe
const it = mocha.it
const gitDummyCommit = require('git-dummy-commit')
const shell = require('shelljs')
const through = require('through2')
const path = require('path')
const fs = require('fs')
const tmp = require('tmp')
const { gitInit, gitDummyCommit, exec } = require('../../../tools/test-tools')
const betterThanBefore = require('better-than-before')()
const preparing = betterThanBefore.preparing

betterThanBefore.setups([
function () {
shell.config.resetForTesting()
shell.cd(__dirname)
shell.rm('-rf', 'tmp')
shell.mkdir('tmp')
shell.cd('tmp')
shell.mkdir('git-templates')
shell.exec('git init --template=./git-templates')

const tmpDir = tmp.dirSync()
process.chdir(tmpDir.name)
gitInit()
fs.writeFileSync('package.json', JSON.stringify({
name: 'conventional-changelog-core',
repository: {
type: 'git',
url: 'https://github.com/conventional-changelog/conventional-changelog.git'
}
}))
gitDummyCommit(['build!: first build setup', 'BREAKING CHANGE: New build system.'])
gitDummyCommit(['ci(travis): add TravisCI pipeline', 'BREAKING CHANGE: Continuously integrated.'])
gitDummyCommit(['Feat: amazing new module', 'BREAKING CHANGE: Not backward compatible.'])
Expand Down Expand Up @@ -54,11 +54,11 @@ betterThanBefore.setups([
gitDummyCommit(['test(*)!: more tests', 'BREAKING CHANGE: The Change is huge.'])
},
function () {
shell.exec('git tag v0.1.0')
exec('git tag v0.1.0')
gitDummyCommit('feat: some more feats')
},
function () {
shell.exec('git tag v0.2.0')
exec('git tag v0.2.0')
gitDummyCommit('feature: some more features')
},
function () {
Expand Down

0 comments on commit bfe3bf1

Please sign in to comment.