Skip to content

Commit

Permalink
Merge branch 'master' into soulomoon/revert-removal-of-withLongTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
soulomoon authored Jun 1, 2024
2 parents 47a61dc + 00b6d36 commit 004ad96
Show file tree
Hide file tree
Showing 19 changed files with 700 additions and 332 deletions.
1 change: 1 addition & 0 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ on:
jobs:
pre_job:
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'performance')
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
Expand Down
6 changes: 5 additions & 1 deletion ghcide/src/Development/IDE/Plugin/Completions/Logic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module Development.IDE.Plugin.Completions.Logic (
, getCompletions
, fromIdentInfo
, getCompletionPrefix
, getCompletionPrefixFromRope
) where

import Control.Applicative
Expand Down Expand Up @@ -897,7 +898,10 @@ mergeListsBy cmp all_lists = merge_lists all_lists

-- |From the given cursor position, gets the prefix module or record for autocompletion
getCompletionPrefix :: Position -> VFS.VirtualFile -> PosPrefixInfo
getCompletionPrefix pos@(Position l c) (VFS.VirtualFile _ _ ropetext) =
getCompletionPrefix pos (VFS.VirtualFile _ _ ropetext) = getCompletionPrefixFromRope pos ropetext

getCompletionPrefixFromRope :: Position -> Rope.Rope -> PosPrefixInfo
getCompletionPrefixFromRope pos@(Position l c) ropetext =
fromMaybe (PosPrefixInfo "" "" "" pos) $ do -- Maybe monad
let headMaybe = listToMaybe
lastMaybe = headMaybe . reverse
Expand Down
18 changes: 1 addition & 17 deletions ghcide/test/exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,7 @@

module Main (main) where
-- import Test.QuickCheck.Instances ()
import Data.Function ((&))
import qualified HieDbRetry
import Ide.Logger (Pretty (pretty),
Priority (Debug),
WithPriority (WithPriority, priority),
cfilter, cmapWithPrio,
makeDefaultStderrRecorder)
import Test.Tasty
import Test.Tasty.Ingredients.Rerun

Expand All @@ -48,7 +42,6 @@ import CompletionTests
import CPPTests
import CradleTests
import DependentFileTest
import Development.IDE (LoggingColumn (..))
import DiagnosticTests
import ExceptionTests
import FindDefinitionAndHoverTests
Expand All @@ -74,15 +67,6 @@ import WatchedFileTests

main :: IO ()
main = do
docWithPriorityRecorder <- makeDefaultStderrRecorder (Just [ThreadIdColumn, PriorityColumn, DataColumn])

let docWithFilteredPriorityRecorder =
docWithPriorityRecorder
& cfilter (\WithPriority{ priority } -> priority >= Debug)

let recorder = docWithFilteredPriorityRecorder
& cmapWithPrio pretty

-- We mess with env vars so run single-threaded.
defaultMainWithRerun $ testGroup "ghcide"
[ OpenCloseTest.tests
Expand All @@ -99,7 +83,7 @@ main = do
, THTests.tests
, SymlinkTests.tests
, SafeTests.tests
, UnitTests.tests recorder
, UnitTests.tests
, HaddockTests.tests
, PositionMappingTests.tests
, WatchedFileTests.tests
Expand Down
4 changes: 2 additions & 2 deletions ghcide/test/exe/SafeTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import qualified Data.Text as T
import Development.IDE.Test (expectNoMoreDiagnostics)
import Language.LSP.Test

import Config
import Test.Tasty
import TestUtils

tests :: TestTree
tests =
testGroup
"SafeHaskell"
[ -- Test for https://github.com/haskell/ghcide/issues/424
testSessionWait "load" $ do
testWithDummyPluginEmpty "load" $ do
let sourceA =
T.unlines
["{-# LANGUAGE Trustworthy #-}"
Expand Down
2 changes: 1 addition & 1 deletion ghcide/test/exe/SymlinkTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import Language.LSP.Test
import System.Directory
import System.FilePath

import Config
import Test.Tasty
import Test.Tasty.HUnit
import TestUtils

-- | Tests for projects that use symbolic links one way or another
tests :: TestTree
Expand Down
10 changes: 3 additions & 7 deletions ghcide/test/exe/UnitTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ import Data.List.Extra
import Data.String (IsString (fromString))
import qualified Data.Text as T
import Development.IDE.Core.FileStore (getModTime)
import qualified Development.IDE.Main as IDE
import qualified Development.IDE.Plugin.HLS.GhcIde as Ghcide
import qualified Development.IDE.Types.Diagnostics as Diagnostics
import Development.IDE.Types.Location
import qualified FuzzySearch
import Ide.Logger (Recorder, WithPriority,
cmapWithPrio)
import Ide.Logger (Recorder, WithPriority)
import Ide.PluginUtils (pluginDescToIdePlugins)
import Ide.Types
import Language.LSP.Protocol.Message
Expand All @@ -26,7 +24,6 @@ import Language.LSP.Protocol.Types hiding
SemanticTokensEdit (..),
mkRange)
import Language.LSP.Test
import LogType (Log (..))
import Network.URI
import qualified Progress
import System.IO.Extra hiding (withTempDir)
Expand All @@ -37,11 +34,10 @@ import Test.Hls (IdeState, def,
import Test.Tasty
import Test.Tasty.ExpectedFailure
import Test.Tasty.HUnit
import TestUtils
import Text.Printf (printf)

tests :: Recorder (WithPriority Log) -> TestTree
tests recorder = do
tests :: TestTree
tests = do
testGroup "Unit"
[ testCase "empty file path does NOT work with the empty String literal" $
uriToFilePath' (fromNormalizedUri $ filePathToUri' "") @?= Just "."
Expand Down
8 changes: 4 additions & 4 deletions ghcide/test/exe/WatchedFileTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

module WatchedFileTests (tests) where

import Config (testWithDummyPluginEmpty')
import Control.Applicative.Combinators
import Control.Monad.IO.Class (liftIO)
import qualified Data.Aeson as A
Expand All @@ -19,12 +20,11 @@ import System.Directory
import System.FilePath
import Test.Tasty
import Test.Tasty.HUnit
import TestUtils

tests :: TestTree
tests = testGroup "watched files"
[ testGroup "Subscriptions"
[ testSession' "workspace files" $ \sessionDir -> do
[ testWithDummyPluginEmpty' "workspace files" $ \sessionDir -> do
liftIO $ writeFile (sessionDir </> "hie.yaml") "cradle: {direct: {arguments: [\"-isrc\", \"A\", \"WatchedFilesMissingModule\"]}}"
_doc <- createDoc "A.hs" "haskell" "{-#LANGUAGE NoImplicitPrelude #-}\nmodule A where\nimport WatchedFilesMissingModule"
setIgnoringRegistrationRequests False
Expand All @@ -33,7 +33,7 @@ tests = testGroup "watched files"
-- Expect 2 subscriptions: one for all .hs files and one for the hie.yaml cradle
liftIO $ length watchedFileRegs @?= 2

, testSession' "non workspace file" $ \sessionDir -> do
, testWithDummyPluginEmpty' "non workspace file" $ \sessionDir -> do
tmpDir <- liftIO getTemporaryDirectory
let yaml = "cradle: {direct: {arguments: [\"-i" <> tail(init(show tmpDir)) <> "\", \"A\", \"WatchedFilesMissingModule\"]}}"
liftIO $ writeFile (sessionDir </> "hie.yaml") yaml
Expand All @@ -48,7 +48,7 @@ tests = testGroup "watched files"
]
, testGroup "Changes"
[
testSession' "workspace files" $ \sessionDir -> do
testWithDummyPluginEmpty' "workspace files" $ \sessionDir -> do
liftIO $ writeFile (sessionDir </> "hie.yaml") "cradle: {direct: {arguments: [\"-isrc\", \"A\", \"B\"]}}"
liftIO $ writeFile (sessionDir </> "B.hs") $ unlines
["module B where"
Expand Down
1 change: 1 addition & 0 deletions haskell-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ library hls-cabal-plugin
Ide.Plugin.Cabal.Completion.Data
Ide.Plugin.Cabal.Completion.Types
Ide.Plugin.Cabal.LicenseSuggest
Ide.Plugin.Cabal.Orphans
Ide.Plugin.Cabal.Parse


Expand Down
2 changes: 2 additions & 0 deletions hls-test-utils/hls-test-utils.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ library
, lsp
, lsp-test ^>=0.17
, lsp-types ^>=2.2
, neat-interpolation
, safe-exceptions
, tasty
, tasty-expected-failure
Expand All @@ -57,6 +58,7 @@ library
, tasty-rerun
, temporary
, text
, text-rope

ghc-options:
-Wall
Expand Down
Loading

0 comments on commit 004ad96

Please sign in to comment.