hls-test-utils-2.9.0.0: Utilities used in the tests of Haskell Language Server
Safe HaskellSafe-Inferred
LanguageGHC2021

Test.Hls.FileSystem

Synopsis

Documentation

data FileSystem Source #

Representation of a VirtualFileTree that has been materialised to disk.

Constructors

FileSystem 

data VirtualFileTree Source #

Virtual representation of a filesystem tree.

Operations of vftTree are relative to vftOriginalRoot. In particular, any copy etc. operation looks for the sources in vftOriginalRoot.

To persist a VirtualFileTree, look at materialise and materialiseVFT.

data FileTree Source #

Instances

Instances details
Show FileTree Source # 
Instance details

Defined in Test.Hls.FileSystem

Eq FileTree Source # 
Instance details

Defined in Test.Hls.FileSystem

Ord FileTree Source # 
Instance details

Defined in Test.Hls.FileSystem

data Content Source #

Instances

Instances details
Show Content Source # 
Instance details

Defined in Test.Hls.FileSystem

Eq Content Source # 
Instance details

Defined in Test.Hls.FileSystem

Methods

(==) :: Content -> Content -> Bool #

(/=) :: Content -> Content -> Bool #

Ord Content Source # 
Instance details

Defined in Test.Hls.FileSystem

init

materialise :: FilePath -> [FileTree] -> FilePath -> IO FileSystem Source #

Materialise a virtual file tree in the rootDir directory.

Synopsis: materialise rootDir fileTree testDataDir

File references in '[FileTree]' are resolved relative to the testDataDir.

materialiseVFT :: FilePath -> VirtualFileTree -> IO FileSystem Source #

Materialise a virtual file tree in the rootDir directory.

Synopsis: materialiseVFT rootDir virtualFileTree

File references in virtualFileTree are resolved relative to the vftOriginalRoot.

Interaction

Test helpers

Builders

file :: FilePath -> Content -> FileTree Source #

Create a file in the test project with some content.

Only the filename will be used, and any directory components are *not* reflected in the test project.

copy :: FilePath -> FileTree Source #

Copy a filepath into a test project. The name of the file is also used in the test project.

The filepath is always resolved to the root of the test data dir.

text :: Text -> Content Source #

Write the given test directly into a file.

ref :: FilePath -> Content Source #

Read the contents of the given file The filepath is always resolved to the root of the test data dir.

copyDir :: FilePath -> FileTree Source #

Copy a directory into a test project. The filepath is always resolved to the root of the test data dir.

Cradle helpers

directCradle :: [Text] -> FileTree Source #

Set up a simple direct cradle.

All arguments are added to the direct cradle file. Arguments will not be escaped.

simpleCabalCradle :: FileTree Source #

Set up a simple cabal cradle.

Prefer simple cabal cradle, over custom multi cabal cradles if possible.

Full project setups

directProject :: FilePath -> [FileTree] Source #

Set up a test project with a single haskell file.

directProjectMulti :: [FilePath] -> [FileTree] Source #

Set up a test project with multiple haskell files.

simpleCabalProject :: [FilePath] -> [FileTree] Source #

Set up a simple cabal cradle project and copy all the given filepaths into the test directory.

simpleCabalProject' :: [FileTree] -> [FileTree] Source #

Set up a simple cabal cradle project.