Skip to content

Commit 82a22c1

Browse files
committed
test: support node 4
1 parent bcfdec3 commit 82a22c1

5 files changed

+98
-88
lines changed

package.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
"npmupdate": "bin/update.js"
1616
},
1717
"scripts": {
18-
"test": "mocha -r thunk-mocha -r intelli-espower-loader -t 200000 test/*.test.js",
19-
"test-cov": "istanbul cover --report none --print none node_modules/mocha/bin/_mocha -- -r thunk-mocha -r intelli-espower-loader -t 200000 test/*.test.js && istanbul report text-summary json lcov",
20-
"test-local": "npm_china=true local=true mocha -r thunk-mocha -r intelli-espower-loader -t 200000 test/*.test.js",
18+
"test": "mocha -r thunk-mocha -t 200000 test/*.test.js",
19+
"test-cov": "istanbul cover --report none --print none node_modules/mocha/bin/_mocha -- -r thunk-mocha -t 200000 test/*.test.js && istanbul report text-summary json lcov",
20+
"test-local": "npm_china=true local=true mocha -r thunk-mocha -t 200000 test/*.test.js",
2121
"lint": "eslint . --fix",
2222
"ci": "npm run lint && npm run test-cov",
2323
"autod": "autod"
@@ -61,7 +61,6 @@
6161
"eslint": "3",
6262
"eslint-config-egg": "3",
6363
"http-proxy": "^1.16.2",
64-
"intelli-espower-loader": "1",
6564
"istanbul": "*",
6665
"mm": "^2.2.1",
6766
"mocha": "3",

test/bigPackage.test.js

+27-24
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,40 @@
22

33
const path = require('path');
44
const rimraf = require('rimraf');
5+
const semver = require('semver');
56
const npminstall = require('./npminstall');
67

7-
describe('test/bigPackage.test.js', () => {
8-
function testcase(name) {
9-
describe(name, () => {
10-
const root = path.join(__dirname, 'fixtures', name);
8+
if (semver.satisfies(process.version, '>= 6.0.0')) {
9+
describe('test/bigPackage.test.js', () => {
10+
function testcase(name) {
11+
describe(name, () => {
12+
const root = path.join(__dirname, 'fixtures', name);
1113

12-
function cleanup() {
13-
rimraf.sync(path.join(root, 'node_modules'));
14-
}
14+
function cleanup() {
15+
rimraf.sync(path.join(root, 'node_modules'));
16+
}
1517

16-
beforeEach(cleanup);
17-
afterEach(cleanup);
18+
beforeEach(cleanup);
19+
afterEach(cleanup);
1820

19-
it('should install success', function* () {
20-
yield npminstall({
21-
root,
22-
trace: true,
21+
it('should install success', function* () {
22+
yield npminstall({
23+
root,
24+
trace: true,
25+
});
2326
});
2427
});
25-
});
26-
}
28+
}
29+
30+
if (process.platform !== 'win32') {
31+
[
32+
'spmtest',
33+
'spmwebpacktest',
34+
].forEach(testcase);
35+
}
2736

28-
if (process.platform !== 'win32') {
2937
[
30-
'spmtest',
31-
'spmwebpacktest',
38+
'standardtest',
3239
].forEach(testcase);
33-
}
34-
35-
[
36-
'standardtest',
37-
].forEach(testcase);
38-
});
40+
});
41+
}

test/concurrency-install.test.js

+28-25
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,37 @@
22

33
const path = require('path');
44
const rimraf = require('rimraf');
5+
const semver = require('semver');
56
const npminstall = require('./npminstall');
67

7-
describe('test/concurrency-install.test.js', () => {
8-
const root1 = path.join(__dirname, 'fixtures', 'concurrency1');
9-
const root2 = path.join(__dirname, 'fixtures', 'concurrency2');
10-
const cacheDir = path.join(__dirname, 'fixtures', '.tmp');
8+
if (semver.satisfies(process.version, '>= 6.0.0')) {
9+
describe('test/concurrency-install.test.js', () => {
10+
const root1 = path.join(__dirname, 'fixtures', 'concurrency1');
11+
const root2 = path.join(__dirname, 'fixtures', 'concurrency2');
12+
const cacheDir = path.join(__dirname, 'fixtures', '.tmp');
1113

12-
function cleanup() {
13-
rimraf.sync(cacheDir);
14-
rimraf.sync(path.join(root1, 'node_modules'));
15-
rimraf.sync(path.join(root2, 'node_modules'));
16-
}
14+
function cleanup() {
15+
rimraf.sync(cacheDir);
16+
rimraf.sync(path.join(root1, 'node_modules'));
17+
rimraf.sync(path.join(root2, 'node_modules'));
18+
}
1719

18-
beforeEach(cleanup);
19-
afterEach(cleanup);
20+
beforeEach(cleanup);
21+
afterEach(cleanup);
2022

21-
it('should concurrency install success', function* () {
22-
yield [
23-
npminstall({
24-
root: root1,
25-
cacheDir,
26-
detail: true,
27-
}),
28-
npminstall({
29-
root: root2,
30-
cacheDir,
31-
detail: true,
32-
}),
33-
];
23+
it('should concurrency install success', function* () {
24+
yield [
25+
npminstall({
26+
root: root1,
27+
cacheDir,
28+
detail: true,
29+
}),
30+
npminstall({
31+
root: root2,
32+
cacheDir,
33+
detail: true,
34+
}),
35+
];
36+
});
3437
});
35-
});
38+
}

test/installScopeRegistry.test.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ const helper = require('./helper');
88
const npminstall = require('./npminstall');
99

1010
describe('test/installScopeRegistry.test.js', () => {
11-
const [ tmp, cleanup ] = helper.tmp();
11+
const items = helper.tmp();
12+
const tmp = items[0];
13+
const cleanup = items[1];
1214
let mockCnpmrc;
1315

1416
before(() => {

test/proxy.test.js

+37-34
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,48 @@ const rimraf = require('rimraf');
55
const mkdirp = require('mkdirp');
66
const mm = require('mm');
77
const coffee = require('coffee');
8-
const proxy = require('./fixtures/reverse-proxy');
8+
const semver = require('semver');
99

10-
const npminstallBin = path.join(__dirname, '../bin/install.js');
10+
if (semver.satisfies(process.version, '>= 6.0.0')) {
11+
const proxy = require('./fixtures/reverse-proxy');
12+
const npminstallBin = path.join(__dirname, '../bin/install.js');
1113

12-
describe('test/proxy.test.js', () => {
13-
let port;
14-
let proxyUrl;
15-
before(done => {
16-
proxy.listen(0, () => {
17-
port = proxy.address().port;
18-
proxyUrl = 'http://127.0.0.1:' + port;
19-
console.log('proxy: %s', proxyUrl);
20-
done();
14+
describe('test/proxy.test.js', () => {
15+
let port;
16+
let proxyUrl;
17+
before(done => {
18+
proxy.listen(0, () => {
19+
port = proxy.address().port;
20+
proxyUrl = 'http://127.0.0.1:' + port;
21+
console.log('proxy: %s', proxyUrl);
22+
done();
23+
});
2124
});
22-
});
23-
after(() => proxy.close());
25+
after(() => proxy.close());
2426

25-
const tmp = path.join(__dirname, 'fixtures', 'tmp');
27+
const tmp = path.join(__dirname, 'fixtures', 'tmp');
2628

27-
function cleanup() {
28-
rimraf.sync(tmp);
29-
}
29+
function cleanup() {
30+
rimraf.sync(tmp);
31+
}
3032

31-
beforeEach(() => {
32-
cleanup();
33-
mkdirp.sync(tmp);
34-
});
35-
afterEach(cleanup);
36-
afterEach(mm.restore);
33+
beforeEach(() => {
34+
cleanup();
35+
mkdirp.sync(tmp);
36+
});
37+
afterEach(cleanup);
38+
afterEach(mm.restore);
3739

38-
it('should install from proxy', () => {
39-
return coffee.fork(npminstallBin, [
40-
'--proxy', proxyUrl,
41-
'koa', 'pedding',
42-
], {
43-
cwd: tmp,
44-
})
45-
.debug()
46-
.expect('code', 0)
47-
.end();
40+
it('should install from proxy', () => {
41+
return coffee.fork(npminstallBin, [
42+
'--proxy', proxyUrl,
43+
'koa', 'pedding',
44+
], {
45+
cwd: tmp,
46+
})
47+
.debug()
48+
.expect('code', 0)
49+
.end();
50+
});
4851
});
49-
});
52+
}

0 commit comments

Comments
 (0)