Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit 414bbee

Browse files
authored
Merge pull request #1413 from alanz/robust-tests
Robust tests
2 parents 623f8f6 + dbff14b commit 414bbee

File tree

10 files changed

+51
-42
lines changed

10 files changed

+51
-42
lines changed

.circleci/config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ defaults: &defaults
2626
- stack-cache-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "stack-build.txt" }}
2727
- stack-cache-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "resolver.txt" }}
2828

29+
# - run:
30+
# name: Stack upgrade
31+
# command: stack upgrade
32+
2933
- run:
3034
name: Stack setup
3135
command: stack -j 2 --stack-yaml=${STACK_FILE} setup

app/MainHie.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ run opts = do
119119
logm $ "Run entered for HIE(" ++ progName ++ ") " ++ version
120120
d <- getCurrentDirectory
121121
logm $ "Current directory:" ++ d
122+
args <- getArgs
123+
logm $ "args:" ++ show args
122124

123125
let vomitOptions = defaultOptions { boLogging = BlVomit}
124126
let defaultOpts = if optGhcModVomit opts then vomitOptions else defaultOptions

test/functional/CompletionSpec.hs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ spec :: Spec
1616
spec = describe "completions" $ do
1717
it "works" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
1818
doc <- openDoc "Completion.hs" "haskell"
19-
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
19+
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
2020

2121
let te = TextEdit (Range (Position 5 7) (Position 5 24)) "put"
2222
_ <- applyEdit doc te
@@ -38,7 +38,7 @@ spec = describe "completions" $ do
3838

3939
it "completes imports" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
4040
doc <- openDoc "Completion.hs" "haskell"
41-
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
41+
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
4242

4343
let te = TextEdit (Range (Position 1 17) (Position 1 26)) "Data.M"
4444
_ <- applyEdit doc te
@@ -52,7 +52,7 @@ spec = describe "completions" $ do
5252

5353
it "completes qualified imports" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
5454
doc <- openDoc "Completion.hs" "haskell"
55-
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
55+
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
5656

5757
let te = TextEdit (Range (Position 2 17) (Position 1 25)) "Dat"
5858
_ <- applyEdit doc te
@@ -66,7 +66,7 @@ spec = describe "completions" $ do
6666

6767
it "completes language extensions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
6868
doc <- openDoc "Completion.hs" "haskell"
69-
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
69+
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
7070

7171
let te = TextEdit (Range (Position 0 24) (Position 0 31)) ""
7272
_ <- applyEdit doc te
@@ -79,7 +79,7 @@ spec = describe "completions" $ do
7979

8080
it "completes pragmas" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
8181
doc <- openDoc "Completion.hs" "haskell"
82-
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
82+
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
8383

8484
let te = TextEdit (Range (Position 0 4) (Position 0 34)) ""
8585
_ <- applyEdit doc te
@@ -94,7 +94,7 @@ spec = describe "completions" $ do
9494

9595
it "completes pragmas no close" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
9696
doc <- openDoc "Completion.hs" "haskell"
97-
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
97+
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
9898

9999
let te = TextEdit (Range (Position 0 4) (Position 0 24)) ""
100100
_ <- applyEdit doc te
@@ -109,7 +109,7 @@ spec = describe "completions" $ do
109109

110110
it "completes options pragma" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
111111
doc <- openDoc "Completion.hs" "haskell"
112-
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
112+
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
113113

114114
let te = TextEdit (Range (Position 0 4) (Position 0 34)) "OPTIONS"
115115
_ <- applyEdit doc te
@@ -127,7 +127,7 @@ spec = describe "completions" $ do
127127
it "completes ghc options pragma values" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
128128
doc <- openDoc "Completion.hs" "haskell"
129129

130-
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
130+
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
131131

132132
let te = TextEdit (Range (Position 0 0) (Position 0 0)) "{-# OPTIONS_GHC -Wno-red #-}\n"
133133
_ <- applyEdit doc te
@@ -144,14 +144,14 @@ spec = describe "completions" $ do
144144

145145
it "completes with no prefix" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
146146
doc <- openDoc "Completion.hs" "haskell"
147-
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
147+
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
148148
compls <- getCompletions doc (Position 5 7)
149149
liftIO $ filter ((== "!!") . (^. label)) compls `shouldNotSatisfy` null
150150

151151
-- See https://github.com/haskell/haskell-ide-engine/issues/903
152152
it "strips compiler generated stuff from completions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
153153
doc <- openDoc "DupRecFields.hs" "haskell"
154-
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
154+
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
155155

156156
let te = TextEdit (Range (Position 5 0) (Position 5 2)) "acc"
157157
_ <- applyEdit doc te
@@ -167,15 +167,15 @@ spec = describe "completions" $ do
167167
describe "contexts" $ do
168168
it "only provides type suggestions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
169169
doc <- openDoc "Context.hs" "haskell"
170-
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
170+
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
171171
compls <- getCompletions doc (Position 2 17)
172172
liftIO $ do
173173
compls `shouldContainCompl` "Integer"
174174
compls `shouldNotContainCompl` "interact"
175175

176176
it "only provides type suggestions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
177177
doc <- openDoc "Context.hs" "haskell"
178-
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
178+
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
179179
compls <- getCompletions doc (Position 3 9)
180180
liftIO $ do
181181
compls `shouldContainCompl` "abs"
@@ -184,7 +184,7 @@ spec = describe "completions" $ do
184184
-- This currently fails if it takes too long to typecheck the module
185185
-- it "completes qualified type suggestions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
186186
-- doc <- openDoc "Context.hs" "haskell"
187-
-- _ <- skipManyTill loggingNotification (count 2 noDiagnostics)
187+
-- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics
188188
-- let te = TextEdit (Range (Position 2 17) (Position 2 17)) " -> Conc."
189189
-- _ <- applyEdit doc te
190190
-- compls <- getCompletions doc (Position 2 26)
@@ -195,7 +195,7 @@ spec = describe "completions" $ do
195195

196196
it "have implicit foralls on basic polymorphic types" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
197197
doc <- openDoc "Completion.hs" "haskell"
198-
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
198+
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
199199
let te = TextEdit (Range (Position 5 7) (Position 5 9)) "id"
200200
_ <- applyEdit doc te
201201
compls <- getCompletions doc (Position 5 9)
@@ -207,7 +207,7 @@ spec = describe "completions" $ do
207207

208208
it "have implicit foralls with multiple type variables" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
209209
doc <- openDoc "Completion.hs" "haskell"
210-
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
210+
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
211211
let te = TextEdit (Range (Position 5 7) (Position 5 24)) "flip"
212212
_ <- applyEdit doc te
213213
compls <- getCompletions doc (Position 5 11)
@@ -220,7 +220,7 @@ spec = describe "completions" $ do
220220
describe "snippets" $ do
221221
it "work for argumentless constructors" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
222222
doc <- openDoc "Completion.hs" "haskell"
223-
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
223+
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
224224

225225
let te = TextEdit (Range (Position 5 7) (Position 5 24)) "Nothing"
226226
_ <- applyEdit doc te
@@ -233,7 +233,7 @@ spec = describe "completions" $ do
233233

234234
it "work for polymorphic types" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
235235
doc <- openDoc "Completion.hs" "haskell"
236-
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
236+
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
237237

238238
let te = TextEdit (Range (Position 5 7) (Position 5 24)) "fold"
239239
_ <- applyEdit doc te
@@ -250,7 +250,7 @@ spec = describe "completions" $ do
250250

251251
it "work for complex types" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
252252
doc <- openDoc "Completion.hs" "haskell"
253-
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
253+
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
254254

255255
let te = TextEdit (Range (Position 5 7) (Position 5 24)) "mapM"
256256
_ <- applyEdit doc te
@@ -267,7 +267,7 @@ spec = describe "completions" $ do
267267

268268
it "work for infix functions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
269269
doc <- openDoc "Completion.hs" "haskell"
270-
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
270+
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
271271

272272
let te = TextEdit (Range (Position 5 7) (Position 5 24)) "even `filte"
273273
_ <- applyEdit doc te
@@ -282,7 +282,7 @@ spec = describe "completions" $ do
282282

283283
it "work for infix functions in backticks" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
284284
doc <- openDoc "Completion.hs" "haskell"
285-
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
285+
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
286286

287287
let te = TextEdit (Range (Position 5 7) (Position 5 24)) "even `filte`"
288288
_ <- applyEdit doc te
@@ -297,7 +297,7 @@ spec = describe "completions" $ do
297297

298298
it "work for qualified infix functions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
299299
doc <- openDoc "Completion.hs" "haskell"
300-
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
300+
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
301301

302302
let te = TextEdit (Range (Position 5 7) (Position 5 24)) "\"\" `Data.List.interspe"
303303
_ <- applyEdit doc te
@@ -312,7 +312,7 @@ spec = describe "completions" $ do
312312

313313
it "work for qualified infix functions in backticks" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
314314
doc <- openDoc "Completion.hs" "haskell"
315-
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
315+
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
316316

317317
let te = TextEdit (Range (Position 5 7) (Position 5 24)) "\"\" `Data.List.interspe`"
318318
_ <- applyEdit doc te
@@ -328,7 +328,7 @@ spec = describe "completions" $ do
328328

329329
it "respects lsp configuration" $ runSession hieCommand fullCaps "test/testdata/completion" $ do
330330
doc <- openDoc "Completion.hs" "haskell"
331-
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
331+
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
332332

333333
let config = object ["languageServerHaskell" .= (object ["completionSnippetsOn" .= False])]
334334

@@ -338,7 +338,7 @@ spec = describe "completions" $ do
338338

339339
it "respects client capabilities" $ runSession hieCommand noSnippetsCaps "test/testdata/completion" $ do
340340
doc <- openDoc "Completion.hs" "haskell"
341-
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
341+
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
342342

343343
checkNoSnippets doc
344344
where

test/functional/DiagnosticsSpec.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
module DiagnosticsSpec where
44

5+
import Control.Applicative.Combinators
56
import Control.Lens hiding (List)
67
import Control.Monad.IO.Class
78
import Data.Aeson (toJSON)
@@ -87,7 +88,7 @@ spec = describe "diagnostics providers" $ do
8788

8889
let te = TextEdit (Range (Position 0 0) (Position 0 13)) ""
8990
_ <- applyEdit doc te
90-
noDiagnostics
91+
skipManyTill loggingNotification noDiagnostics
9192

9293
sendNotification TextDocumentDidSave (DidSaveTextDocumentParams doc)
9394
diags2 <- waitForDiagnostics

test/functional/HighlightSpec.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ spec :: Spec
1212
spec = describe "highlight" $
1313
it "works" $ runSession hieCommand fullCaps "test/testdata" $ do
1414
doc <- openDoc "Highlight.hs" "haskell"
15-
_ <- skipManyTill loggingNotification $ count 2 noDiagnostics
15+
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
1616
highlights <- getHighlights doc (Position 2 2)
1717
liftIO $ do
1818
let hls =

test/functional/HoverSpec.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ spec :: Spec
1515
spec = describe "hover" $
1616
it "works" $ runSession hieCommand fullCaps "test/testdata" $ do
1717
doc <- openDoc "Hover.hs" "haskell"
18-
_ <- skipManyTill loggingNotification $ count 2 noDiagnostics
18+
_ <- count 2 $ skipManyTill loggingNotification noDiagnostics
1919
Just h <- getHover doc (Position 1 19)
2020
liftIO $ do
2121
h ^. range `shouldBe` Just (Range (Position 1 16) (Position 1 19))

test/functional/ProgressSpec.hs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,29 @@ spec = describe "window/progress" $ do
3232
startNotification ^. L.params . L.title `shouldBe` "Typechecking ApplyRefact2.hs"
3333
startNotification ^. L.params . L.id `shouldBe` "0"
3434

35-
doneNotification <- message :: Session ProgressDoneNotification
35+
doneNotification <- skipManyTill loggingNotification (message :: Session ProgressDoneNotification)
3636
liftIO $ doneNotification ^. L.params . L.id `shouldBe` "0"
3737

3838
-- the ghc-mod diagnostics
39-
_ <- publishDiagnosticsNotification
39+
_ <- skipManyTill loggingNotification publishDiagnosticsNotification
4040

4141
-- Test incrementing ids
4242
sendNotification TextDocumentDidSave (DidSaveTextDocumentParams doc)
4343

4444
-- hlint notifications
45-
_ <- publishDiagnosticsNotification
45+
_ <- skipManyTill loggingNotification publishDiagnosticsNotification
4646

47-
startNotification' <- message :: Session ProgressStartNotification
47+
startNotification' <- skipManyTill loggingNotification (message :: Session ProgressStartNotification)
4848
liftIO $ do
4949
startNotification' ^. L.params . L.title `shouldBe` "Typechecking ApplyRefact2.hs"
5050
startNotification' ^. L.params . L.id `shouldBe` "1"
5151

52-
doneNotification' <- message :: Session ProgressDoneNotification
52+
doneNotification' <- skipManyTill loggingNotification (message :: Session ProgressDoneNotification)
5353
liftIO $ doneNotification' ^. L.params . L.id `shouldBe` "1"
5454

5555
-- the ghc-mod diagnostics
56-
const () <$> publishDiagnosticsNotification
56+
const () <$> skipManyTill loggingNotification publishDiagnosticsNotification
57+
5758
it "sends indefinite progress notifications with liquid" $
5859
-- Testing that Liquid Haskell sends progress notifications
5960
runSession hieCommand progressCaps "test/testdata" $ do
@@ -62,13 +63,13 @@ spec = describe "window/progress" $ do
6263
skipMany loggingNotification
6364

6465
-- Initial hlint notifications
65-
_ <- publishDiagnosticsNotification
66+
_ <- skipManyTill loggingNotification publishDiagnosticsNotification
6667

6768
_ <- message :: Session ProgressStartNotification
6869
_ <- message :: Session ProgressDoneNotification
6970

7071
-- the ghc-mod diagnostics
71-
_ <- publishDiagnosticsNotification
72+
_ <- skipManyTill loggingNotification publishDiagnosticsNotification
7273

7374
-- Enable liquid haskell plugin
7475
let config = def { liquidOn = True, hlintOn = False }
@@ -78,7 +79,7 @@ spec = describe "window/progress" $ do
7879
sendNotification TextDocumentDidSave (DidSaveTextDocumentParams doc)
7980

8081
-- hlint notifications
81-
_ <- publishDiagnosticsNotification
82+
_ <- skipManyTill loggingNotification publishDiagnosticsNotification
8283

8384
let startPred (NotProgressStart m) =
8485
m ^. L.params . L.title == "Running Liquid Haskell on Evens.hs"
@@ -92,4 +93,4 @@ spec = describe "window/progress" $ do
9293
return ()
9394

9495
progressCaps :: ClientCapabilities
95-
progressCaps = fullCaps { _window = Just (WindowClientCapabilities (Just True)) }
96+
progressCaps = fullCaps { _window = Just (WindowClientCapabilities (Just True)) }
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
import Data.Text
2-
foo = pack "I'm a Text"
2+
foo = pack "I'm a Text"
3+
main = putStrLn "hello"

test/unit/PackagePluginSpec.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ packageSpec = do
4747
let fp = testdata </> cabal
4848
packageType <- findPackageType fp
4949
packageType `shouldBe` CabalPackage "add-package-test.cabal"
50-
it "Find no project description if none is present " $ do
50+
it "Find no project description if none is present" $ do
5151
let fp = cwd </> testdata </> "invalid"
5252
packageType <- findPackageType fp
5353
packageType `shouldBe` NoPackage
5454
it "Throws exception if path is invalid" $ do
5555
let fp = testdata </> "unknownPath"
5656
findPackageType fp `shouldThrow` anyIOException
5757
describe "Add the package to the correct file" $ do
58-
it "Add package to .cabal to executable component"
58+
it "Adds package to .cabal to executable component"
5959
$ withCurrentDirectory (testdata </> "cabal-exe")
6060
$ do
6161
let
@@ -167,7 +167,7 @@ packageSpec = do
167167
testCommand testPlugins act "package" "add" args res
168168

169169

170-
it "Add package to package.yaml to executable component"
170+
it "Adds package to package.yaml to executable component"
171171
$ withCurrentDirectory (testdata </> "hpack-exe")
172172
$ do
173173
let

test/utils/TestUtils.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ ghcVersion = GHCPre84
136136
stackYaml :: FilePath
137137
stackYaml =
138138
#if (defined(MIN_VERSION_GLASGOW_HASKELL) && (MIN_VERSION_GLASGOW_HASKELL(8,6,5,0)))
139-
"stack.yaml"
139+
"stack-8.6.5.yaml"
140140
#elif (defined(MIN_VERSION_GLASGOW_HASKELL) && (MIN_VERSION_GLASGOW_HASKELL(8,6,4,0)))
141141
"stack-8.6.4.yaml"
142142
#elif (defined(MIN_VERSION_GLASGOW_HASKELL) && (MIN_VERSION_GLASGOW_HASKELL(8,6,3,0)))

0 commit comments

Comments
 (0)