-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] win32 mismatch of path casings causes duplicate entries
- Loading branch information
Showing
6 changed files
with
197 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* A unique set of paths. Case insensitive on win32 | ||
*/ | ||
class PathSet extends Set { | ||
constructor () { | ||
super() | ||
this._win32 = process.platform === 'win32' | ||
} | ||
|
||
add (value) { | ||
if (this._win32) { | ||
value = value.toLowerCase() | ||
} | ||
super.add(value) | ||
} | ||
|
||
has (value) { | ||
if (this._win32) { | ||
value = value.toLowerCase() | ||
} | ||
return super.has(value) | ||
} | ||
} | ||
|
||
module.exports = PathSet |
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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{ | ||
"result": [ | ||
{ | ||
"scriptId": "51", | ||
"url": "file:///TEST_CWD/test/fixtures/all/vanilla/MAIN.js", | ||
"functions": [ | ||
{ | ||
"functionName": "", | ||
"ranges": [ | ||
{ | ||
"startOffset": 0, | ||
"endOffset": 111, | ||
"count": 1 | ||
} | ||
], | ||
"isBlockCoverage": true | ||
} | ||
] | ||
}, | ||
{ | ||
"scriptId": "52", | ||
"url": "file:///TEST_CWD/test/fixtures/all/vanilla/LOADED.js", | ||
"functions": [ | ||
{ | ||
"functionName": "", | ||
"ranges": [ | ||
{ | ||
"startOffset": 0, | ||
"endOffset": 309, | ||
"count": 1 | ||
} | ||
], | ||
"isBlockCoverage": true | ||
}, | ||
{ | ||
"functionName": "getString", | ||
"ranges": [ | ||
{ | ||
"startOffset": 17, | ||
"endOffset": 309, | ||
"count": 3 | ||
}, | ||
{ | ||
"startOffset": 89, | ||
"endOffset": 117, | ||
"count": 0 | ||
}, | ||
{ | ||
"startOffset": 140, | ||
"endOffset": 169, | ||
"count": 1 | ||
}, | ||
{ | ||
"startOffset": 169, | ||
"endOffset": 267, | ||
"count": 2 | ||
}, | ||
{ | ||
"startOffset": 190, | ||
"endOffset": 267, | ||
"count": 1 | ||
}, | ||
{ | ||
"startOffset": 272, | ||
"endOffset": 306, | ||
"count": 0 | ||
} | ||
], | ||
"isBlockCoverage": true | ||
} | ||
] | ||
} | ||
] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* global describe, it */ | ||
const PathSet = require('../lib/path-set') | ||
const assert = require('assert') | ||
describe('path-set', () => { | ||
it('should have only one entry when adding strings with different cases on win32', () => { | ||
const pathSet = new PathSet() | ||
pathSet._win32 = true | ||
const file = 'foo.js' | ||
pathSet.add(file) | ||
pathSet.add(file.toUpperCase()) | ||
assert.strictEqual(pathSet.size, 1) | ||
}) | ||
|
||
it('should have multiple entries when adding strings with different cases on non-win32', () => { | ||
const pathSet = new PathSet() | ||
pathSet._win32 = false | ||
const file = 'foo.js' | ||
pathSet.add(file) | ||
pathSet.add(file.toUpperCase()) | ||
assert.strictEqual(pathSet.size, 2) | ||
}) | ||
|
||
it('has should return true for different cases on win32', () => { | ||
const pathSet = new PathSet() | ||
pathSet._win32 = true | ||
const file = 'foo.js' | ||
pathSet.add(file) | ||
assert(pathSet.has(file.toUpperCase())) | ||
}) | ||
|
||
it('has should NOT return true for different cases non-win32', () => { | ||
const pathSet = new PathSet() | ||
pathSet._win32 = false | ||
const file = 'foo.js' | ||
pathSet.add(file) | ||
assert(!pathSet.has(file.toUpperCase())) | ||
}) | ||
}) |