Skip to content

Commit

Permalink
test: there are a few valid trees
Browse files Browse the repository at this point in the history
Unfortunately small changes to the installer can result in different
trees with git dependencies -- all are valid, but some are lossier than
others. Handle all three valid alternatives in the test so it's not so
sensitive to raciness, and also not coupled too tightly to the
implementation.
  • Loading branch information
othiym23 committed May 1, 2015
1 parent 63b79cc commit d975aa0
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ npm-debug.log
/node_modules/marked
/node_modules/require-inject
/node_modules/sprintf-js
/node_modules/deep-equal
/html/api/
/html/partial/
/html/doc/
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
"write-file-atomic"
],
"devDependencies": {
"deep-equal": "~1.0.0",
"marked": "~0.3.3",
"marked-man": "~0.1.4",
"nock": "~1.6.0",
Expand Down
67 changes: 51 additions & 16 deletions test/tap/git-races.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
var execFile = require('child_process').execFile
var path = require('path')
var zlib = require('zlib')
var execFile = require('child_process').execFile

var asyncMap = require('slide').asyncMap
var deepEqual = require('deep-equal')
var fs = require('graceful-fs')
var test = require('tap').test
var tmpdir = require('osenv').tmpdir
var mkdirp = require('mkdirp')
var once = require('once')
var requireInject = require('require-inject')
var rimraf = require('rimraf')
var tar = require('tar')
var once = require('once')
var test = require('tap').test
var tmpdir = require('osenv').tmpdir
var which = require('which')
var requireInject = require('require-inject')
var asyncMap = require('slide').asyncMap

var wd = path.resolve(tmpdir(), 'git-races')
var fixtures = path.resolve(__dirname, '../fixtures')
Expand Down Expand Up @@ -160,23 +161,57 @@ test('setup', function (t) {
})
})

// there are three valid trees that can result, and
// we don't care which one we get
var oneTree = [
'[email protected]', [
['[email protected]', [
['[email protected]', []]
]],
['[email protected]', []],
['[email protected]', [
['[email protected]', []]
]]
]
]
var otherTree = [
'[email protected]', [
['[email protected]', [
['[email protected]', []],
['[email protected]', []]
]],
['[email protected]', []],
['[email protected]', [
['[email protected]', []]
]]
]
]
var grippingTree = [
'[email protected]', [
['[email protected]', [
['[email protected]', []],
['[email protected]', []]
]],
['[email protected]', [
['[email protected]', []]
]]
]
]

test('correct versions are installed for git dependency', function (t) {
t.plan(4)
t.comment('test for https://github.com/npm/npm/issues/7202')
npm.commands.install([], function (er) {
t.ifError(er, 'installed OK')
npm.commands.ls([], true, function (er, result) {
t.ifError(er, 'ls OK')
t.deepEqual(toSimple(result), [
'[email protected]', [
['[email protected]', [
['[email protected]', []]
]],
['[email protected]', []],
['[email protected]', [
['[email protected]', []]
]]
]], 'install tree is correct')
var simplified = toSimple(result)
t.ok(
deepEqual(simplified, oneTree) ||
deepEqual(simplified, otherTree) ||
deepEqual(simplified, grippingTree),
'install tree is correct'
)
})
})
})
Expand Down

0 comments on commit d975aa0

Please sign in to comment.