Skip to content

Commit

Permalink
Expect bench experiments to fail with Cabal (haskell/ghcide#704)
Browse files Browse the repository at this point in the history
  • Loading branch information
pepeiborra authored Jul 20, 2020
1 parent eb50f85 commit 735a360
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions ghcide/stack-ghc-lib.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ flags:
ghc-options:
ghc-lib-parser: -O0
ghc-lib: -O0
ghcide: -DSTACK
3 changes: 3 additions & 0 deletions ghcide/stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ extra-deps:
- extra-1.7.2
nix:
packages: [zlib]

ghc-options:
ghcide: -DSTACK
3 changes: 3 additions & 0 deletions ghcide/stack810.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ extra-deps:

nix:
packages: [zlib]

ghc-options:
ghcide: -DSTACK
4 changes: 4 additions & 0 deletions ghcide/stack84.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ extra-deps:

nix:
packages: [zlib]


ghc-options:
ghcide: -DSTACK
3 changes: 3 additions & 0 deletions ghcide/stack88.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ extra-deps:
- extra-1.7.2
nix:
packages: [zlib]

ghc-options:
ghcide: -DSTACK
13 changes: 11 additions & 2 deletions ghcide/test/exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ addTypeAnnotationsToLiteralsTest = testGroup "add type annotations to literals t
, ""
, "import Debug.Trace"
, ""
, "f a = traceShow \"debug\" a"
, "f a = traceShow \"debug\" a"
])
[ (DsWarning, (6, 6), "Defaulting the following constraint") ]
"Add type annotation ‘[Char]’ to ‘\"debug\""
Expand Down Expand Up @@ -2303,6 +2303,13 @@ xfail8101 = flip expectFailBecause
xfail8101 t _ = t
#endif

expectFailCabal :: String -> TestTree -> TestTree
#ifdef STACK
expectFailCabal _ = id
#else
expectFailCabal = expectFailBecause
#endif

data Expect
= ExpectRange Range -- Both gotoDef and hover should report this range
| ExpectLocation Location
Expand Down Expand Up @@ -2678,17 +2685,19 @@ nonLspCommandLine = testGroup "ghcide command line"
]

benchmarkTests :: TestTree
-- These tests require stack and will fail with cabal test
benchmarkTests =
let ?config = Bench.defConfig
{ Bench.verbosity = Bench.Quiet
, Bench.repetitions = Just 3
, Bench.buildTool = Bench.Stack
} in
withResource Bench.setup id $ \_ -> testGroup "benchmark experiments"
[ testCase (Bench.name e) $ do
[ expectFailCabal "Requires stack" $ testCase (Bench.name e) $ do
res <- Bench.runBench runInDir e
assertBool "did not successfully complete 5 repetitions" $ Bench.success res
| e <- Bench.experiments
, Bench.name e /= "edit" -- the edit experiment does not ever fail
]

----------------------------------------------------------------------
Expand Down

0 comments on commit 735a360

Please sign in to comment.