Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
Description
I was trying to write some gradle projects tests using NbModuleSuite – the plan was to create a simpel gradle project (just buildscript), then open it as a project and inspect.
To my surprise, calls like FileObject.createAndOpen or FileObject.getOuputStream() write (inside FS Atomic Action) resulted in the project directory not being recognized at all ! When I tried to debug the situation, a stop in the debugger (just a single thread) caused the project to be found magically.
It turned to be a race between Git module (the workdir is created inside the source tree managed by git) and the Project system: Git module runs as extension to filesystems even inside FS Atomic Action (shown on a pictured stacktrace from debugger) and executes FileOwnerQuery.findOwner on the to-be-project directory before the buildscript is even created. The result of not being a project is then cached - and the cache is reset asynchronously when/after the project file is created.
But the test manages to call ProjectManager.findProject sooner, while the cache still holds the negative result.
One of the screenshots shows a debugger that stopped in a situation when the script file has been already created (a message in the output window), but project manager call invoked after the creation does not find a project. Uncommenting the m.invoke() line in HACK section will fix the situation - caches must be reset.
The other screenshot is a debugger stopping when the to-be-project directory is first inspected, showing that the directory's is yet empty.
// cc: entlicher