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

Add cradle tests #91

Merged
merged 15 commits into from
Nov 18, 2019
Merged

Add cradle tests #91

merged 15 commits into from
Nov 18, 2019

Conversation

mpickering
Copy link
Collaborator

Other changes

  • Pass --no-nix-pure to stack, otherwise it runs the nix-shell with
    --pure which unsets all env vars.
  • Expose CradleError from HIE.Bios module
  • Return the success flag from the initialisation action.

@mpickering
Copy link
Collaborator Author

What's the best way to setup CI for windows? @jneira ?

@mpickering mpickering mentioned this pull request Nov 15, 2019
14 tasks
@jneira
Copy link
Member

jneira commented Nov 16, 2019

Mmm if travis is already being used i would use it for win too, like lsp-test: https://github.com/bubba/lsp-test/blob/master/.travis.yml

@jneira
Copy link
Member

jneira commented Nov 16, 2019

In the meanwhile i've run the tests locally:

PS D:\dev\ws\haskell\hie-bios> cabal test
Resolving dependencies...
Build profile: -w ghc-8.6.5 -O1
In order, the following will be built (use -v for more details):
 - hie-bios-0.3.0 (lib) (configuration changed)
 - hie-bios-0.3.0 (test:parser-tests) (configuration changed)
 - hie-bios-0.3.0 (test:bios-tests) (first run)
Configuring library for hie-bios-0.3.0..
Preprocessing library for hie-bios-0.3.0..
Building library for hie-bios-0.3.0..
[11 of 16] Compiling HIE.Bios.Ghc.Api ( src\HIE\Bios\Ghc\Api.hs, D:\dev\ws\haskell\hie-bios\dist-newstyle\build\x86_64-windows\ghc-8.6.5\hie-bios-0.3.0\build\HIE\Bios\Ghc\Api.o )
[14 of 16] Compiling HIE.Bios.Ghc.Check ( src\HIE\Bios\Ghc\Check.hs, D:\dev\ws\haskell\hie-bios\dist-newstyle\build\x86_64-windows\ghc-8.6.5\hie-bios-0.3.0\build\HIE\Bios\Ghc\Check.o )
[15 of 16] Compiling HIE.Bios.Cradle  ( src\HIE\Bios\Cradle.hs, D:\dev\ws\haskell\hie-bios\dist-newstyle\build\x86_64-windows\ghc-8.6.5\hie-bios-0.3.0\build\HIE\Bios\Cradle.o )
[16 of 16] Compiling HIE.Bios         ( src\HIE\Bios.hs, D:\dev\ws\haskell\hie-bios\dist-newstyle\build\x86_64-windows\ghc-8.6.5\hie-bios-0.3.0\build\HIE\Bios.o )
Configuring test suite 'parser-tests' for hie-bios-0.3.0..
Configuring test suite 'bios-tests' for hie-bios-0.3.0..
Preprocessing test suite 'parser-tests' for hie-bios-0.3.0..
Building test suite 'parser-tests' for hie-bios-0.3.0..
Preprocessing test suite 'bios-tests' for hie-bios-0.3.0..
Building test suite 'bios-tests' for hie-bios-0.3.0..
[1 of 1] Compiling Main             ( tests\BiosTests.hs, D:\dev\ws\haskell\hie-bios\dist-newstyle\build\x86_64-windows\ghc-8.6.5\hie-bios-0.3.0\t\bios-tests\build\bios-tests\bios-tests-tmp\Main.o )
Linking D:\dev\ws\haskell\hie-bios\dist-newstyle\build\x86_64-windows\ghc-8.6.5\hie-bios-0.3.0\t\parser-tests\build\parser-tests\parser-tests.exe ...
Linking D:\dev\ws\haskell\hie-bios\dist-newstyle\build\x86_64-windows\ghc-8.6.5\hie-bios-0.3.0\t\bios-tests\build\bios-tests\bios-tests.exe ...
Running 1 test suites...
Test suite parser-tests: RUNNING...
Test suite parser-tests: PASS
Test suite logged to:
D:\dev\ws\haskell\hie-bios\dist-newstyle\build\x86_64-windows\ghc-8.6.5\hie-bios-0.3.0\t\parser-tests\test\hie-bios-0.3.0-parser-tests.log
1 of 1 test suites (1 of 1 test cases) passed.
Running 1 test suites...
Test suite bios-tests: RUNNING...
Loading tests
  simple-cabal:  OK (12.20s)
    Finding Cradle
    Loading Cradle
    Initialise Flags    (11.56s)
    Initial module load (0.57s)
    (1,2)               (0.05s)
    (2,2)               (0.02s)
  simple-stack:  FAIL (2.83s)
    Finding Cradle
    Loading Cradle
    Initialise Flags    (2.82s)
    Initial module load
      bios-tests.exe: can't find a package database at D:\bin\stack\x86_64-windows\ghc-8.6.5\lib\package.conf.d        
  simple-direct: OK (0.22s)
    Finding Cradle
    Loading Cradle
    Initialise Flags    (0.10s)
    Initial module load (0.03s)
    (1,2)               (0.07s)
    (2,2)               (0.02s)
  simple-bios:   FAIL (0.15s)
    Finding Cradle
    Loading Cradle
      D:\dev\ws\haskell\hie-bios\tests\projects\simple-bios\hie-bios: streamingProcess: invalid argument (Exec format error)

2 out of 4 tests failed (15.39s)
Test suite bios-tests: FAIL
Test suite logged to:
D:\dev\ws\haskell\hie-bios\dist-newstyle\build\x86_64-windows\ghc-8.6.5\hie-bios-0.3.0\t\bios-tests\test\hie-bios-0.3.0-bios-tests.log
0 of 1 test suites (0 of 1 test cases) passed.
cabal.exe: Tests failed for test:bios-tests from hie-bios-0.3.0.

It is catching the same error that #90 (comment) so the test suite works 👍

@jneira
Copy link
Member

jneira commented Nov 16, 2019

I am trying to add windows support to travis, taking as reference lsp-test. It would be great update haskell-ci to take in account the new travis feature (maybe it already supports it? there is a open issue to add win support: haskell-CI/haskell-ci#199)

@@ -1,21 +1,27 @@
Cabal-Version: 2.4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be wrong, but doesnt this force us to build this package with cabal 2.4 at least?
This will break old stack lts snapshots, since they got shipped with older cabal versions. Iirc, it would force hie to drop stack support for GHC versions older than 8.6.
At least lower the Cabal-Version to 2.2. What was the problem with 1.1?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need Cabal-2.4 for tests/projects/**/*.hs syntax.

src/HIE/Bios/Ghc/Api.hs Show resolved Hide resolved
Comment on lines +1 to +5
# Revision history for simple-cabal

## 0.1.0.0 -- YYYY-mm-dd

* First version. Released on an unsuspecting world.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably noise and could be removed from the .cabal file and the repo

@@ -0,0 +1,66 @@
# This file was automatically generated by 'stack init'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like a lonely stack.yaml does it not have any friends, e.g. source files?

@@ -373,7 +373,7 @@ stackAction work_dir l fp = do
-- Same wrapper works as with cabal
wrapper_fp <- getCabalWrapperTool
(ex1, _stdo, stde, args) <-
readProcessWithExitCodeInDirectory l work_dir "stack" ["repl", "--no-load", "--with-ghc", wrapper_fp, fp ]
readProcessWithExitCodeInDirectory l work_dir "stack" ["repl", "--no-nix-pure", "--no-load", "--with-ghc", wrapper_fp, fp ]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--no-nix-pure has no impact when nix is not enabled right?
Maybe add a comment that it does not?

@@ -11,6 +11,7 @@ module HIE.Bios (
-- * Find and load a Cradle
Cradle(..)
, CradleLoadResult(..)
, CradleError(..)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this fixes the build error in #90?

@fendor
Copy link
Collaborator

fendor commented Nov 16, 2019

If I want to add tests, should I open a PR to your PR or push directly to this branch?

@mpickering
Copy link
Collaborator Author

@fendor You can push directly to this branch. I'll make sure not to force push.

mpickering and others added 12 commits November 18, 2019 22:47
Now all the cradles communicate by reading the value of HIE_BIOS_OUTPUT
which is a filepath, and writing the arguments to that temporary file.
This makes all the cradles more robust about the build tools spurting
things to stdout.
Other changes

* Pass `--no-nix-pure` to stack, otherwise it runs the nix-shell with
`--pure` which unsets all env vars.
* Expose `CradleError` from `HIE.Bios` module
* Return the success flag from the initialisation action.
@mpickering mpickering changed the base branch from wip/no-stdout to master November 18, 2019 22:02
@mpickering mpickering merged commit 2d432cd into master Nov 18, 2019
@mpickering mpickering deleted the wip/tests branch November 18, 2019 23:40
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

Successfully merging this pull request may close these issues.

None yet

3 participants