Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions tests/app/Spec/Tests/Rust/Changes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module Spec.Tests.Rust.Changes (tests) where
import Control.Lens
import Data.Function
import qualified Data.List as L
import Data.Row.Records
import Data.String.Interpolate
import qualified Language.LSP.Protocol.Lens as LSP
import Language.LSP.Protocol.Types
Expand All @@ -27,7 +26,7 @@ tests = describe "Changes" $ do
, (Range (Position 0 7) (Position 0 7), Just (InR "E0423"), "use `!` to invoke the macro: `!`")
]

changeDoc ident [TextDocumentContentChangeEvent $ InL (#range .== (Range (p 0 7) (p 0 7)) .+ #rangeLength .== Nothing .+ #text .== "z")]
changeDoc ident [TextDocumentContentChangeEvent $ InL $ TextDocumentContentChangePartial (Range (p 0 7) (p 0 7)) Nothing "z"]

waitUntil 120.0 $ do
waitForDiagnostics >>= \diags -> do
Expand Down
6 changes: 1 addition & 5 deletions tests/app/Spec/Tests/Typst.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@

module Spec.Tests.Typst (tests) where

import Control.Lens hiding (List)
import Control.Monad
import Data.String.Interpolate
import Data.Text as T
import Language.LSP.Protocol.Lens hiding (diagnostics, hover, text)
import Language.LSP.Protocol.Types
import Language.LSP.Test hiding (message)
import Test.Sandwich as Sandwich
import TestLib.JupyterRunnerContext
import TestLib.LSP
import TestLib.NixEnvironmentContext
import TestLib.NixTypes
import TestLib.TestBuilding
import TestLib.TestSearchers
import TestLib.Types


Expand Down Expand Up @@ -71,6 +66,7 @@ lsName = "tinymist"
-- ]
-- }

config :: [Text]
config = [
"exporters.typst.enable = true;"
, "exporters.typst.lsp.tinymist.enable = true;"
Expand Down
2 changes: 1 addition & 1 deletion tests/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
postgresql.pg_config
zlib

haskell.compiler.ghc96
haskell.compiler.ghc9122
];

NIX_PATH = "nixpkgs=${pkgs.path}";
Expand Down
30 changes: 15 additions & 15 deletions tests/src/TestLib/LSP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import qualified Data.List as L
import Data.Map (Map)
import qualified Data.Map as M
import Data.Maybe
import Data.Row.Records hiding (Map)
import qualified Data.Set as S
import Data.String.Interpolate
import qualified Data.Text as T hiding (filter)
import Data.Text hiding (filter)
import Data.Text hiding (filter, show)
import qualified Data.Text.IO as T
import GHC.Int
import GHC.Stack
import Language.LSP.Protocol.Capabilities
import Language.LSP.Protocol.Lens as LSP hiding (diagnostics, hover, id, label, name, ranges)
import Language.LSP.Protocol.Types
import Language.LSP.Test
Expand Down Expand Up @@ -66,7 +66,7 @@ data LanguageServerConfig = LanguageServerConfig {
, lspConfigPrimary :: Maybe Bool
, lspConfigArgs :: [Text]
, lspConfigLanguageId :: Maybe Text
, lspConfigInitializationOptions :: Maybe A.Value
, lspConfigInitializationOptions :: Maybe A.Object
, lspConfigNotebookSuffix :: Text
, lspConfigKernelName :: Maybe Text
, lspConfigEnv :: Maybe (Map Text Text)
Expand Down Expand Up @@ -103,20 +103,20 @@ doSession' filename lsName codeToUse cb = do

testDiagnostics :: (
LspContext ctx m
) => Text -> FilePath -> Maybe Text -> Text -> ([Diagnostic] -> ExampleT ctx m ()) -> SpecFree ctx m ()
) => Text -> FilePath -> Maybe LanguageKind -> Text -> ([Diagnostic] -> ExampleT ctx m ()) -> SpecFree ctx m ()
testDiagnostics name filename maybeLanguageId codeToTest = testDiagnostics' name filename maybeLanguageId codeToTest []

testDiagnostics' :: (
LspContext ctx m
) => Text -> FilePath -> Maybe Text -> Text -> [(FilePath, B.ByteString)] -> ([Diagnostic] -> ExampleT ctx m ()) -> SpecFree ctx m ()
) => Text -> FilePath -> Maybe LanguageKind -> Text -> [(FilePath, B.ByteString)] -> ([Diagnostic] -> ExampleT ctx m ()) -> SpecFree ctx m ()
testDiagnostics' name filename maybeLanguageId codeToTest = testDiagnostics'' [i|#{name}, #{filename} with #{show codeToTest} (diagnostics)|] name filename maybeLanguageId codeToTest

testDiagnosticsLabelDesired :: (
LspContext ctx m
) => String -> Text -> FilePath -> Maybe Text -> Text -> ([Diagnostic] -> Bool) -> SpecFree ctx m ()
) => String -> Text -> FilePath -> Maybe LanguageKind -> Text -> ([Diagnostic] -> Bool) -> SpecFree ctx m ()
testDiagnosticsLabelDesired label name filename maybeLanguageId codeToTest cb = it label $
withLspSession' id name filename codeToTest [] $ \_homeDir -> do
_ <- openDoc filename (fromMaybe name maybeLanguageId)
_ <- openDoc filename (fromMaybe (LanguageKind_Custom name) maybeLanguageId)

lastSeenDiagsVar <- newTVarIO mempty

Expand All @@ -137,15 +137,15 @@ testDiagnosticsLabelDesired label name filename maybeLanguageId codeToTest cb =

testDiagnosticsLabel :: (
LspContext ctx m
) => String -> Text -> FilePath -> Maybe Text -> Text -> ([Diagnostic] -> ExampleT ctx m ()) -> SpecFree ctx m ()
) => String -> Text -> FilePath -> Maybe LanguageKind -> Text -> ([Diagnostic] -> ExampleT ctx m ()) -> SpecFree ctx m ()
testDiagnosticsLabel label name filename maybeLanguageId codeToTest = testDiagnostics'' label name filename maybeLanguageId codeToTest []

testDiagnostics'' :: (
LspContext ctx m
) => String -> Text -> FilePath -> Maybe Text -> Text -> [(FilePath, B.ByteString)] -> ([Diagnostic] -> ExampleT ctx m ()) -> SpecFree ctx m ()
) => String -> Text -> FilePath -> Maybe LanguageKind -> Text -> [(FilePath, B.ByteString)] -> ([Diagnostic] -> ExampleT ctx m ()) -> SpecFree ctx m ()
testDiagnostics'' label name filename maybeLanguageId codeToTest extraFiles cb = it label $ do
withLspSession' id name filename codeToTest extraFiles $ \_homeDir -> do
_ <- openDoc filename (fromMaybe name maybeLanguageId)
_ <- openDoc filename (fromMaybe (LanguageKind_Custom name) maybeLanguageId)

lastSeenDiagsVar <- newIORef mempty

Expand All @@ -158,10 +158,10 @@ testDiagnostics'' label name filename maybeLanguageId codeToTest extraFiles cb =

itHasHoverSatisfying :: (
LspContext ctx m
) => Text -> FilePath -> Maybe Text -> Text -> Position -> (Hover -> ExampleT ctx m ()) -> SpecFree ctx m ()
) => Text -> FilePath -> Maybe LanguageKind -> Text -> Position -> (Hover -> ExampleT ctx m ()) -> SpecFree ctx m ()
itHasHoverSatisfying name filename maybeLanguageId codeToTest pos cb = it [i|#{name}: #{show codeToTest} (hover)|] $ do
withLspSession name filename codeToTest [] $ \_homeDir -> do
ident <- openDoc filename (fromMaybe name maybeLanguageId)
ident <- openDoc filename (fromMaybe (LanguageKind_Custom name) maybeLanguageId)
getHover ident pos >>= \case
Nothing -> expectationFailure [i|Expected a hover.|]
Just x -> lift $ cb x
Expand Down Expand Up @@ -204,7 +204,7 @@ withLspSession' handleFn name filename codeToTest extraFiles session = do
-- Comment this and use openDoc' to simulate an unsaved document
liftIO $ T.writeFile (homeDir </> filename) codeToTest

let sessionConfig = def { lspConfig = lspConfigInitializationOptions config
let sessionConfig = def { lspConfig = fromMaybe mempty (lspConfigInitializationOptions config)
, logStdErr = True
, logMessages = True
, messageTimeout = 120
Expand Down Expand Up @@ -251,7 +251,7 @@ withLspSession' handleFn name filename codeToTest extraFiles session = do
info [i|LSP command: #{cp}|]

-- We don't support certain server-to-client requests, since the waitForDiagnostics doesn't handle them
let caps = fullCaps
let caps = fullClientCapsForVersion (LSPVersion 3 16)
& set (workspace . _Just . workspaceFolders) Nothing
& set (workspace . _Just . configuration) Nothing
& set (workspace . _Just . didChangeWatchedFiles . _Just . dynamicRegistration) (Just False)
Expand Down Expand Up @@ -314,7 +314,7 @@ allHoverContentsText (InR markedStrings) = case markedStrings of
InR mss -> mconcat $ fmap markedStringToText mss
where
markedStringToText (MarkedString (InL t)) = t
markedStringToText (MarkedString (InR thing)) = thing .! #value
markedStringToText (MarkedString (InR thing)) = thing ^. LSP.value

containsAll :: Text -> [Text] -> Bool
containsAll haystack = Prelude.all (`T.isInfixOf` haystack)
13 changes: 3 additions & 10 deletions tests/stack.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

resolver: lts-22.44
resolver: nightly-2025-12-25

packages:
- .
Expand All @@ -11,21 +11,14 @@ system-ghc: true

extra-deps:
- git: https://github.com/codedownio/lsp.git
commit: 673ff007ce08aed7cf3cf8a5050b4066948afa91
# upgrade-monads-newest-jan2026 branch
commit: d920b28aa25d454812d8d9bbd922e893574d45bc
subdirs:
- lsp
- lsp-test
- lsp-types

- sandwich-0.3.0.3
- sandwich-contexts-0.3.0.1

# Needed by newer sandwich
- vty-windows-0.2.0.0

- ex-pool-0.2.1@sha256:c8249338ced27bc4d6395ad9c3069eec394fb111813d6ec736814d095f7e6a24,1293

- crypton-connection-0.3.1@sha256:4d0958537197956b536ea91718b1749949757022532f50b8f683290056a19021,1581

- git: https://github.com/codedownio/minio-hs
commit: 768665c90321d118fdd3cde2c6ac6c01310d76a0
66 changes: 19 additions & 47 deletions tests/stack.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,79 +5,51 @@

packages:
- completed:
commit: 673ff007ce08aed7cf3cf8a5050b4066948afa91
commit: d920b28aa25d454812d8d9bbd922e893574d45bc
git: https://github.com/codedownio/lsp.git
name: lsp
pantry-tree:
sha256: 9d8370277cc83f157edf368042479b89a770aba92b8aa4072b3426b6b489c12b
size: 1043
sha256: 0463d2462d7690aa877cf2f79279cc1902be006ca7bfcae34da1a56b46c7d00c
size: 1121
subdir: lsp
version: 2.0.0.0
version: 2.7.0.1
original:
commit: 673ff007ce08aed7cf3cf8a5050b4066948afa91
commit: d920b28aa25d454812d8d9bbd922e893574d45bc
git: https://github.com/codedownio/lsp.git
subdir: lsp
- completed:
commit: 673ff007ce08aed7cf3cf8a5050b4066948afa91
commit: d920b28aa25d454812d8d9bbd922e893574d45bc
git: https://github.com/codedownio/lsp.git
name: lsp-test
pantry-tree:
sha256: ae5d36c3d41b027768f7f62c55a8885ba28c2d9674a135c4c98394778a6a06e3
size: 2225
sha256: 3671570067b55febf7903af85164d35aa515851318e69b31f048998e64362c6a
size: 2304
subdir: lsp-test
version: 0.15.0.0
version: 0.17.1.1
original:
commit: 673ff007ce08aed7cf3cf8a5050b4066948afa91
commit: d920b28aa25d454812d8d9bbd922e893574d45bc
git: https://github.com/codedownio/lsp.git
subdir: lsp-test
- completed:
commit: 673ff007ce08aed7cf3cf8a5050b4066948afa91
commit: d920b28aa25d454812d8d9bbd922e893574d45bc
git: https://github.com/codedownio/lsp.git
name: lsp-types
pantry-tree:
sha256: f8617d8aaa142ecc8ce62e0b2d930669d4969b6b9143368d20b1680874b8077c
size: 45522
sha256: 08d01a9208540b71e038e6fb85793a42785b37fa390f6f57df2eba0a5e87fe8e
size: 52176
subdir: lsp-types
version: 2.0.0.1
version: 2.3.0.1
original:
commit: 673ff007ce08aed7cf3cf8a5050b4066948afa91
commit: d920b28aa25d454812d8d9bbd922e893574d45bc
git: https://github.com/codedownio/lsp.git
subdir: lsp-types
- completed:
hackage: sandwich-0.3.0.3@sha256:1cd757d3e7af7aaaa68cf91b125aace3fde87a1a347c25e14e3cbf78282eea99,9221
pantry-tree:
sha256: a583451e9d393700383654d8ab631bf22d246184d29ffdde0745fdc8e549496e
size: 6145
original:
hackage: sandwich-0.3.0.3
- completed:
hackage: sandwich-contexts-0.3.0.1@sha256:de63f120457c084035313f85fe323bc61a172c99a600b134b9322e26ac42a790,3085
pantry-tree:
sha256: f6cad8a7d1ba25e6d602dc67d5ef06243b139c818f2b11cd0fa369b106cdb444
size: 1665
original:
hackage: sandwich-contexts-0.3.0.1
- completed:
hackage: vty-windows-0.2.0.0@sha256:91a11bab7bb79f8ee0d4a8166824ed855251cbac101eed3fdf607ad519a13557,2815
pantry-tree:
sha256: 50d343eb4df5d1901b1773baeaff8ae7c6a88204d0997430e26f0dc50a1a63eb
size: 2160
original:
hackage: vty-windows-0.2.0.0
- completed:
hackage: ex-pool-0.2.1@sha256:c8249338ced27bc4d6395ad9c3069eec394fb111813d6ec736814d095f7e6a24,1293
pantry-tree:
sha256: 863f042cd38e712406ac3ca414eb83e4f2264a71913fca0319d940655ebc873a
size: 253
original:
hackage: ex-pool-0.2.1@sha256:c8249338ced27bc4d6395ad9c3069eec394fb111813d6ec736814d095f7e6a24,1293
- completed:
hackage: crypton-connection-0.3.1@sha256:4d0958537197956b536ea91718b1749949757022532f50b8f683290056a19021,1581
pantry-tree:
sha256: e35ac3a35611afab9fafac633d0c4e6328b9cce4c8262378671d6c5a739e7e70
size: 394
original:
hackage: crypton-connection-0.3.1@sha256:4d0958537197956b536ea91718b1749949757022532f50b8f683290056a19021,1581
- completed:
commit: 768665c90321d118fdd3cde2c6ac6c01310d76a0
git: https://github.com/codedownio/minio-hs
Expand All @@ -91,7 +63,7 @@ packages:
git: https://github.com/codedownio/minio-hs
snapshots:
- completed:
sha256: 238fa745b64f91184f9aa518fe04bdde6552533d169b0da5256670df83a0f1a9
size: 721141
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/44.yaml
original: lts-22.44
sha256: 671a94f04c2cb37457b71c66134242d4b12ab703597c19fad769df2d5e1e5659
size: 715416
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2025/12/25.yaml
original: nightly-2025-12-25
Loading