-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
add clearCache cli command #4430
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3036f7e
add clearCache cli command
tabrindle 7615c79
fix lint issue - sort-keys
tabrindle 04b495d
clear all projects cacheDirectory
tabrindle d63c815
improve wording in arg description
tabrindle 0a7a2c2
use path.join instead of string concat
tabrindle 4595517
remove clearDirectory function in favor of rimraf
tabrindle 40efb06
allow clearCache loop to run before failing with exit 1
tabrindle a4b9ea6
add clear_cache integration test
tabrindle 613feca
fix integration test
tabrindle 82d01b3
changes per PR comments
tabrindle 2cc04eb
update license headers to MIT
tabrindle cf503fb
add check for cache_dir before deletion
tabrindle 072428c
update license to MIT for pass_with_no_tests.test.js
tabrindle 4680586
fix lint error
tabrindle 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const os = require('os'); | ||
const path = require('path'); | ||
const runJest = require('../runJest'); | ||
|
||
const CACHE = path.resolve(os.tmpdir(), 'clear_cache_directory'); | ||
|
||
describe('jest --clearCache', () => { | ||
test('normal run results in cache directory being written', () => { | ||
const {status} = runJest('clear_cache', [`--cacheDirectory=${CACHE}`]); | ||
|
||
expect(fs.existsSync(CACHE)).toBe(true); | ||
expect(status).toBe(0); | ||
}); | ||
test('clearCache results in deleted directory and exit status 0', () => { | ||
expect(fs.existsSync(CACHE)).toBe(true); | ||
|
||
const {status, stdout, stderr} = runJest('clear_cache', [ | ||
'--clearCache', | ||
`--cacheDirectory=${CACHE}`, | ||
]); | ||
|
||
expect(fs.existsSync(CACHE)).toBe(false); | ||
expect(stdout).toBe(`Cleared ${CACHE}\n`); | ||
expect(stderr.trim()).toBe(''); | ||
expect(status).toBe(0); | ||
}); | ||
}); |
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
11 changes: 11 additions & 0 deletions
11
integration_tests/clear_cache/__tests__/clear_cache.test.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,11 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
'use strict'; | ||
|
||
test('stub', () => expect(1).toBe(1)); |
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 @@ | ||
{ | ||
"jest": { | ||
"testEnvironment": "node" | ||
} | ||
} |
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
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.
It's a false positive. This folder doesn't exist, because Jest didn't run any tests. We need to populate this cache earlier with a sample run, then run it once more. Or just create the dir and make sure it is present prior to running test.
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.
Sorry I thought the folder was created when calling runJest regardless of whether there are tests or not. Will add a stub test, verify the cache dir has contents, then runJest again with clearCache
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.
can you add
above the
runJest
call?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.
In the second test correct? Makes sense.
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.
Correct!