-
-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Update caching-transform options. #873
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,8 @@ | ||
const CACHE_VERSION = require('../package.json').version | ||
const md5hex = require('md5-hex') | ||
const salt = JSON.stringify({ | ||
istanbul: require('istanbul-lib-coverage/package.json').version, | ||
nyc: CACHE_VERSION | ||
}) | ||
'use strict' | ||
|
||
function Hash (code, filename) { | ||
return md5hex([code, filename, salt]) + '_' + CACHE_VERSION | ||
module.exports = { | ||
salt: JSON.stringify({ | ||
istanbul: require('istanbul-lib-coverage/package.json').version, | ||
nyc: require('../package.json').version | ||
}) | ||
} | ||
|
||
Hash.salt = salt | ||
|
||
module.exports = Hash |
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,14 @@ | ||
const path = require('path') | ||
const assert = require('assert') | ||
const file1 = require('./identical-file1.js') | ||
const file2 = require('./identical-file2.js') | ||
|
||
assert.equal(file1(), file2()) | ||
|
||
const cov = (new Function('return this.__coverage__'))() | ||
|
||
assert.deepEqual(Object.keys(cov).sort(), [ | ||
__filename, | ||
path.resolve('identical-file1.js'), | ||
path.resolve('identical-file2.js') | ||
]) |
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,5 @@ | ||
function identical() { | ||
return 'identical' | ||
} | ||
|
||
module.exports = identical |
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,5 @@ | ||
function identical() { | ||
return 'identical' | ||
} | ||
|
||
module.exports = identical |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm open to better ways to test that the coverage data includes the 3 files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coreyfarrell this assertion seems reasonable to me but, out of curiosity, what would the behavior have been before your fixes to the caching transform, would we have only had one of the two files listed in the coverage object?
mind testing running this test prior to your fix and confirming that it breaks as expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did test it, without the fixes to caching-transform this test would not record results for identical-file2.js. This is because both identical files have the same hash value so caching-transform gave the instrumented code from file1 to file2. This meant file2 recorded it's results to file1.