-
-
Notifications
You must be signed in to change notification settings - Fork 359
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 reset, clean up before every test #121
Conversation
@@ -117,7 +117,7 @@ if (process.env.NYC_CWD) { | |||
} else if (argv._.length) { | |||
// wrap subprocesses and execute argv[1] | |||
var nyc = (new NYC()) | |||
nyc.cleanup() | |||
nyc.reset() |
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 wonder if the if (!process.env.NYC_CWD)
clause in cleanup()
is causing some confusion here. I think it ensures child processes don't perform any cleanup, but maybe that guard should be in this file and not in the implementation.
TBH I'm not entirely sure what the expected behavior is and why it impacts --all
.
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.
The issue with all
was that it was calling cleanup()
, which deleted directories, but did not recreate them.
but maybe that guard should be in this file and not in the implementation.
I think I agree with you (I considered that as well). I just wanted to avoid an additional change creeping into this PR.
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.
The issue with all was that it was calling cleanup(), which deleted directories, but did not recreate them.
Where did it call cleanup()
? That's the part I'm not understanding, I suppose.
I just wanted to avoid an additional change creeping into this PR.
Sure.
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.
Where did it call cleanup()?
Right there in that diff. Now instead it calls reset
, which deletes and recreates the directory.
The issue is that all
immediately and synchronously writes a "preample" for every included file to disk, before continuing with the test, so the folder needs to exist, even though we haven't yet forked a process.
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.
Ah! OK, resetting before running anything makes sense.
@jamestalmage how do you feel about moving the cache folder into |
Separate folders makes it easier to clean between tests (we don't want to clean the cache each time). Also, AVA has already followed suit and caches Babel transforms in If anything, I would like to move |
@jamestalmage this seems like a reasonable argument, it's good that AVA and nyc are standardizing on an approach. Let's hold off on moving |
I'm happy with this branch, once you and @novemberborn both sign off. |
I don't quite understand why |
@Lalem001, can you confirm that this branch solves your |
The issue is resolved. 👍 |
|
Add a reset method, and clean up between tests.
@Lalem001 |
This adds a
reset
method which deletes the temp directory then adds it back.createTempDirectory
is no longer called for every forked process.Instead of writing a test for #120, I just went ahead and fixed #112. I have verified it would have caught the error.
Fixes #120
Fixes #112