contributte / codeception

:arrow_forward: Integration of Nette Framework to Codeception.
https://contributte.org/packages/contributte/codeception.html
MIT License
27 stars 15 forks source link

"Unable to delete" on Windows #3

Closed jirinapravnik closed 7 years ago

jirinapravnik commented 8 years ago

I am getting almost on every run error "Unable to delete". Once it is file, then it is also directory temp/functional...

I tried to play with NetteDIModule.php and move code in _before() should be in _beforeSuite(), and _after() should be in _afterSuite(). And problem seems to be solved, only sometimes it get that error. I don't understand too much codeception, but IMHO current version of NetteDIModule rebuild container on each test, when I run full suite and it's expensive...

enumag commented 8 years ago

I've never seen this error (and I'm in fact using windows), can you elaborate how to reproduce it or what kind of file it is?

As for container creation you're right about that. It's not easy to achieve though because you would have to keep generated DIC while clearing all other cached data for proper tests isolation.

EDIT: Or maybe we could make the tempDir clearing optional. Would that work for you?

jirinapravnik commented 8 years ago

I am using also Doctrine and so DIC and cache folder is quite large. It is diferrent files or folder. Sometimes it also pass, but not so often.

I think it would be probably better to have optional clearing tempDir, or somethim like that. If i run my suite "as is" it lasts 2.23min. If I run it with my edited NetteDIModule (_afterSuite & _beforeSuite) it lasts 53 sec.

enumag commented 8 years ago

Can you post your edited NetteDIModule for inspiration?

jirinapravnik commented 8 years ago

I only moved code from _after() to _afterSuite() and _before() to _beforeSuite()

But it is probably solution for faster execution, not for "unable delete". If it helps, "unable delete" is caused by "permission denied".

enumag commented 8 years ago

Can you test how fast it is if you rename the methods back to _before / _after and remove the FileSystem::delete() call in _before?

I'm afraid I can't help with unable delete without being able to reproduce it.

jirinapravnik commented 8 years ago

Still slow. One test in suite takes about 14sec. In my edited NetteDIModule takes about 5sec (except first, because it must generate cache folder and DIC).

I understand, but it is interesting, you have never seen this error... Have you ever tried run it in larger application - in my case - 400 services & 65 entities?

enumag commented 8 years ago

That's odd. Can you determine why Nette recompiles the container after that change? (Presuming that's what is slowing the tests down.)

Probably not as large as yours.

Also don't take my "never saw this error" too seriously. It's quite possible I just forgot.

jirinapravnik commented 8 years ago

IMHO it recompiles due to _after - there is also FileSystem::delete ... And _after is called IMHO after each test function

enumag commented 8 years ago

Oh of course. Remove the delete from after as well. Then it should be fast.

jirinapravnik commented 8 years ago

Only a bit faster, problem is also $this->container = null; in _before(). If i remove this, it is fast like my edited file.

enumag commented 8 years ago

$this->container = null; is something I'd like to keep. Reusing the same container for all tests can lead to all sorts of problems. I'm trying to achieve a point where the container is created but not generated for every test. Which should be the case after removing the FileSystem::delete calls. - I don't understand why it is still slow.

enumag commented 8 years ago

@jirinapravnik After some thought I want to add an option for reusing the container. Perhaps even make it default in some future version. Can you send a PR?

enumag commented 7 years ago

@jirinapravnik Please check if the new option works for you. I can add this to v0.7.x as well if you want.