Skip to content

Commit 887cde9

Browse files
committed
Eval tests as proper subpackage (to add QuickCheck dependency)
1 parent a48a8f7 commit 887cde9

File tree

11 files changed

+138
-116
lines changed

11 files changed

+138
-116
lines changed

.circleci/config.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ defaults: &defaults
3636

3737
- run:
3838
name: Build (we need the exe for tests)
39+
# need j1, else ghc-lib-parser triggers OOM
3940
command: stack -j 1 --stack-yaml=${STACK_FILE} install
40-
# need j1, else ghc-lib-parser triggers OOM
4141
no_output_timeout: 30m
4242

4343
- run:
@@ -63,6 +63,14 @@ defaults: &defaults
6363
command: echo "ghcide tests disabled until they got fixed, see https://github.com/mpickering/ghcide/issues/25"
6464
no_output_timeout: 120m
6565

66+
- run:
67+
name: Setup stack eval hie.html
68+
command: cp test/testdata/eval/hie-stack.yaml test/testdata/eval/hie.yaml
69+
70+
- run:
71+
name: Setup stack eval stack.html
72+
command: grep '^resolver:\|^compiler:' stack-build.txt > test/testdata/eval/stack.yaml
73+
6674
- run:
6775
name: Test haskell-language-server func-test suite
6876
# Tasty by default will run all the tests in parallel. Which should

.github/workflows/test.yml

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -7,76 +7,76 @@ jobs:
77
strategy:
88
fail-fast: false
99
matrix:
10-
ghc: ['8.10.2', '8.10.1', '8.8.4', '8.8.3', '8.8.2', '8.6.5', '8.6.4']
10+
ghc: ["8.10.2", "8.10.1", "8.8.4", "8.8.3", "8.8.2", "8.6.5", "8.6.4"]
1111
os: [ubuntu-latest, macOS-latest, windows-latest]
1212
exclude:
1313
- os: windows-latest
14-
ghc: '8.10.2' # broken due to https://gitlab.haskell.org/ghc/ghc/-/issues/18550
14+
ghc: "8.10.2" # broken due to https://gitlab.haskell.org/ghc/ghc/-/issues/18550
1515
- os: windows-latest
16-
ghc: '8.8.4' # also fails due to segfault :(
16+
ghc: "8.8.4" # also fails due to segfault :(
1717
- os: windows-latest
18-
ghc: '8.8.3' # fails due to segfault
18+
ghc: "8.8.3" # fails due to segfault
1919
- os: windows-latest
20-
ghc: '8.8.2' # fails due to error with Cabal
20+
ghc: "8.8.2" # fails due to error with Cabal
2121
include:
2222
- os: windows-latest
23-
ghc: '8.10.2.2' # only available for windows and choco
23+
ghc: "8.10.2.2" # only available for windows and choco
2424

2525
steps:
26-
- uses: actions/checkout@v2
27-
with:
28-
submodules: true
29-
- uses: actions/setup-haskell@v1
30-
with:
31-
ghc-version: ${{ matrix.ghc }}
32-
cabal-version: '3.2'
33-
enable-stack: true
26+
- uses: actions/checkout@v2
27+
with:
28+
submodules: true
29+
- uses: actions/setup-haskell@v1
30+
with:
31+
ghc-version: ${{ matrix.ghc }}
32+
cabal-version: "3.2"
33+
enable-stack: true
3434

35-
- name: Cache Cabal
36-
uses: actions/cache@v2
37-
env:
38-
cache-name: cache-cabal
39-
with:
40-
path: ~/.cabal/
41-
key: ${{ runner.os }}-${{ matrix.ghc }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }}
42-
restore-keys: |
43-
${{ runner.os }}-${{ matrix.ghc }}-build-${{ env.cache-name }}-
44-
${{ runner.os }}-${{ matrix.ghc }}-build-
45-
${{ runner.os }}-${{ matrix.ghc }}
35+
- name: Cache Cabal
36+
uses: actions/cache@v2
37+
env:
38+
cache-name: cache-cabal
39+
with:
40+
path: ~/.cabal/
41+
key: ${{ runner.os }}-${{ matrix.ghc }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }}
42+
restore-keys: |
43+
${{ runner.os }}-${{ matrix.ghc }}-build-${{ env.cache-name }}-
44+
${{ runner.os }}-${{ matrix.ghc }}-build-
45+
${{ runner.os }}-${{ matrix.ghc }}
4646
47-
- run: cabal update
47+
- run: cabal update
4848

49-
# Need this to work around filepath length limits in Windows
50-
- name: Shorten binary names
51-
shell: bash
52-
run: |
53-
sed -i.bak -e 's/haskell-language-server/hls/g' \
54-
-e 's/haskell_language_server/hls/g' \
55-
haskell-language-server.cabal
56-
sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \
57-
src/**/*.hs exe/*.hs
49+
# Need this to work around filepath length limits in Windows
50+
- name: Shorten binary names
51+
shell: bash
52+
run: |
53+
sed -i.bak -e 's/haskell-language-server/hls/g' \
54+
-e 's/haskell_language_server/hls/g' \
55+
haskell-language-server.cabal
56+
sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \
57+
src/**/*.hs exe/*.hs
5858
59-
- name: Build
60-
shell: bash
61-
# Retry it three times to workaround compiler segfaults in windows
62-
run: cabal build || cabal build || cabal build
59+
- name: Build
60+
shell: bash
61+
# Retry it three times to workaround compiler segfaults in windows
62+
run: cabal build || cabal build || cabal build
6363

64-
- name: Test func-test suite
65-
shell: bash
66-
env:
67-
HLS_TEST_EXE: hls
68-
HLS_WRAPPER_TEST_EXE: hls-wrapper
69-
# run the tests without parallelism, otherwise tasty will attempt to run
70-
# all functional test cases simultaneously which causes way too many hls
71-
# instances to be spun up for the poor github actions runner to handle
72-
run: cabal test func-test --test-options="-j1 --rerun-update" || cabal test func-test --test-options="-j1 --rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test func-test --test-options="-j1 --rerun"
64+
- name: Test func-test suite
65+
shell: bash
66+
env:
67+
HLS_TEST_EXE: hls
68+
HLS_WRAPPER_TEST_EXE: hls-wrapper
69+
# run the tests without parallelism, otherwise tasty will attempt to run
70+
# all functional test cases simultaneously which causes way too many hls
71+
# instances to be spun up for the poor github actions runner to handle
72+
run: cabal test func-test --test-options="-j1 --rerun-update" || cabal test func-test --test-options="-j1 --rerun --rerun-update" || cabal test func-test --test-options="-j1 --rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test func-test --test-options="-j1 --rerun"
7373

74-
- name: Test wrapper-test suite
75-
shell: bash
76-
env:
77-
HLS_TEST_EXE: hls
78-
HLS_WRAPPER_TEST_EXE: hls-wrapper
79-
# run the tests without parallelism, otherwise tasty will attempt to run
80-
# all functional test cases simultaneously which causes way too many hls
81-
# instances to be spun up for the poor github actions runner to handle
82-
run: cabal test wrapper-test --test-options="-j1" || cabal test wrapper-test --test-options="-j1" || cabal test wrapper-test --test-options="-j1"
74+
- name: Test wrapper-test suite
75+
shell: bash
76+
env:
77+
HLS_TEST_EXE: hls
78+
HLS_WRAPPER_TEST_EXE: hls-wrapper
79+
# run the tests without parallelism, otherwise tasty will attempt to run
80+
# all functional test cases simultaneously which causes way too many hls
81+
# instances to be spun up for the poor github actions runner to handle
82+
run: cabal test wrapper-test --test-options="-j1" || cabal test wrapper-test --test-options="-j1" || cabal test wrapper-test --test-options="-j1"

haskell-language-server.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,6 @@ test-suite func-test
380380
, tasty-ant-xml >=1.1.6
381381
, tasty-golden
382382
, tasty-rerun
383-
, QuickCheck
384383

385384
hs-source-dirs: test/functional plugins/tactics/src
386385

plugins/default/src/Ide/Plugin/Eval.hs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ module Ide.Plugin.Eval (
1919

2020
import qualified Ide.Plugin.Eval.CodeLens as CL
2121
import Ide.Types (
22-
PluginDescriptor (
23-
pluginCodeLensProvider,
24-
pluginCommands,
25-
),
22+
PluginDescriptor (..),
2623
PluginId,
2724
defaultPluginDescriptor,
2825
)

test/functional/Eval.hs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import Language.Haskell.LSP.Types (
3030
Command (Command, _title),
3131
Position (..),
3232
Range (..),
33+
TextDocumentIdentifier,
3334
)
3435
import System.Directory (doesFileExist)
3536
import System.FilePath (
@@ -57,27 +58,27 @@ tests =
5758
[ testCase "Produces Evaluate code lenses" $
5859
runSession hlsCommand fullCaps evalPath $ do
5960
doc <- openDoc "T1.hs" "haskell"
60-
lenses <- getCodeLenses doc
61+
lenses <- getEvalCodeLenses doc
6162
liftIO $ map (fmap _title . _command) lenses @?= [Just "Evaluate..."]
6263
, testCase "Produces Refresh code lenses" $
6364
runSession hlsCommand fullCaps evalPath $ do
6465
doc <- openDoc "T2.hs" "haskell"
65-
lenses <- getCodeLenses doc
66+
lenses <- getEvalCodeLenses doc
6667
liftIO $ map (fmap _title . _command) lenses @?= [Just "Refresh..."]
6768
, testCase "Code lenses have ranges" $
6869
runSession hlsCommand fullCaps evalPath $ do
6970
doc <- openDoc "T1.hs" "haskell"
70-
lenses <- getCodeLenses doc
71+
lenses <- getEvalCodeLenses doc
7172
liftIO $ map _range lenses @?= [Range (Position 4 0) (Position 5 0)]
7273
, testCase "Multi-line expressions have a multi-line range" $ do
7374
runSession hlsCommand fullCaps evalPath $ do
7475
doc <- openDoc "T3.hs" "haskell"
75-
lenses <- getCodeLenses doc
76+
lenses <- getEvalCodeLenses doc
7677
liftIO $ map _range lenses @?= [Range (Position 3 0) (Position 5 0)]
7778
, testCase "Executed expressions range covers only the expression" $ do
7879
runSession hlsCommand fullCaps evalPath $ do
7980
doc <- openDoc "T2.hs" "haskell"
80-
lenses <- getCodeLenses doc
81+
lenses <- getEvalCodeLenses doc
8182
liftIO $ map _range lenses @?= [Range (Position 4 0) (Position 5 0)]
8283
, testCase "Evaluation of expressions" $ goldenTest "T1.hs"
8384
, testCase "Reevaluation of expressions" $ goldenTest "T2.hs"
@@ -164,13 +165,9 @@ goldenTestBy f input = runSession hlsCommand fullCaps evalPath $ do
164165
doc <- openDoc input "haskell"
165166

166167
-- Execute lenses backwards, to avoid affecting their position in the source file
167-
codeLenses <- reverse . filter f <$> getCodeLenses doc
168+
codeLenses <- reverse <$> getCodeLensesBy f doc
168169
-- liftIO $ print codeLenses
169170

170-
-- Execute in parallel
171-
-- mapM_ executeCommand $ [c | CodeLens{_command = Just c} <- codeLenses]
172-
-- _resp :: ApplyWorkspaceEditRequest <- skipManyTill anyMessage message
173-
174171
-- Execute sequentially
175172
mapM_ executeCmd $ [c | CodeLens{_command = Just c} <- codeLenses]
176173

@@ -187,6 +184,12 @@ goldenTestBy f input = runSession hlsCommand fullCaps evalPath $ do
187184
expected <- liftIO $ T.readFile expectedFile
188185
liftIO $ edited @?= expected
189186

187+
getEvalCodeLenses :: TextDocumentIdentifier -> Session [CodeLens]
188+
getEvalCodeLenses = getCodeLensesBy isEvalTest
189+
190+
getCodeLensesBy :: (CodeLens -> Bool) -> TextDocumentIdentifier -> Session [CodeLens]
191+
getCodeLensesBy f doc = filter f <$> getCodeLenses doc
192+
190193
-- Execute command and wait for result
191194
executeCmd :: Command -> Session ()
192195
executeCmd cmd = do

test/testdata/eval/cabal.project

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages: .

test/testdata/eval/hie-cabal.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
cradle:
2+
cabal:
3+
- path: "././"
4+
component: "lib:test"

test/testdata/eval/hie-stack.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
cradle:
2+
stack:
3+
- path: "././"
4+
component: "test:lib"

test/testdata/eval/hie.yaml

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,4 @@
11
cradle:
2-
direct:
3-
arguments:
4-
- "T1"
5-
- "T2"
6-
- "T3"
7-
- "T4"
8-
- "T5"
9-
- "T6"
10-
- "T7"
11-
- "T8"
12-
- "T9"
13-
- "T10"
14-
- "T11"
15-
- "T12"
16-
- "T13"
17-
- "T14"
18-
- "T15"
19-
- "T16"
20-
- "T17"
21-
- "T18"
22-
- "T19"
23-
- "T20"
24-
- "T21"
25-
- "T22"
26-
- "T23"
27-
- "T24"
28-
- "T25"
29-
- "T26"
30-
- "TMulti"
31-
- "TPlainComment"
32-
- "THaddock"
33-
- "TCompare"
34-
- "TLocalImport"
35-
- "TLocalImportInTest"
36-
- "TLanguageOptionsTupleSections"
37-
- "TIO"
38-
- "TProperty"
39-
- "TPrelude"
40-
- "TCPP"
41-
- "TLHS"
42-
- "TLHSLateX"
43-
- "Util"
2+
cabal:
3+
- path: "././"
4+
component: "lib:test"

test/testdata/eval/stack.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
resolver: lts-14.27 # Last 8.6.5
2+
3+
packages:
4+
- .

0 commit comments

Comments
 (0)