forked from cenfun/monocart-coverage-reports
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added
baseDir
option for normalizing the relative source path
- Loading branch information
Showing
9 changed files
with
71 additions
and
56 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
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
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
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 |
---|---|---|
@@ -1,63 +1,63 @@ | ||
const platform = process.platform; | ||
const assert = require('assert'); | ||
const { resolveSourceUrl, getSourcePath } = require('../../lib/utils/source-path.js'); | ||
const { resolveSourceUrl, normalizeSourcePath } = require('../../lib/utils/source-path.js'); | ||
|
||
it('resolveSourceUrl', () => { | ||
it('normalizeSourcePath + resolveSourceUrl', () => { | ||
|
||
// windows absolute path | ||
if (platform === 'win32') { | ||
console.log('test win32 path'); | ||
assert.equal(getSourcePath(resolveSourceUrl('C://a.js')), 'C/a.js'); | ||
assert.equal(getSourcePath(resolveSourceUrl('C:\\\\a.js')), 'C/a.js'); | ||
assert.equal(getSourcePath(resolveSourceUrl('c://workspace/test.spec.js')), 'c/workspace/test.spec.js'); | ||
assert.equal(getSourcePath(resolveSourceUrl('c:/workspace/test.spec.js')), 'c/workspace/test.spec.js'); | ||
assert.equal(getSourcePath(resolveSourceUrl('c:\\workspace\\test.spec.js')), 'c/workspace/test.spec.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('C://a.js')), 'C/a.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('C:\\\\a.js')), 'C/a.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('c://workspace/test.spec.js')), 'c/workspace/test.spec.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('c:/workspace/test.spec.js')), 'c/workspace/test.spec.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('c:\\workspace\\test.spec.js')), 'c/workspace/test.spec.js'); | ||
} | ||
|
||
// linux absolute path | ||
assert.equal(getSourcePath(resolveSourceUrl('/dir/./src/a.js')), 'dir/src/a.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('/dir/./src/a.js')), 'dir/src/a.js'); | ||
|
||
// protocol | ||
assert.equal(getSourcePath(resolveSourceUrl('ws://a.js')), 'a.js'); | ||
assert.equal(getSourcePath(resolveSourceUrl('webpack://coverage-v8/./src/branch.js')), 'coverage-v8/src/branch.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('ws://a.js')), 'a.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('webpack://coverage-v8/./src/branch.js')), 'coverage-v8/src/branch.js'); | ||
|
||
// file:// protocol | ||
if (platform === 'win32') { | ||
// absolute | ||
assert.equal(getSourcePath(resolveSourceUrl('file:///C:/path/src/a.js')), 'C/path/src/a.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('file:///C:/path/src/a.js')), 'C/path/src/a.js'); | ||
// relative | ||
assert.equal(getSourcePath(resolveSourceUrl('file://src/a.js')), 'src/a.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('file://src/a.js')), 'src/a.js'); | ||
} else { | ||
// absolute /// | ||
assert.equal(getSourcePath(resolveSourceUrl('file:///src/a.js')), 'src/a.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('file:///src/a.js')), 'src/a.js'); | ||
// relative localhost or empty | ||
assert.equal(getSourcePath(resolveSourceUrl('file://localhost/src/a.js')), 'src/a.js'); | ||
assert.equal(getSourcePath(resolveSourceUrl('file:/src/a.js')), 'src/a.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('file://localhost/src/a.js')), 'src/a.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('file:/src/a.js')), 'src/a.js'); | ||
} | ||
|
||
// relative | ||
assert.equal(getSourcePath(resolveSourceUrl('../../src/a.js')), 'src/a.js'); | ||
assert.equal(getSourcePath(resolveSourceUrl('a.js')), 'a.js'); | ||
assert.equal(getSourcePath(resolveSourceUrl('./src/a.js')), 'src/a.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('../../src/a.js')), 'src/a.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('a.js')), 'a.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('./src/a.js')), 'src/a.js'); | ||
|
||
// sourceRoot | ||
assert.equal(getSourcePath(resolveSourceUrl('../a.js', 'webpack://')), 'a.js'); | ||
assert.equal(getSourcePath(resolveSourceUrl('a.js', 'dist')), 'dist/a.js'); | ||
assert.equal(getSourcePath(resolveSourceUrl('../a.js', 'dist')), 'a.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('../a.js', 'webpack://')), 'a.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('a.js', 'dist')), 'dist/a.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('../a.js', 'dist')), 'a.js'); | ||
|
||
if (platform === 'win32') { | ||
assert.equal(getSourcePath(resolveSourceUrl('./a.js', 'file:///C:/path/src')), 'C/path/src/a.js'); | ||
assert.equal(getSourcePath(resolveSourceUrl('../a.js', 'file:///C:/path/src')), 'C/path/a.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('./a.js', 'file:///C:/path/src')), 'C/path/src/a.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('../a.js', 'file:///C:/path/src')), 'C/path/a.js'); | ||
|
||
assert.equal(getSourcePath(resolveSourceUrl('./a.js', 'file://path/src')), 'path/src/a.js'); | ||
assert.equal(getSourcePath(resolveSourceUrl('../a.js', 'file://path/src')), 'path/a.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('./a.js', 'file://path/src')), 'path/src/a.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('../a.js', 'file://path/src')), 'path/a.js'); | ||
|
||
} else { | ||
// absolute /// | ||
assert.equal(getSourcePath(resolveSourceUrl('./a.js', 'file:///path/src')), 'path/src/a.js'); | ||
assert.equal(getSourcePath(resolveSourceUrl('../a.js', 'file:///path/src')), 'path/a.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('./a.js', 'file:///path/src')), 'path/src/a.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('../a.js', 'file:///path/src')), 'path/a.js'); | ||
} | ||
|
||
assert.equal(getSourcePath(resolveSourceUrl('a.js', '/root')), 'root/a.js'); | ||
assert.equal(normalizeSourcePath(resolveSourceUrl('a.js', '/root')), 'root/a.js'); | ||
|
||
}); |