Skip to content

Commit 984c4c4

Browse files
committed
chore: Troubleshoot windows
1 parent 674bb7c commit 984c4c4

File tree

4 files changed

+81
-69
lines changed

4 files changed

+81
-69
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
language: node_js
22
os:
33
- windows
4-
- linux
5-
- osx
4+
# - linux
5+
# - osx
66
node_js:
77
- "node"
88
- 10

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"lint": "standard",
88
"pretest": "npm run lint && npm run clean && npm run instrument",
9-
"test": "tap",
9+
"test": "tap test/should-instrument.js",
1010
"snap": "npm test -- --snapshot",
1111
"posttest": "npm run report",
1212
"clean": "rimraf ./.nyc_output ./node_modules/.cache ./.self_coverage ./test/fixtures/.nyc_output ./test/fixtures/node_modules/.cache ./test/fixtures/cli/foo-cache ./test/temp-dir-* ./self-coverage",

test/nyc-index.js

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -88,72 +88,6 @@ describe('nyc', function () {
8888
})
8989
})
9090

91-
describe('shouldInstrumentFile', function () {
92-
it('should exclude appropriately with defaults', function () {
93-
var nyc = new NYC(configUtil.buildYargs('/cwd').parse([
94-
'--exclude=test/**',
95-
'--exclude=test{,-*}.js',
96-
'--exclude=**/*.test.js',
97-
'--exclude=**/__tests__/**'
98-
]))
99-
100-
// nyc always excludes "node_modules/**"
101-
nyc.exclude.shouldInstrument('/cwd/foo.js', 'foo.js').should.equal(true)
102-
nyc.exclude.shouldInstrument('/cwd/node_modules/bar.js', 'node_modules/bar.js').should.equal(false)
103-
nyc.exclude.shouldInstrument('/cwd/foo/node_modules/bar.js', 'foo/node_modules/bar.js').should.equal(false)
104-
nyc.exclude.shouldInstrument('/cwd/test.js', 'test.js').should.equal(false)
105-
nyc.exclude.shouldInstrument('/cwd/testfoo.js', 'testfoo.js').should.equal(true)
106-
nyc.exclude.shouldInstrument('/cwd/test-foo.js', 'test-foo.js').should.equal(false)
107-
nyc.exclude.shouldInstrument('/cwd/lib/test.js', 'lib/test.js').should.equal(true)
108-
nyc.exclude.shouldInstrument('/cwd/foo/bar/test.js', './test.js').should.equal(false)
109-
nyc.exclude.shouldInstrument('/cwd/foo/bar/test.js', '.\\test.js').should.equal(false)
110-
nyc.exclude.shouldInstrument('/cwd/foo/bar/foo.test.js', './foo.test.js').should.equal(false)
111-
nyc.exclude.shouldInstrument('/cwd/foo/bar/__tests__/foo.js', './__tests__/foo.js').should.equal(false)
112-
})
113-
114-
it('should exclude appropriately with config.exclude', function () {
115-
var nyc = new NYC(configUtil.buildYargs(fixtures).parse())
116-
117-
// fixtures/package.json configures excludes: "blarg", "blerg"
118-
nyc.exclude.shouldInstrument('blarg.js', 'blarg.js').should.equal(false)
119-
nyc.exclude.shouldInstrument('blarg/foo.js', 'blarg/foo.js').should.equal(false)
120-
nyc.exclude.shouldInstrument('blerg.js', 'blerg.js').should.equal(false)
121-
nyc.exclude.shouldInstrument('./blerg.js', './blerg.js').should.equal(false)
122-
nyc.exclude.shouldInstrument('./blerg.js', '.\\blerg.js').should.equal(false)
123-
})
124-
125-
it('should exclude outside of the current working directory', function () {
126-
var nyc = new NYC(configUtil.buildYargs('/cwd/foo/').parse())
127-
nyc.exclude.shouldInstrument('/cwd/bar.js', '../bar.js').should.equal(false)
128-
})
129-
130-
it('should not exclude if the current working directory is inside node_modules', function () {
131-
var nyc = new NYC(configUtil.buildYargs('/cwd/node_modules/foo/').parse())
132-
nyc.exclude.shouldInstrument('/cwd/node_modules/foo/bar.js', './bar.js').should.equal(true)
133-
nyc.exclude.shouldInstrument('/cwd/node_modules/foo/bar.js', '.\\bar.js').should.equal(true)
134-
})
135-
136-
it('allows files to be explicitly included, rather than excluded', function () {
137-
var nyc = new NYC(configUtil.buildYargs('/cwd/').parse(['--include=foo.js']))
138-
139-
nyc.exclude.shouldInstrument('/cwd/foo.js', 'foo.js').should.equal(true)
140-
nyc.exclude.shouldInstrument('/cwd/index.js', 'index.js').should.equal(false)
141-
})
142-
143-
it('exclude overrides include', function () {
144-
var nyc = new NYC(configUtil.buildYargs('/cwd/').parse([
145-
'--include=foo.js',
146-
'--include=test.js',
147-
'--exclude=**/node_modules/**',
148-
'--exclude=test/**',
149-
'--exclude=test{,-*}.js'
150-
]))
151-
152-
nyc.exclude.shouldInstrument('/cwd/foo.js', 'foo.js').should.equal(true)
153-
nyc.exclude.shouldInstrument('/cwd/test.js', 'test.js').should.equal(false)
154-
})
155-
})
156-
15791
describe('wrap', function () {
15892
it('wraps modules with coverage counters when they are required', function () {
15993
var nyc = new NYC(configUtil.buildYargs().parse())

test/should-instrument.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
const path = require('path')
2+
const NYC = require('../self-coverage')
3+
const configUtil = require('../self-coverage/lib/config-util')
4+
const fixtures = path.resolve(__dirname, './fixtures')
5+
6+
const t = require('tap')
7+
8+
const rootDir = path.resolve('/')
9+
t.test('should exclude appropriately with defaults', t => {
10+
const nyc = new NYC(configUtil.buildYargs(rootDir).parse([
11+
'--exclude=test/**',
12+
'--exclude=test{,-*}.js',
13+
'--exclude=**/*.test.js',
14+
'--exclude=**/__tests__/**'
15+
]))
16+
17+
// nyc always excludes "node_modules/**"
18+
t.true(nyc.exclude.shouldInstrument(path.join(rootDir, 'foo.js'), 'foo.js'))
19+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'node_modules/bar.js'), 'node_modules/bar.js'))
20+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'foo/node_modules/bar.js'), 'foo/node_modules/bar.js'))
21+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'test.js'), 'test.js'))
22+
t.true(nyc.exclude.shouldInstrument(path.join(rootDir, 'testfoo.js'), 'testfoo.js'))
23+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'test-foo.js'), 'test-foo.js'))
24+
t.true(nyc.exclude.shouldInstrument(path.join(rootDir, 'lib/test.js'), 'lib/test.js'))
25+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'foo/bar/test.js'), './test.js'))
26+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'foo/bar/test.js'), '.\\test.js'))
27+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'foo/bar/foo.test.js'), './foo.test.js'))
28+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'foo/bar/__tests__/foo.js'), './__tests__/foo.js'))
29+
t.done()
30+
})
31+
32+
t.test('should exclude appropriately with config.exclude', t => {
33+
const nyc = new NYC(configUtil.buildYargs(fixtures).parse())
34+
35+
// fixtures/package.json configures excludes: "blarg", "blerg"
36+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'blarg.js'), 'blarg.js'))
37+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'blarg/foo.js'), 'blarg/foo.js'))
38+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'blerg.js'), 'blerg.js'))
39+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'blerg.js'), './blerg.js'))
40+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'blerg.js'), '.\\blerg.js'))
41+
t.done()
42+
})
43+
44+
t.test('should exclude outside of the current working directory', t => {
45+
const nyc = new NYC(configUtil.buildYargs(path.join(rootDir, 'foo')).parse())
46+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'bar.js'), '../bar.js'))
47+
t.done()
48+
})
49+
50+
t.test('should not exclude if the current working directory is inside node_modules', t => {
51+
const cwd = path.join(rootDir, 'node_modules', 'foo')
52+
const nyc = new NYC(configUtil.buildYargs(cwd).parse())
53+
t.true(nyc.exclude.shouldInstrument(path.join(cwd, 'bar.js'), './bar.js'))
54+
t.true(nyc.exclude.shouldInstrument(path.join(cwd, 'bar.js'), '.\\bar.js'))
55+
t.done()
56+
})
57+
58+
t.test('allows files to be explicitly included, rather than excluded', t => {
59+
const nyc = new NYC(configUtil.buildYargs(rootDir).parse(['--include=foo.js']))
60+
61+
t.true(nyc.exclude.shouldInstrument(path.join(rootDir, 'foo.js'), 'foo.js'))
62+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'index.js'), 'index.js'))
63+
t.done()
64+
})
65+
66+
t.test('exclude overrides include', t => {
67+
const nyc = new NYC(configUtil.buildYargs(rootDir).parse([
68+
'--include=foo.js',
69+
'--include=test.js',
70+
'--exclude=**/node_modules/**',
71+
'--exclude=test/**',
72+
'--exclude=test{,-*}.js'
73+
]))
74+
75+
t.true(nyc.exclude.shouldInstrument(path.join(rootDir, 'foo.js'), 'foo.js'))
76+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'test.js'), 'test.js'))
77+
t.done()
78+
})

0 commit comments

Comments
 (0)