Skip to content

Commit

Permalink
fix(test): use exec for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
watilde committed Sep 17, 2017
1 parent 958ea3e commit 5f75b3e
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions test/10-install.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require('fs')
const path = require('path')
const execFile = require('child_process').execFile
const exec = require('child_process').exec
const tree = require('strong-npm-ls')
const test = require('tap').test
const skip = [
Expand All @@ -21,7 +21,7 @@ test((t) => {
fixtures.forEach(fixture => {
const pkg = path.join(__dirname, 'deps', fixture)
const pkgJSON = require(path.join(pkg, 'package.json'))
execFile(bin, ['install'], {cwd: pkg}, (err, stdout, stderr) => {
exec(`node ${bin} install`, {cwd: pkg}, (err, stdout, stderr) => {
t.ifError(err, `${pkgJSON.name}: install ran without error`)
tree.read(pkg, (err, out) => {
t.ifError(err, `${pkgJSON.name}: tree could be read`)
Expand Down
4 changes: 2 additions & 2 deletions test/11-install-deprecated.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const path = require('path')
const execFile = require('child_process').execFile
const exec = require('child_process').exec
const tree = require('strong-npm-ls')
const test = require('tap').test
const bin = path.join(__dirname, '..', 'bin', 'dep.js')
const pkg = path.join(__dirname, 'deps/install-deprecated')
const pkgJSON = require(path.join(pkg, 'package.json'))

test((t) => {
execFile(bin, ['install'], {cwd: pkg}, (err, stdout, stderr) => {
exec(`node ${bin} install`, {cwd: pkg}, (err, stdout, stderr) => {
t.ifError(err, `${pkgJSON.name}: install ran without error`)
t.has(stdout, 'minimatch@0.0.1')
tree.read(pkg, (err, out) => {
Expand Down
6 changes: 3 additions & 3 deletions test/11-install-only.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const path = require('path')
const execFile = require('child_process').execFile
const exec = require('child_process').exec
const tree = require('strong-npm-ls')
const test = require('tap').test
const bin = path.join(__dirname, '..', 'bin', 'dep.js')
const pkg = path.join(__dirname, 'deps/install-only')
const pkgJSON = require(path.join(pkg, 'package.json'))

test((t) => {
execFile(bin, ['install', '--only=prod'], {cwd: pkg}, (err, stdout, stderr) => {
exec(`node ${bin} install --only=prod`, {cwd: pkg}, (err, stdout, stderr) => {
t.ifError(err, `${pkgJSON.name}: install ran without error`)
tree.read(pkg, (err, out) => {
t.ifError(err, `${pkgJSON.name}: tree could be read`)
Expand All @@ -19,7 +19,7 @@ test((t) => {
})

test((t) => {
execFile(bin, ['install', '--only=dev'], {cwd: pkg}, (err, stdout, stderr) => {
exec(`node ${bin} install --only=dev`, {cwd: pkg}, (err, stdout, stderr) => {
t.ifError(err, `${pkgJSON.name}: install ran without error`)
tree.read(pkg, (err, out) => {
t.ifError(err, `${pkgJSON.name}: tree could be read`)
Expand Down
6 changes: 3 additions & 3 deletions test/11-install-save.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require('fs')
const path = require('path')
const execFile = require('child_process').execFile
const exec = require('child_process').exec
const tree = require('strong-npm-ls')
const test = require('tap').test
const bin = path.join(__dirname, '..', 'bin', 'dep.js')
Expand All @@ -9,7 +9,7 @@ const pkgJSON = require(path.join(pkg, 'package.json'))

test((t) => {
const file = 'happy-birthday@' + path.join(__dirname, 'deps/file/happy-birthday-0.6.0')
execFile(bin, ['install', '--save=prod', file], {cwd: pkg}, (err, stdout, stderr) => {
exec(`node ${bin} install --save=prod ${file}`, {cwd: pkg}, (err, stdout, stderr) => {
t.ifError(err, `${pkgJSON.name}: install ran without error`)
tree.read(pkg, (err, out) => {
t.ifError(err, `${pkgJSON.name}: tree could be read`)
Expand All @@ -21,7 +21,7 @@ test((t) => {
})

test((t) => {
execFile(bin, ['install', '--save=dev', 'text-table'], {cwd: pkg}, (err, stdout, stderr) => {
exec(`node ${bin} install --save=dev text-table`, {cwd: pkg}, (err, stdout, stderr) => {
t.ifError(err, `${pkgJSON.name}: install ran without error`)
tree.read(pkg, (err, out) => {
t.ifError(err, `${pkgJSON.name}: tree could be read`)
Expand Down
4 changes: 2 additions & 2 deletions test/12-install-dat.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require('fs-extra')
const path = require('path')
const execFile = require('child_process').execFile
const exec = require('child_process').exec
const tree = require('strong-npm-ls')
const test = require('tap').test
const Dat = require('dat-node')
Expand All @@ -14,7 +14,7 @@ test((t) => {
dat.importFiles()
dat.joinNetwork()
const datLink = 'dat://' + dat.key.toString('hex')
execFile(bin, ['install', `happy-birthday@${datLink}`], {cwd: pkg}, (err, stdout, stderr) => {
exec(`node ${bin} install happy-birthday@${datLink}`, {cwd: pkg}, (err, stdout, stderr) => {
t.ifError(err, `${pkgJSON.name}: install ran without error`)
dat.close((err) => {
dat.leaveNetwork()
Expand Down
4 changes: 2 additions & 2 deletions test/20-lock.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require('fs')
const path = require('path')
const execFile = require('child_process').execFile
const exec = require('child_process').exec
const test = require('tap').test
const fixtures = fs.readdirSync(path.join(__dirname, 'deps'))
const bin = path.join(__dirname, '..', 'bin', 'dep.js')
Expand All @@ -12,7 +12,7 @@ test((t) => {
fixtures.forEach(fixture => {
const pkg = path.join(__dirname, 'deps', fixture)
const pkgJSON = require(path.join(pkg, 'package.json'))
execFile(bin, ['lock'], {cwd: pkg}, (err, stdout, stderr) => {
exec(`node ${bin} lock`, {cwd: pkg}, (err, stdout, stderr) => {
t.ifError(err, `${pkgJSON.name}: lock ran without error`)
const lock = require(path.join(pkg, 'node_modules.json'))
const deps = lock.dependencies
Expand Down
6 changes: 3 additions & 3 deletions test/30-run.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
const path = require('path')
const execFile = require('child_process').execFile
const exec = require('child_process').exec
const test = require('tap').test
const pkg = path.join(__dirname, 'deps', 'run')
const bin = path.join(__dirname, '..', 'bin', 'dep.js')

test((t) => {
execFile(bin, ['run'], {cwd: pkg}, (err, stdout, stderr) => {
exec(`node ${bin} run`, {cwd: pkg}, (err, stdout, stderr) => {
t.ifError(err, 'run without error')
t.end()
})
})

test((t) => {
execFile(bin, ['run', 'test'], {cwd: pkg}, (err, stdout, stderr) => {
exec(`node ${bin} run test`, {cwd: pkg}, (err, stdout, stderr) => {
t.ifError(err, 'run test without error')
t.end()
})
Expand Down
6 changes: 3 additions & 3 deletions test/90-help.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
const path = require('path')
const execFile = require('child_process').execFile
const exec = require('child_process').exec
const test = require('tap').test
const bin = path.join(__dirname, '..', 'bin', 'dep.js')

test((t) => {
execFile(bin, ['-h'], (err, stdout, stderr) => {
exec(`node ${bin} -h`, (err, stdout, stderr) => {
t.ifError(err, 'help ran without error')
t.ok(stdout, 'help displayed a message')
t.end()
})
})

test((t) => {
execFile(bin, (err, stdout, stderr) => {
exec(`node ${bin}`, (err, stdout, stderr) => {
t.ifError(err, 'help ran without error')
t.ok(stderr, 'help displayed a message')
t.end()
Expand Down
4 changes: 2 additions & 2 deletions test/90-version.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const path = require('path')
const execFile = require('child_process').execFile
const exec = require('child_process').exec
const test = require('tap').test
const bin = path.join(__dirname, '..', 'bin', 'dep.js')

test((t) => {
execFile(bin, ['-v'], (err, stdout, stderr) => {
exec(`node ${bin} -v`, (err, stdout, stderr) => {
t.ifError(err, 'version ran without error')
t.ok(stdout, 'version displayed a message')
t.end()
Expand Down

0 comments on commit 5f75b3e

Please sign in to comment.