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

Test dependencies are ignored / not implemented #47

Closed
andys8 opened this issue Jun 2, 2019 · 8 comments
Closed

Test dependencies are ignored / not implemented #47

andys8 opened this issue Jun 2, 2019 · 8 comments

Comments

@andys8
Copy link
Member

andys8 commented Jun 2, 2019

Issue

UNKNOWN IMPORT - The MainTest module has a bad import: import Test I cannot find that module! Is there a typo in the module name? The "source-directories" field of your elm.json tells me to only look in the src directory, but it is not there. Maybe it is in a package that is not installed yet?

Cause

Currently direct dependencies are read, but test-dependencies are not. This will lead to

const dependencies: { [index: string]: string } =
type === "application"
? elmJson.dependencies.direct
: elmJson.dependencies;

elm.json Structure

    "dependencies": {
        "direct": {
        },
        "indirect": {
        }
    },
    "test-dependencies": {
        "direct": {
        },
        "indirect": {
        }
    }

Solution

For now it's probably an improvement to add test-dependencies. In the long term there needs to be some distinction between dependency types, to disallow importing test dependencies in source files.

@andys8
Copy link
Member Author

andys8 commented Jun 2, 2019

I started looking into it. My initial thought is, it should look something like this, which is not working:
5de27ba

I haven't figured out, how to debug, using the language server typescript code base, and vim with ale.
It looks like debugging is not well supported (dense-analysis/ale#2137)

@razzeee
Copy link
Member

razzeee commented Jun 2, 2019

Please try again, should work now, if you got the same problems that I could find with the spa example

@andys8
Copy link
Member Author

andys8 commented Jun 3, 2019

https://github.com/rtfeldman/elm-spa-example/blob/master/tests/RoutingTests.elm

Still getting the same error in the first line claiming it can't find Test as an import.

image

Same behavior with my project. Is it working for you?

@razzeee
Copy link
Member

razzeee commented Jun 3, 2019

Well I made completions, hover, references work yesterday. I can reprod it, will look at it later. I would guess it's caused by us trying to run elm make on it for some reason, but we should be running elm test.

@andys8
Copy link
Member Author

andys8 commented Jun 3, 2019

@razzeee Maybe this implementation is a good help. https://github.com/w0rp/ale/blob/a730a6d5d5a434f3ec93b77a4e003272a9e22925/ale_linters/elm/make.vim#L227

It is consistent with your thoughts.

@andys8
Copy link
Member Author

andys8 commented Jun 3, 2019

I replaced elm with elm-test for testing and it seems to work pretty well. The error message is gone and compile checks are working fine.

  1. elmTestPath param.
  2. Logic to determine if elm or elm-test should be used for compilation. Compare: https://github.com/w0rp/ale/blob/a730a6d5d5a434f3ec93b77a4e003272a9e22925/ale_linters/elm/make.vim#L178

@razzeee
Copy link
Member

razzeee commented Jun 4, 2019

Closing, as it should be working for now.

@razzeee razzeee closed this as completed Jun 4, 2019
@andys8
Copy link
Member Author

andys8 commented Jun 4, 2019

Yep, can confirm it's working

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

2 participants