-
-
Notifications
You must be signed in to change notification settings - Fork 368
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
ghcide test IfaceTests
, we should remove interface cache dir before we run the test, or the diganostic simply gone
#4200
Comments
A possible solution to this would be to remove the .cache dir in |
The test seems to time out on re-runs.
|
@komikat Yes, since if we have the cache, we won't compile it again and hence the diganostic is not genereated |
@soulomoon so expected behaviour should be to not wait for a diagnosis? or delete the specific component being cached before the test is run? |
@komikat The point of the test is to assert wether the diganostic would arrive. So may be the latter. |
I tried removing the cache dir in setupTestEnvironment :: IO FilePath
setupTestEnvironment = do
tmpDirRoot <- getTemporaryDirectory
let testRoot = tmpDirRoot </> "hls-test-root"
testCacheDir = testRoot </> ".cache"
dirExists <- doesDirectoryExist testCacheDir
when dirExists $ removeDirectoryRecursive testCacheDir
createDirectory testCacheDir
setEnv "XDG_CACHE_HOME" testCacheDir
pure testRoot this solves |
Then those tests are very suspicious !(Being not worked without cache) 🤔
Something must be wrong in our tests. |
Maybe not!
This suggests there being a race condition somewhere causing the directory to be deleted in between these two lines. dirExists <- doesDirectoryExist testCacheDir
when dirExists $ removeDirectoryRecursive testCacheDir I tried handling the exception itself instead — this way: setupTestEnvironment :: IO FilePath
setupTestEnvironment = do
tmpDirRoot <- getTemporaryDirectory
let testRoot = tmpDirRoot </> "hls-test-root"
testCacheDir = testRoot </> ".cache"
exc <- try $ removeDirectoryRecursive testCacheDir
case exc of
Left e ->
if isDoesNotExistError e
then return ()
else ioError e
Right _ ->
return ()
createDirectory testCacheDir
setEnv "XDG_CACHE_HOME" testCacheDir
pure testRoot This gets rid of all previous exceptions(!) but creates a new one:
This is probably due to the same race condition causing the previous issue. We can use createDirectoryIfMissing instead but Tagging @fendor since I'm not sure if I'm heading in the right direction. |
It looks like sharing the |
Thanks, that solves the issue. I'm only concerned about there being too many directories being created, would it be better to clean up all the temporary dirs after? |
All directories are created in the temporary hls root directory. So I think it is fine. |
This can happened in the second round doing the test.
Reproduce
Run this consectively
we are seeing
The test past again if we remove the cache dir entirely
The text was updated successfully, but these errors were encountered: