Skip to content

Commit

Permalink
test: support node 4
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Dec 7, 2019
1 parent bcfdec3 commit 82a22c1
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 88 deletions.
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"npmupdate": "bin/update.js"
},
"scripts": {
"test": "mocha -r thunk-mocha -r intelli-espower-loader -t 200000 test/*.test.js",
"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",
"test-local": "npm_china=true local=true mocha -r thunk-mocha -r intelli-espower-loader -t 200000 test/*.test.js",
"test": "mocha -r thunk-mocha -t 200000 test/*.test.js",
"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",
"test-local": "npm_china=true local=true mocha -r thunk-mocha -t 200000 test/*.test.js",
"lint": "eslint . --fix",
"ci": "npm run lint && npm run test-cov",
"autod": "autod"
Expand Down Expand Up @@ -61,7 +61,6 @@
"eslint": "3",
"eslint-config-egg": "3",
"http-proxy": "^1.16.2",
"intelli-espower-loader": "1",
"istanbul": "*",
"mm": "^2.2.1",
"mocha": "3",
Expand Down
51 changes: 27 additions & 24 deletions test/bigPackage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,40 @@

const path = require('path');
const rimraf = require('rimraf');
const semver = require('semver');
const npminstall = require('./npminstall');

describe('test/bigPackage.test.js', () => {
function testcase(name) {
describe(name, () => {
const root = path.join(__dirname, 'fixtures', name);
if (semver.satisfies(process.version, '>= 6.0.0')) {
describe('test/bigPackage.test.js', () => {
function testcase(name) {
describe(name, () => {
const root = path.join(__dirname, 'fixtures', name);

function cleanup() {
rimraf.sync(path.join(root, 'node_modules'));
}
function cleanup() {
rimraf.sync(path.join(root, 'node_modules'));
}

beforeEach(cleanup);
afterEach(cleanup);
beforeEach(cleanup);
afterEach(cleanup);

it('should install success', function* () {
yield npminstall({
root,
trace: true,
it('should install success', function* () {
yield npminstall({
root,
trace: true,
});
});
});
});
}
}

if (process.platform !== 'win32') {
[
'spmtest',
'spmwebpacktest',
].forEach(testcase);
}

if (process.platform !== 'win32') {
[
'spmtest',
'spmwebpacktest',
'standardtest',
].forEach(testcase);
}

[
'standardtest',
].forEach(testcase);
});
});
}
53 changes: 28 additions & 25 deletions test/concurrency-install.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,37 @@

const path = require('path');
const rimraf = require('rimraf');
const semver = require('semver');
const npminstall = require('./npminstall');

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

function cleanup() {
rimraf.sync(cacheDir);
rimraf.sync(path.join(root1, 'node_modules'));
rimraf.sync(path.join(root2, 'node_modules'));
}
function cleanup() {
rimraf.sync(cacheDir);
rimraf.sync(path.join(root1, 'node_modules'));
rimraf.sync(path.join(root2, 'node_modules'));
}

beforeEach(cleanup);
afterEach(cleanup);
beforeEach(cleanup);
afterEach(cleanup);

it('should concurrency install success', function* () {
yield [
npminstall({
root: root1,
cacheDir,
detail: true,
}),
npminstall({
root: root2,
cacheDir,
detail: true,
}),
];
it('should concurrency install success', function* () {
yield [
npminstall({
root: root1,
cacheDir,
detail: true,
}),
npminstall({
root: root2,
cacheDir,
detail: true,
}),
];
});
});
});
}
4 changes: 3 additions & 1 deletion test/installScopeRegistry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const helper = require('./helper');
const npminstall = require('./npminstall');

describe('test/installScopeRegistry.test.js', () => {
const [ tmp, cleanup ] = helper.tmp();
const items = helper.tmp();
const tmp = items[0];
const cleanup = items[1];
let mockCnpmrc;

before(() => {
Expand Down
71 changes: 37 additions & 34 deletions test/proxy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,48 @@ const rimraf = require('rimraf');
const mkdirp = require('mkdirp');
const mm = require('mm');
const coffee = require('coffee');
const proxy = require('./fixtures/reverse-proxy');
const semver = require('semver');

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

describe('test/proxy.test.js', () => {
let port;
let proxyUrl;
before(done => {
proxy.listen(0, () => {
port = proxy.address().port;
proxyUrl = 'http://127.0.0.1:' + port;
console.log('proxy: %s', proxyUrl);
done();
describe('test/proxy.test.js', () => {
let port;
let proxyUrl;
before(done => {
proxy.listen(0, () => {
port = proxy.address().port;
proxyUrl = 'http://127.0.0.1:' + port;
console.log('proxy: %s', proxyUrl);
done();
});
});
});
after(() => proxy.close());
after(() => proxy.close());

const tmp = path.join(__dirname, 'fixtures', 'tmp');
const tmp = path.join(__dirname, 'fixtures', 'tmp');

function cleanup() {
rimraf.sync(tmp);
}
function cleanup() {
rimraf.sync(tmp);
}

beforeEach(() => {
cleanup();
mkdirp.sync(tmp);
});
afterEach(cleanup);
afterEach(mm.restore);
beforeEach(() => {
cleanup();
mkdirp.sync(tmp);
});
afterEach(cleanup);
afterEach(mm.restore);

it('should install from proxy', () => {
return coffee.fork(npminstallBin, [
'--proxy', proxyUrl,
'koa', 'pedding',
], {
cwd: tmp,
})
.debug()
.expect('code', 0)
.end();
it('should install from proxy', () => {
return coffee.fork(npminstallBin, [
'--proxy', proxyUrl,
'koa', 'pedding',
], {
cwd: tmp,
})
.debug()
.expect('code', 0)
.end();
});
});
});
}

0 comments on commit 82a22c1

Please sign in to comment.