-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
3 changed files
with
53 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | ||
|
@@ -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' | ||
) | ||
}) | ||
}) | ||
}) | ||
|