Skip to content

Commit 3266f71

Browse files
committed
[ new ] Allow path of ALS to be passed into the test suite
1 parent f6e28ba commit 3266f71

File tree

2 files changed

+31
-17
lines changed

2 files changed

+31
-17
lines changed

test/Test.hs

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
1-
module Test where
1+
import Data.Proxy (Proxy (..))
2+
import Data.Typeable (Typeable)
3+
import qualified Test.LSP as LSP
4+
import qualified Test.SrcLoc as SrcLoc
5+
import Test.Tasty
6+
import Test.Tasty.Options
27

3-
import qualified Test.SrcLoc as SrcLoc
4-
import qualified Test.LSP as LSP
5-
import Test.Tasty ( TestTree
6-
, defaultMain
7-
, testGroup
8-
)
8+
-- Define the custom option
9+
newtype AlsPathOption = AlsPathOption FilePath
10+
deriving (Show, Typeable)
11+
12+
instance IsOption AlsPathOption where
13+
defaultValue = AlsPathOption "als"
14+
parseValue = Just . AlsPathOption
15+
optionName = return "als-path"
16+
optionHelp = return "Path to the als executable"
917

1018
main :: IO ()
11-
main = defaultMain tests
19+
main = do
20+
let opts = [Option (Proxy :: Proxy AlsPathOption)]
21+
ingredients = includingOptions opts : defaultIngredients
22+
defaultMainWithIngredients ingredients tests
1223

1324
tests :: TestTree
14-
tests = testGroup "Tests"
15-
[SrcLoc.tests,
16-
LSP.tests
17-
]
25+
tests = askOption $ \(AlsPathOption alsPath) ->
26+
testGroup
27+
"Tests"
28+
[ SrcLoc.tests,
29+
LSP.tests alsPath
30+
]

test/Test/LSP.hs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@ import qualified Data.Aeson as JSON
1212
import Switchboard ( agdaCustomMethod )
1313
import Agda
1414

15-
tests :: TestTree
16-
tests =
15+
tests :: FilePath -> TestTree
16+
tests alsPath =
1717
testGroup
1818
"LSP"
19-
[ testCase "load" demo
19+
[ testCase "load" (demo alsPath)
2020
]
2121

22-
demo :: IO ()
23-
demo = runSession "als" fullLatestClientCaps "test/data/" $ do
22+
demo :: FilePath -> IO ()
23+
demo alsPath =
24+
runSession alsPath fullLatestClientCaps "test/data/" $ do
2425
doc <- openDoc "A.agda" "agda"
2526

2627
-- Use your favourite favourite combinators.

0 commit comments

Comments
 (0)