Fix up potential race condition in test cases of "box" (fix #3759) #3760
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.
What does it do?
Fix up Issue #3759
When "npm test" runs multiple times, a test case in
test/scripts/box/box.js
fails occasionally.This is caused by a potential race condition.
The test case "process() - hash changed" fails
if it starts and finishes within wall-clock timer tick (=1ms).
This can be explained by the implementation of "box.Cache" (
lib/models/cache.js
)."box.Cache" makes decision about "cache hit/miss" based on "mtime" and "hash" of target file.
"box.Cache" says "cache miss" only when both "mtime" and "hash" are changed.
The test case expects that "box.Cache" says "cache miss" always when "hash" is changed.
Unfortunately "box.Cache" says "cache hit" if "mtime" is not changed.
This patch is to clarify and complement these test cases.
How to test
Pull request tasks