mmanela / chutzpah

Chutzpah is an open source JavaScript test runner which enables you to run unit tests using QUnit, Jasmine, Mocha and TypeScript.
http://mmanela.github.io/chutzpah/
Apache License 2.0
550 stars 142 forks source link

FileNotFoundException with different working directory and TestFiles folder #596

Closed Danielku15 closed 7 years ago

Danielku15 commented 7 years ago

I am running chutzpah on our CCNet CI using the console runner but I've also discovered this issue locally: If you run chutzpah.console.exe from a different working directory it will fail to run the tests since it cannot find the neccessary chutzpah dependencies.

C:\Dev\MyQUnitProject>C:\Tools\chutzpah\chutzpah.console.exe . 
Chutzpah console test runner  (64-bit .NET 4.0.30319.42000)
Version 4.3.3.0
Copyright (C) 2016 Matthew Manela (http://matthewmanela.com).

Error: System.IO.FileNotFoundException: Could not find file 'C:\Dev\MyQUnitProject\chutzpah_boot.js'.
File name: 'C:\Dev\MyQUnitProject\chutzpah_boot.js'
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)

First I thought it might be a general issue that it looks for the chutzpah_boot.js within the working directory. But the problem seems to be caused by the TestFiles folder. For my own test files i have a TestFiles directory in my test project. It seems that this misleads chutzpah to think it needs to look for the chutzpah_boot.js in the working directory. I found the cause in the code: https://github.com/mmanela/chutzpah/blob/3a54a62f6218fd5e789781c4ad57693d6e657027/Chutzpah/FileProbe.cs#L223

I think the exe path should overrule the working directory by default. Or at least the BuiltInDependencyDirectory should not only look for the TestFiles folder, but also for some chutzpah specific file. TestFiles is quite a general name that might exist in your test project.

So a simple alternative could also be to rename TestFiles to ChutzpahTestFiles or TestRuntime to remove this ambiguous naming.

mmanela commented 7 years ago

Thanks @Danielku15 for the investigation. You are 100% right. I think its funny you are the first person to hit this. The right long term solution is Chutzpah should know which file it is looking for and if it is a one needed to run only look in the right place instead of using the generic probing method I wrote.

That said, I did what you suggested as a temporary mitigation and just renamed the folders. I will include this in the next release.