Skip to content
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

Error when generating report #8

Open
michaeljones opened this issue Jan 31, 2018 · 6 comments
Open

Error when generating report #8

michaeljones opened this issue Jan 31, 2018 · 6 comments

Comments

@michaeljones
Copy link

michaeljones commented Jan 31, 2018

I wanted to do some long overdue testing on my code base and hoped to use this project to guide me towards areas that could definitely need it. Looks super promising but I get an error when running it. No worries at all but just wanted to report it in case it was useful:

$ elm coverage                                               
[10:03:25.21] Instrumenting sources...               
[10:03:29.86] Wrote original tests/elm-package.json to .coverage/elm-package.json.bak                     
[10:03:29.86] Running tests...                       
Success! Compiled 78 modules.                        
Successfully generated /dev/null                     
Success! Compiled 1 module.                          
Successfully generated /home/michael/root/projects/hive/portal/server/apps/business/elm-stuff/generated-code/elm-community/elm-test/elmTestOutput.js                                                                 

elm-test 0.18.11                                     
----------------                                     

Running 90 tests. To reproduce these results, run: elm-test --fuzz 100 --seed 742943637 tests/                                                                              

TEST RUN PASSED                                      

Duration: 651 ms                                     
Passed:   90                                         
Failed:   0                                          

[10:04:17.42] Restored tests/elm-package.json        
[10:04:17.44] Generating report...                   
Unhandled rejection Error: ENOENT: no such file or directory, open 'src/Main.elm'        

I'm not sure where the src/Main.elm is coming from as I don't have a file called that and I can't see that string in the elm-coverage source code either.

Thanks for the project though. As I said, exciting to see :)

Edit: Very happy to provide more information but I'm not sure what bits would be useful to know.

@michaeljones
Copy link
Author

So I had something strange in my set up (a wrapper script for elm-make) but I still experience problems with that removed. I see the issue above and then if I try to run it again I get:

$ elm coverage                                                                                             
[11:33:24.30] Instrumenting sources...
[11:33:28.57] Wrote original tests/elm-package.json to .coverage/elm-package.json.bak
[11:33:28.57] Running tests...
[11:33:29.50] Ruh roh, tests failed.
[11:33:29.50] Restored tests/elm-package.json
[11:33:29.50] Something went wrong: 
Error: I found multiple modules named 'Coverage'.

Module 'Authoring.ActivityTemplate.Model' is trying to import it.

Modules with that name were found in the following locations:

    directory /home/michael/root/projects/hive/portal/node_modules/elm-coverage/kernel-src/Coverage.elm
    directory /home/michael/root/projects/hive/portal/node_modules/elm-coverage/kernel-src/Coverage.elm

Compilation failed while attempting to build ...

Which even happens immediately after elm-test runs & passes just fine.

I'm afraid I'm quite clueless as to what it going on.

@zwilias
Copy link
Owner

zwilias commented Feb 1, 2018

That looks like there's a duplicate entry in tests/elm-package.json. Perhaps restoring it failed in a previous run? Can you verify that it does not include any weird stuff like that kernel-src folder as a source-directory?

(If restoration failed, that's an issue by itself, though I suspect there's more going on here)

@michaeljones
Copy link
Author

I'll check that. The test/elm-package.json did seem to have been re-written to a single line of json for some reason. I'll explore that a bit more.

Another piece of the puzzle is that I have my working directly with a src folder and 4 different entry files for 4 different apps. I have Authoring.elm, Business.elm, etc. I've just realised that each of these declare themselves as module Main exposing (..) and I guess it works as they are all compiled separately via different imports to js code that is handled by webpack and webpack loader. Maybe the Main in the original error is coming from one of those? I'll experiment.

@zwilias
Copy link
Owner

zwilias commented Feb 1, 2018

Ohhh, yeah, that must be it.

Coverage is calculate per module. Afterwards, for generating the module, it "reverse engineers" the filename from the module-name. I hadn't realized people would have multiple Main modules, which is a perfectly fine thing to have.

I'm going to have to ponder how to handle this 🤔

@michaeljones
Copy link
Author

Yeah, I can confirm that it works fine after fixing up the module names. Looks fantastic. Great job. Now if it could just write the tests too...

@xAt0mZ
Copy link

xAt0mZ commented Feb 9, 2018

Hello @zwilias ,
having the same issue ("Unhandled rejection Error: ENOENT: no such file or directory, open 'src/ModuleX/Main.elm' ") just by putting my elm sources in subfolders under src, before naming the subsequent folders following the elm architecture.

Means, I have
---src/projectA/ModuleX/Main.elm

elm-coverage is trying to resolve "src/ModuleX/Main.elm" with reverse engeenering from module names, but it's not matching the actual files architecture.
Maybe using the "source-directories" entry from elm-package.json can be a way to handle this problem.

Cheers,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants