Skip to content

Commit 5c11479

Browse files
authoredDec 17, 2018
Merge pull request #898 from secretcowlevel/master
Switch back to Hoek.clone from lodash.deepClone.
2 parents 47e8181 + a9c6b7a commit 5c11479

9 files changed

+64
-22
lines changed
 

‎.gitattributes

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* text=auto eol=lf
2+
*.new text eol=lf
3+
*.inl text eol=lf
4+
*.js text eol=lf

‎.travis.yml

+5
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,9 @@ node_js:
66
- "11"
77
- "node"
88

9+
os:
10+
- linux
11+
- osx
12+
- windows
13+
914
sudo: false

‎lib/reporters/console.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ internals.color = function (name, code, enabled) {
431431
internals.colors = function (enabled) {
432432

433433
if (enabled === null) {
434-
enabled = require('supports-color');
434+
enabled = require('supports-color').stdout;
435435
}
436436

437437
const codes = {

‎lib/reporters/multiple.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Load modules
44

5-
const { cloneDeep } = require('lodash');
5+
const Hoek = require('hoek');
66
const Reporters = require('./index');
77

88

@@ -17,7 +17,7 @@ exports = module.exports = internals.Reporter = function (options) {
1717

1818
options.reporter.forEach((reporter, index) => {
1919

20-
const reporterOptions = cloneDeep(options);
20+
const reporterOptions = Hoek.clone(options);
2121
reporterOptions.reporter = reporter;
2222

2323
if (options.output[index] === 'stdout') {

‎lib/runner.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// Load modules
44

55
const Hoek = require('hoek');
6-
const { cloneDeep } = require('lodash');
76
const Seedrandom = require('seedrandom');
87
const WillCall = require('will-call');
98
const Reporters = require('./reporters');
@@ -264,7 +263,7 @@ internals.executeExperiments = async function (experiments, state, skip, parentC
264263
for (const experiment of experiments) {
265264
const skipExperiment = skip || experiment.options.skip || !internals.experimentHasTests(experiment, state) || (state.options.bail && state.report.failures);
266265

267-
state.currentContext = parentContext ? cloneDeep(parentContext) : {};
266+
state.currentContext = parentContext ? Hoek.clone(parentContext) : {};
268267

269268
// Before
270269

@@ -372,7 +371,7 @@ internals.executeTests = async function (experiment, state, skip) {
372371

373372
const start = Date.now();
374373
try {
375-
test.context = cloneDeep(state.currentContext);
374+
test.context = Hoek.clone(state.currentContext);
376375
await internals.protect(test, state);
377376
}
378377
catch (ex) {

‎package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,39 @@
1010
"dependencies": {
1111
"bossy": "4.x.x",
1212
"diff": "3.5.x",
13-
"eslint": "5.9.x",
13+
"eslint": "5.10.x",
1414
"eslint-config-hapi": "12.x.x",
1515
"eslint-plugin-hapi": "4.x.x",
16-
"espree": "4.1.x",
16+
"espree": "5.0.x",
1717
"find-rc": "3.0.x",
1818
"handlebars": "4.x.x",
19-
"hoek": "6.x.x",
19+
"hoek": "6.1.x",
2020
"json-stable-stringify": "1.x.x",
2121
"json-stringify-safe": "5.x.x",
22-
"lodash": "^4.17.x",
2322
"mkdirp": "0.5.x",
2423
"seedrandom": "2.4.x",
2524
"source-map": "0.7.x",
2625
"source-map-support": "0.5.x",
27-
"supports-color": "4.4.x",
26+
"supports-color": "5.5.x",
2827
"will-call": "1.x.x"
2928
},
3029
"devDependencies": {
3130
"code": "5.x.x",
3231
"cpr": "3.0.x",
3332
"eslint-plugin-markdown": "1.0.0-rc.0",
3433
"lab-event-reporter": "1.x.x",
35-
"rimraf": "2.6.x"
34+
"rimraf": "2.6.x",
35+
"semver": "5.6.x"
3636
},
3737
"bin": {
3838
"lab": "./bin/lab"
3939
},
4040
"scripts": {
41-
"test": "node ./bin/_lab -fL -t 100 -m 3000",
41+
"test": "node ./bin/_lab -fL -t 100 -m 10000",
4242
"posttest": "npm run lint-md",
43-
"test-cov-html": "node ./bin/_lab -fL -r html -m 3000 -o coverage.html",
43+
"test-cov-html": "node ./bin/_lab -fL -r html -m 10000 -o coverage.html",
4444
"lint": "node ./bin/_lab -d -f -L",
45-
"lint-md": "eslint --config hapi --rule 'strict: 0, eol-last: 0' --plugin markdown --ext md --parser-options 'ecmaVersion: 9' ."
45+
"lint-md": "eslint --config hapi --rule \"strict: 0, eol-last: 0\" --plugin markdown --ext md --parser-options \"ecmaVersion: 9\" ."
4646
},
4747
"license": "BSD-3-Clause"
4848
}

‎test/leaks.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Load modules
44

55
const Code = require('code');
6+
const Semver = require('semver');
67
const _Lab = require('../test_runner');
78
const Lab = require('../');
89

@@ -100,7 +101,7 @@ describe('Leaks', () => {
100101
expect(leaks.length).to.equal(0);
101102
});
102103

103-
it('ignores Counter globals', () => {
104+
it('ignores Counter globals', { skip: process.platform === 'win32' && Semver.gte(process.version, '11.0.0') }, () => {
104105

105106
const counterGlobals = internals.counterGlobals;
106107
testedKeys = internals.counterGlobals;

‎test/linters.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ describe('Linters - eslint', () => {
154154
Fs.writeFileSync = (path, output) => {
155155

156156
expect(path).to.endWith(Path.join('test', 'lint', 'eslint', 'fix', 'success.js'));
157-
expect(output).to.endWith('\n return value;\n};\n');
157+
expect(output).to.match(/\r?\n return value;\r?\n\};\r?\n/);
158158
isFixed = true;
159159
};
160160

‎test/reporters.js

+38-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const Crypto = require('crypto');
66
const Fs = require('fs');
77
const Os = require('os');
88
const Path = require('path');
9+
const Rimraf = require('rimraf');
910
const Stream = require('stream');
1011
const Code = require('code');
1112
const _Lab = require('../test_runner');
@@ -101,8 +102,7 @@ describe('Reporter', () => {
101102

102103
expect(code).to.equal(0);
103104
expect(output).to.equal(Fs.readFileSync(filename).toString());
104-
Fs.unlinkSync(filename);
105-
Fs.rmdirSync(folder);
105+
Rimraf.sync(folder);
106106
});
107107

108108
it('outputs to a file with output is passed as an array and reporter is an array', async () => {
@@ -683,7 +683,7 @@ describe('Reporter', () => {
683683
});
684684

685685
const { output } = await Lab.report(script, { reporter: 'console', progress: 0, output: false, assert: false });
686-
expect(output).to.match(/^\u001b\[32m1 tests complete\u001b\[0m\nTest duration: \d+ ms\n\u001b\[32mNo global variable leaks detected\u001b\[0m\n\n$/);
686+
expect(output).to.match(/^(\u001b\[32m)?1 tests complete(\u001b\[0m)?\nTest duration: \d+ ms\n(\u001b\[32m)?No global variable leaks detected(\u001b\[0m)?\n\n$/);
687687
});
688688

689689
it('generates a report with verbose progress', async () => {
@@ -695,7 +695,7 @@ describe('Reporter', () => {
695695
});
696696

697697
const { output } = await Lab.report(script, { reporter: 'console', progress: 2, output: false, assert: false });
698-
expect(output).to.match(/^test\n \u001b\[32m[]\u001b\[0m \u001b\[90m1\) works \(\d+ ms\)\u001b\[0m\n\n\n\u001b\[32m1 tests complete\u001b\[0m\nTest duration: \d+ ms\n\u001b\[32mNo global variable leaks detected\u001b\[0m\n\n$/);
698+
expect(output).to.match(/^test\n (\u001b\[32m)?[](\u001b\[0m)? (\u001b\[90m)?1\) works \(\d+ ms\)(\u001b\[0m)?\n\n\n(\u001b\[32m)?1 tests complete(\u001b\[0m)?\nTest duration: \d+ ms\n(\u001b\[32m)?No global variable leaks detected(\u001b\[0m)?\n\n$/);
699699
});
700700

701701
it('generates a report with verbose progress with experiments with same named tests', async () => {
@@ -763,7 +763,7 @@ describe('Reporter', () => {
763763
});
764764

765765
const { output } = await Lab.report(script, { reporter: 'console', progress: 2, assert: Code, output: false });
766-
expect(output).to.match(/^test\n \u001b\[32m[]\u001b\[0m \u001b\[90m1\) works \(\d+ ms and \d+ assertions\)\u001b\[0m\n\n\n\u001b\[32m1 tests complete\u001b\[0m\nTest duration: \d+ ms\nAssertions count\: \d+ \(verbosity\: \d+\.\d+\)\n\u001b\[32mNo global variable leaks detected\u001b\[0m\n\n$/);
766+
expect(output).to.match(/^test\n (\u001b\[32m)?[](\u001b\[0m)? (\u001b\[90m)?1\) works \(\d+ ms and \d+ assertions\)(\u001b\[0m)?\n\n\n(\u001b\[32m)?1 tests complete(\u001b\[0m)?\nTest duration: \d+ ms\nAssertions count\: \d+ \(verbosity\: \d+\.\d+\)\n(\u001b\[32m)?No global variable leaks detected(\u001b\[0m)?\n\n$/);
767767
});
768768

769769
it('generates a report with verbose progress that displays well on windows', async () => {
@@ -999,6 +999,39 @@ describe('Reporter', () => {
999999
expect(output).to.match(/^\n \n \.\n\n1 tests complete\nTest duration: \d+ ms\nNo global variable leaks detected\n\n$/);
10001000
});
10011001

1002+
it('includes colors when terminal supports', async () => {
1003+
1004+
delete require.cache[require.resolve('supports-color')];
1005+
const orig = {
1006+
isTTY: process.stdout.isTTY,
1007+
env: process.env
1008+
};
1009+
process.stdout.isTTY = true;
1010+
process.env = {
1011+
FORCE_COLOR: true
1012+
};
1013+
1014+
const script = Lab.script();
1015+
script.experiment('test', () => {
1016+
1017+
script.test('works', () => {
1018+
1019+
expect(true).to.equal(true);
1020+
});
1021+
script.test('does not work', () => {
1022+
1023+
expect(true).to.equal(false);
1024+
});
1025+
});
1026+
1027+
const { code, output } = await Lab.report(script, { reporter: 'console', output: false, assert: false });
1028+
1029+
process.stdout.isTTY = orig.isTTY;
1030+
process.env = orig.env;
1031+
expect(code).to.equal(1);
1032+
expect(output).to.match(/^\n \n \.\u001b\[31mx\u001b\[0m\n\nFailed tests:\n\n 2\) test does not work:\n\n \u001b\[37;41mactual\u001b\[0m \u001b\[30;42mexpected\u001b\[0m\n\n \u001b\[37;41mtrue\u001b\[0m\u001b\[30;42mfalse\u001b\[0m\n\n \u001b\[33mExpected true to equal specified value: false\u001b\[0m\n\n.*?\u001b\[0m\n\n\n\u001b\[31m1 of 2 tests failed\u001b\[0m\nTest duration: \d+ ms\n\u001b\[32mNo global variable leaks detected\u001b\[0m\n\n$/);
1033+
});
1034+
10021035
it('displays custom error messages in expect', async () => {
10031036

10041037
const script = Lab.script();

0 commit comments

Comments
 (0)
Please sign in to comment.