-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 compiler command crystal clear_cache
#13553
Add compiler command crystal clear_cache
#13553
Conversation
For testing, you could just write a file to |
Added a spec for it. Not 100% sure if we actually want this spec or not, since it actually deletes the actual compiler cache, and I could imagine that there might be an issue with doing that during the tests. I'm thinking that it would be problematic if the compiler tests were ever run in parallel, since it could easily interfere with another test. I briefly took a look at making a tempdir for the test and trying to use that instead of the actual compiler cache. Couldn't reassign the CacheDir singleton, and I'm not familiar enough with crystal to really know the best way to mock out a singleton. So if you have any guidance on that then I'd be happy to modify the spec so that it uses a tempdir instead of the actual compiler cache. Otherwise, I think this is alright for now (especially since the spec isn't really a requirement for the PR) |
65fd00b
to
f158622
Compare
Closest to mocking that stdlib provides, is monkey-patching the class Crystal::CacheDir
class_setter instance
def initialize(@dir)
end
end This would allow you to swap the |
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.
Nice. Doing that much work for the spec really wasn't expected of you.
It could potentially pose a problem if we run specs concurrently. For that to work correctly, we'd need to run the command in complete isolation. But we don't do that right now, and there are probably other issues with that as well in the compiler specs.
So I'm happy to take it in. We'll see if there happen to be any issues with it.
Co-authored-by: Sijawusz Pur Rahnama <[email protected]>
f1663c3
to
4023afb
Compare
@baseballlover723 Please avoid force pushes to a PR, as requested in the the contributing guide. Especially, after it has been approved and milestoned. |
My apologies, I didn't realize that that document existed. I'll refrain from force pushing in the future. Thanks for linking the document to me. |
crystal clear_cache
Co-authored-by: Sijawusz Pur Rahnama <[email protected]>
Seemed simple enough to implement so I took a crack at it. Working perhaps isn't the best, but I think is moderately clear enough. Didn't add any tests because I don't know enough about the compiler to know how to easily generate cache files.
Fixes #4730