Skip to content

Delete testUtil from ghcide-tests #4272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 2, 2024
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
9 changes: 0 additions & 9 deletions ghcide/test/exe/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import Control.Lens.Setter ((.~))
import Data.Foldable (traverse_)
import Data.Function ((&))
import qualified Data.Text as T
import Development.IDE (Pretty)
import Development.IDE.Test (canonicalizeUri)
import Ide.Types (defaultPluginDescriptor)
import qualified Language.LSP.Protocol.Lens as L
Expand Down Expand Up @@ -90,20 +89,12 @@ testWithExtraFiles testName dirName action = testCase testName $ runWithExtraFil
runInDir :: FilePath -> Session a -> IO a
runInDir fs = runSessionWithServer def dummyPlugin fs

testSession' :: TestName -> (FilePath -> Session ()) -> TestTree
testSession' name = testCase name . run'

run :: Session a -> IO a
run = runSessionWithTestConfig def
{ testDirLocation = Right (mkIdeTestFs [])
, testPluginDescriptor = dummyPlugin }
. const

run' :: (FilePath -> Session a) -> IO a
run' = runSessionWithTestConfig def
{ testDirLocation = Right (mkIdeTestFs [])
, testPluginDescriptor = dummyPlugin }

pattern R :: UInt -> UInt -> UInt -> UInt -> Range
pattern R x y x' y' = Range (Position x y) (Position x' y')

Expand Down
1 change: 0 additions & 1 deletion ghcide/test/exe/CradleTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import System.FilePath
import System.IO.Extra hiding (withTempDir)
-- import Test.QuickCheck.Instances ()
import Config
import Config (checkDefs, mkL)
import Control.Lens ((^.))
import Development.IDE.Plugin.Test (WaitForIdeRuleResult (..))
import GHC.TypeLits (symbolVal)
Expand Down
24 changes: 23 additions & 1 deletion ghcide/test/exe/NonLspCommandLine.hs
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@

module NonLspCommandLine (tests) where

import Control.Monad ((>=>))
import Data.Foldable (for_)
import Development.IDE.Test.Runfiles
import Development.Shake (getDirectoryFilesIO)
import System.Directory (copyFile,
createDirectoryIfMissing)
import System.Directory.Extra (canonicalizePath)
import System.Environment.Blank (setEnv)
import System.Exit (ExitCode (ExitSuccess))
import System.FilePath (takeDirectory, (</>))
import qualified System.IO.Extra
import System.Process.Extra (CreateProcess (cwd), proc,
readCreateProcessWithExitCode)
import Test.Tasty
import Test.Tasty.HUnit
import TestUtils


-- A test to ensure that the command line ghcide workflow stays working
Expand All @@ -25,3 +32,18 @@ tests = testGroup "ghcide command line"

ec @?= ExitSuccess
]

-- | Version of 'System.IO.Extra.withTempDir' that canonicalizes the path
-- Which we need to do on macOS since the $TMPDIR can be in @/private/var@ or
-- @/var@
withTempDir :: (FilePath -> IO a) -> IO a
withTempDir f = System.IO.Extra.withTempDir $ canonicalizePath >=> f


copyTestDataFiles :: FilePath -> FilePath -> IO ()
copyTestDataFiles dir prefix = do
-- Copy all the test data files to the temporary workspace
testDataFiles <- getDirectoryFilesIO ("ghcide/test/data" </> prefix) ["//*"]
for_ testDataFiles $ \f -> do
createDirectoryIfMissing True $ dir </> takeDirectory f
copyFile ("ghcide/test/data" </> prefix </> f) (dir </> f)
197 changes: 0 additions & 197 deletions ghcide/test/exe/TestUtils.hs

This file was deleted.

1 change: 0 additions & 1 deletion haskell-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -2175,7 +2175,6 @@ test-suite ghcide-tests
RootUriTests
SafeTests
SymlinkTests
TestUtils
THTests
UnitTests
WatchedFileTests
Expand Down
Loading