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

tests/elm.json still required for ALE to lint test files #64

Closed
altaurog opened this issue Dec 31, 2018 · 2 comments
Closed

tests/elm.json still required for ALE to lint test files #64

altaurog opened this issue Dec 31, 2018 · 2 comments

Comments

@altaurog
Copy link

altaurog commented Dec 31, 2018

I gather that test-dependencies has been added to elm.json (formerly elm-package.json) to separate test dependencies. This does indeed seem to be a better approach than maintaining tests/elm.json separately.

However, when using vim/ALE, I see import errors. ALE runs elm make under the hood. It looks to me like it is essentially:

$ elm make --output=/dev/null tests/Example.elm

Which produces the following error

-- UNKNOWN IMPORT -------------------------------------------- tests/Example.elm

The Example 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 look in directories
like src, but it is not in any of them. Maybe it is in a package that is not
installed yet?

Of course, elm-explorations/test is in test-dependencies, not dependencies.

By creating tests/elm.json with adjusted source-directories and dependencies, I can get the make command (and thereby ALE) to work. But this confuses elm-test and it fails with the following:

Error: /path/to/my/project/tests/tests does not exist. Please create a tests/ directory in your project root!

As a quick and dirty workaround, I have a bash function as follows:

elmtest() {
    mv tests/elm.json tests/elmjson
    elm-test "$@"
    mv tests/elmjson tests/elm.json
}

But this is obviously not the right solution.
Is there a (better) way to do this now?

@avh4
Copy link
Collaborator

avh4 commented Dec 31, 2018

I believe you can do elm test make --output=/dev/null tests/Example.elm (note this is elm test make, not elm make) to build files that use the test dependencies.

@altaurog
Copy link
Author

altaurog commented Jan 1, 2019

@avh4 thanks for the suggestion! With elm 0.19.0 elm test only gives an error, but elm-test make seems to do the trick. Is that documented somewhere? It isn’t in the usage help I get with elm-test --help.

@altaurog altaurog closed this as completed Jan 1, 2019
altaurog added a commit to altaurog/ale that referenced this issue Jan 2, 2019
With earlier elm versions, a separate package file is maintained for
tests, which when properly configured enabled the compiler to find what
it needed to compile the tests.  Under elm 0.19, test dependencies are
managed in the top-level package file, so `elm make` will fail on the
tests.  `elm-test make` is required in this case.

See elm-explorations/test#64
altaurog added a commit to altaurog/ale that referenced this issue Jan 2, 2019
With earlier elm versions, a separate package file is maintained for
tests, which when properly configured enabled the compiler to find what
it needed to compile the tests.  Under elm 0.19, test dependencies are
managed in the top-level package file, so `elm make` will fail on the
tests.  `elm-test make` is required in this case.

See elm-explorations/test#64
altaurog added a commit to altaurog/ale that referenced this issue Jan 3, 2019
With earlier elm versions, a separate package file is maintained for
tests, which when properly configured enabled the compiler to find what
it needed to compile the tests.  Under elm 0.19, test dependencies are
managed in the top-level package file, so `elm make` will fail on the
tests.  `elm-test make` is required in this case.

See elm-explorations/test#64
altaurog added a commit to altaurog/ale that referenced this issue Jan 3, 2019
With earlier elm versions, a separate package file is maintained for
tests, which when properly configured enabled the compiler to find what
it needed to compile the tests.  Under elm 0.19, test dependencies are
managed in the top-level package file, so `elm make` will fail on the
tests.  `elm-test make` is required in this case.

See elm-explorations/test#64
altaurog added a commit to altaurog/ale that referenced this issue Jan 4, 2019
With earlier elm versions, a separate package file is maintained for
tests, which when properly configured enabled the compiler to find what
it needed to compile the tests.  Under elm 0.19, test dependencies are
managed in the top-level package file, so `elm make` will fail on the
tests.  `elm-test make` is required in this case.

See elm-explorations/test#64
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