From 2747a154ccc57c587e39d2885d2fb7c609504033 Mon Sep 17 00:00:00 2001 From: Fendor Date: Fri, 6 Oct 2023 11:49:03 +0200 Subject: [PATCH 01/11] Set the root for tests to the test directory On startup, HLS performs a sanity check to validate the GHC version for the project is the same as the GHC version used to build HLS. Due to some oversights, the tests always use HLS's cabal package to perform this check. This is (almost) valid for the tests but adds overhead for finding the GHC version for each integration test in HLS. Improves the startup time for each integration tests that depends on hls-test-utils. Thus, ghcide test suite is unaffected. Fix `findCradle` invocations to point to a file in the root directory. `findCradle` from hie-bios doesn't work correctly for directories and requires a file, even if that file doesn't exist. --- ghcide/session-loader/Development/IDE/Session.hs | 2 +- hls-test-utils/src/Test/Hls.hs | 1 + src/Ide/Main.hs | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ghcide/session-loader/Development/IDE/Session.hs b/ghcide/session-loader/Development/IDE/Session.hs index 46e41072cd..ab20945847 100644 --- a/ghcide/session-loader/Development/IDE/Session.hs +++ b/ghcide/session-loader/Development/IDE/Session.hs @@ -266,7 +266,7 @@ loadWithImplicitCradle mHieYaml rootDir = do getInitialGhcLibDirDefault :: Recorder (WithPriority Log) -> FilePath -> IO (Maybe LibDir) getInitialGhcLibDirDefault recorder rootDir = do - hieYaml <- findCradle def rootDir + hieYaml <- findCradle def (rootDir "a") cradle <- loadCradle def hieYaml rootDir libDirRes <- getRuntimeGhcLibDir (toCologActionWithPrio (cmapWithPrio LogHieBios recorder)) cradle case libDirRes of diff --git a/hls-test-utils/src/Test/Hls.hs b/hls-test-utils/src/Test/Hls.hs index 0bbdbc0b72..86fd4fcf6e 100644 --- a/hls-test-utils/src/Test/Hls.hs +++ b/hls-test-utils/src/Test/Hls.hs @@ -617,6 +617,7 @@ runSessionWithServer' plugins conf sconf caps root s = withLock lock $ keepCurr , argsDefaultHlsConfig = conf , argsLogger = argsLogger , argsIdeOptions = ideOptions + , argsProjectRoot = Just root } x <- runSessionWithHandles inW outR sconf' caps root s diff --git a/src/Ide/Main.hs b/src/Ide/Main.hs index b6ee489d7c..726eebc524 100644 --- a/src/Ide/Main.hs +++ b/src/Ide/Main.hs @@ -90,7 +90,7 @@ defaultMain recorder args idePlugins = do BiosMode PrintCradleType -> do dir <- IO.getCurrentDirectory - hieYaml <- Session.findCradle def dir + hieYaml <- Session.findCradle def (dir "a") cradle <- Session.loadCradle def hieYaml dir print cradle From c0f7d4c40ba2c63dabcaeb4f49e91a6de8c8a984 Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Thu, 12 Oct 2023 19:48:49 +0100 Subject: [PATCH 02/11] Simplify cabal.project (#3836) - entropy has had bounds revised in - basement/hw-prim bounds empirically unnecessariy - hyphenation was for wingman - bound hlint to a version that uses ghc-lib by default - stylish-haskell has never had a ghc-lib flag - none of the versions of fourmolu that we use have a fixity-th flag - remove some other things that lack justification speculatively --- cabal.project | 53 +++++-------------- haskell-language-server.cabal | 3 ++ .../hls-hlint-plugin/hls-hlint-plugin.cabal | 2 +- shake-bench/shake-bench.cabal | 1 + stack-lts21.yaml | 5 -- stack.yaml | 3 -- 6 files changed, 19 insertions(+), 48 deletions(-) diff --git a/cabal.project b/cabal.project index 121b9ba544..75dbc2656b 100644 --- a/cabal.project +++ b/cabal.project @@ -34,47 +34,26 @@ packages: ./plugins/hls-refactor-plugin ./plugins/hls-overloaded-record-dot-plugin --- Standard location for temporary packages needed for particular environments --- For example it is used in the project gitlab mirror to help in the MAcOS M1 build script --- See https://github.com/haskell/haskell-language-server/blob/master/.gitlab-ci.yml -optional-packages: vendored/*/*.cabal +index-state: 2023-10-06T06:12:29Z tests: True +test-show-details: direct --- mfsolve has duplicate instances in its test suite --- See: https://github.com/kuribas/mfsolve/issues/8 -package mfsolve - tests: False - -package * - ghc-options: -haddock - test-show-details: direct +benchmarks: True write-ghc-environment-files: never -index-state: 2023-10-06T06:12:29Z +-- Make sure dependencies are build with haddock so we get +-- haddock shown on hover +package * + ghc-options: -haddock constraints: -- C++ is hard to distribute, especially on older GHCs -- See https://github.com/haskell/haskell-language-server/issues/3822 text -simdutf, - -- For GHC 9.4, older versions of entropy fail to build on Windows - entropy >= 0.4.1.10, - -- For GHC 9.4 - basement >= 0.0.15, - -- For GHC 9.4 - hw-prim >= 0.6.3.2, - hyphenation +embed, - -- remove this when hlint sets ghc-lib to true by default - -- https://github.com/ndmitchell/hlint/issues/1376 - hlint +ghc-lib, ghc-check -ghc-check-use-package-abis, ghc-lib-parser-ex -auto, - stylish-haskell +ghc-lib, - fourmolu -fixity-th, - setup.happy == 1.20.1.1, - happy == 1.20.1.1, - filepath installed, -- Centos 7 comes with an old gcc version that doesn't know about -- the flag '-fopen-simd', which blocked the release 2.2.0.0. -- We want to be able to benefit from the performance optimisations @@ -94,20 +73,17 @@ source-repository-package tag: 7a0af7a8fd38045fd15fb13445bdcc7085325460 -- END DELETE -allow-newer: - -- ghc-9.4 - ekg-json:base, - ekg-wai:time, - -if impl(ghc >= 9.5) +if impl(ghc >= 9.1) + -- ekg packagess are old and unmaintained, but we + -- don't rely on them for the mainline build, so + -- this is okay allow-newer: - -- ghc-9.6 - ekg-core:ghc-prim, - stm-hamt:transformers, + ekg-json:base, + ekg-wai:time, + ekg-core:ghc-prim if impl(ghc >= 9.7) allow-newer: - -- ghc-9.8 base, template-haskell, ghc, @@ -122,7 +98,6 @@ if impl(ghc >= 9.7) unix, deepseq, -if impl(ghc >= 9.7) repository head.hackage.ghc.haskell.org url: https://ghc.gitlab.haskell.org/head.hackage/ secure: True diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index b5dbc6c685..715950a049 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -570,6 +570,9 @@ test-suite wrapper-test main-is: Main.hs benchmark benchmark + -- Depends on shake-bench which is unbuildable after this point + if impl(ghc >= 9.5) + buildable: False type: exitcode-stdio-1.0 default-language: Haskell2010 ghc-options: -Wall -Wno-name-shadowing -threaded diff --git a/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal b/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal index 3f5972d908..54e6f53d34 100644 --- a/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal +++ b/plugins/hls-hlint-plugin/hls-hlint-plugin.cabal @@ -52,7 +52,7 @@ library , ghc-exactprint >=0.6.3.4 , ghcide == 2.4.0.0 , hashable - , hlint < 3.7 + , hlint >= 3.5 && < 3.7 , hls-plugin-api == 2.4.0.0 , lens , lsp diff --git a/shake-bench/shake-bench.cabal b/shake-bench/shake-bench.cabal index fafccc20c8..c55485963a 100644 --- a/shake-bench/shake-bench.cabal +++ b/shake-bench/shake-bench.cabal @@ -16,6 +16,7 @@ source-repository head location: https://github.com/haskell/haskell-language-server.git library + -- Depends on Chart which is unbuildable after this point if impl(ghc >= 9.5) buildable: False exposed-modules: Development.Benchmark.Rules diff --git a/stack-lts21.yaml b/stack-lts21.yaml index c119576d1f..5f26370a2a 100644 --- a/stack-lts21.yaml +++ b/stack-lts21.yaml @@ -66,11 +66,6 @@ flags: pedantic: true retrie: BuildExecutable: false - # Stack doesn't support automatic flags. - hyphenation: - embed: true - stylish-haskell: - ghc-lib: true nix: packages: [ icu libcxx zlib ] diff --git a/stack.yaml b/stack.yaml index 7a0744226a..bba26fd4b6 100644 --- a/stack.yaml +++ b/stack.yaml @@ -67,9 +67,6 @@ flags: pedantic: true retrie: BuildExecutable: false - # Stack doesn't support automatic flags. - hyphenation: - embed: true nix: packages: [ icu libcxx zlib ] From ec489af495fb0888d1f6f13613ebcc47d387bc61 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Oct 2023 02:23:02 +0000 Subject: [PATCH 03/11] Bump fkirc/skip-duplicate-actions from 5.3.0 to 5.3.1 Bumps [fkirc/skip-duplicate-actions](https://github.com/fkirc/skip-duplicate-actions) from 5.3.0 to 5.3.1. - [Release notes](https://github.com/fkirc/skip-duplicate-actions/releases) - [Commits](https://github.com/fkirc/skip-duplicate-actions/compare/v5.3.0...v5.3.1) --- updated-dependencies: - dependency-name: fkirc/skip-duplicate-actions dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/bench.yml | 2 +- .github/workflows/caching.yml | 2 +- .github/workflows/flags.yml | 2 +- .github/workflows/nix.yml | 4 ++-- .github/workflows/test.yml | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index bd558576d1..3c822b7cf3 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -21,7 +21,7 @@ jobs: should_skip: ${{ steps.skip_check.outputs.should_skip }} steps: - id: skip_check - uses: fkirc/skip-duplicate-actions@v5.3.0 + uses: fkirc/skip-duplicate-actions@v5.3.1 with: cancel_others: false paths_ignore: '[ "**/docs/**" diff --git a/.github/workflows/caching.yml b/.github/workflows/caching.yml index 76bf204d82..96616cc4b4 100644 --- a/.github/workflows/caching.yml +++ b/.github/workflows/caching.yml @@ -62,7 +62,7 @@ jobs: - id: ghcs run: echo "ghcs=$(cat ./.github/workflows/supported-ghc-versions.json)" >> $GITHUB_OUTPUT - id: skip_check - uses: fkirc/skip-duplicate-actions@v5.3.0 + uses: fkirc/skip-duplicate-actions@v5.3.1 with: cancel_others: false paths_ignore: '["**/docs/**" diff --git a/.github/workflows/flags.yml b/.github/workflows/flags.yml index f00af915f1..52d971a046 100644 --- a/.github/workflows/flags.yml +++ b/.github/workflows/flags.yml @@ -26,7 +26,7 @@ jobs: - id: ghcs run: echo "ghcs=$(cat ./.github/workflows/supported-ghc-versions.json)" >> $GITHUB_OUTPUT - id: skip_check - uses: fkirc/skip-duplicate-actions@v5.3.0 + uses: fkirc/skip-duplicate-actions@v5.3.1 with: cancel_others: false paths_ignore: '[ "**/docs/**" diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index c1cc7013e0..064d8f59f3 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -21,7 +21,7 @@ jobs: should_skip_build: ${{ steps.skip_check_no_nix.outputs.should_skip }} steps: - id: skip_check - uses: fkirc/skip-duplicate-actions@v5.3.0 + uses: fkirc/skip-duplicate-actions@v5.3.1 with: cancel_others: false paths_ignore: '[ "**/docs/**" @@ -36,7 +36,7 @@ jobs: , ".gitlab/**" ]' - id: skip_check_no_nix - uses: fkirc/skip-duplicate-actions@v5.3.0 + uses: fkirc/skip-duplicate-actions@v5.3.1 with: cancel_others: false paths: '[ "**.nix" ]' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b5180353b2..48d0668db9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,7 +27,7 @@ jobs: - id: ghcs run: echo "ghcs=$(cat ./.github/workflows/supported-ghc-versions.json)" >> $GITHUB_OUTPUT - id: skip_check - uses: fkirc/skip-duplicate-actions@v5.3.0 + uses: fkirc/skip-duplicate-actions@v5.3.1 with: cancel_others: false paths_ignore: '[ "**/docs/**" @@ -45,7 +45,7 @@ jobs: ]' # If we only change ghcide downstream packages we have not test ghcide itself - id: skip_ghcide_check - uses: fkirc/skip-duplicate-actions@v5.3.0 + uses: fkirc/skip-duplicate-actions@v5.3.1 with: cancel_others: false paths_ignore: '[ "hls-test-utils/**" From ed4e9fd725ce498aade0182a0fc89c61c323ac8a Mon Sep 17 00:00:00 2001 From: George Thomas Date: Sun, 29 Oct 2023 10:11:16 +0000 Subject: [PATCH 04/11] Remove redundant imports and extensions --- plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs b/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs index 68fd1b2017..0e8fe0682d 100644 --- a/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs +++ b/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs @@ -1,6 +1,5 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} -{-# LANGUAGE DisambiguateRecordFields #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE OverloadedLabels #-} @@ -15,11 +14,11 @@ module Ide.Plugin.Fourmolu ( LogEvent, ) where -import Control.Exception (IOException, handle, try) +import Control.Exception (IOException, handle) import Control.Lens ((^.)) import Control.Monad (guard) import Control.Monad.Error.Class (MonadError (throwError)) -import Control.Monad.Trans.Except (ExceptT (..), mapExceptT, +import Control.Monad.Trans.Except (ExceptT (..), runExceptT) import Control.Monad.IO.Class (MonadIO (liftIO)) From 496acde5bd6cf68791e233efd04e1e996b1361f9 Mon Sep 17 00:00:00 2001 From: George Thomas Date: Sun, 29 Oct 2023 21:20:05 +0000 Subject: [PATCH 05/11] Use `refineConfig` to load default fixities in Fourmolu --- plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs b/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs index 0e8fe0682d..84118ce089 100644 --- a/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs +++ b/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs @@ -95,7 +95,7 @@ provider recorder plId ideState typ contents fp fo = ExceptT $ withIndefinitePro errorMessage = "Failed to load " <> T.pack f <> ": " <> T.pack (show err) let config = - defaultConfig + refineConfig ModuleSource Nothing Nothing Nothing defaultConfig { cfgDynOptions = map DynOption fileOpts , cfgFixityOverrides = cfgFileFixities , cfgRegion = region From e03653731503fcc039b36437b1a322bb730db4f5 Mon Sep 17 00:00:00 2001 From: George Thomas Date: Sun, 29 Oct 2023 21:54:15 +0000 Subject: [PATCH 06/11] Format --- .../src/Ide/Plugin/Fourmolu.hs | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs b/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs index 84118ce089..5791fe59cf 100644 --- a/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs +++ b/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs @@ -1,12 +1,12 @@ -{-# LANGUAGE CPP #-} -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE OverloadedLabels #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE TypeApplications #-} -{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE CPP #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE OverloadedLabels #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeOperators #-} module Ide.Plugin.Fourmolu ( descriptor, @@ -18,9 +18,7 @@ import Control.Exception (IOException, handle) import Control.Lens ((^.)) import Control.Monad (guard) import Control.Monad.Error.Class (MonadError (throwError)) -import Control.Monad.Trans.Except (ExceptT (..), - runExceptT) - +import Control.Monad.Trans.Except (ExceptT (..), runExceptT) import Control.Monad.IO.Class (MonadIO (liftIO)) import Control.Monad.Trans.Class (MonadTrans (lift)) import Data.Bifunctor (bimap) From 7124b9d377fd906ce857537ba70c980df68ae98e Mon Sep 17 00:00:00 2001 From: George Thomas Date: Sun, 29 Oct 2023 21:54:29 +0000 Subject: [PATCH 07/11] Fix GHC 9.2 --- plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs b/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs index 5791fe59cf..8fcde79282 100644 --- a/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs +++ b/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs @@ -14,7 +14,7 @@ module Ide.Plugin.Fourmolu ( LogEvent, ) where -import Control.Exception (IOException, handle) +import Control.Exception import Control.Lens ((^.)) import Control.Monad (guard) import Control.Monad.Error.Class (MonadError (throwError)) From a603bd3e2b042ab8da96a70288d11155294bd3a9 Mon Sep 17 00:00:00 2001 From: George Thomas Date: Sun, 29 Oct 2023 22:13:54 +0000 Subject: [PATCH 08/11] Format --- plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs b/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs index 8fcde79282..dad2e21814 100644 --- a/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs +++ b/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs @@ -18,9 +18,9 @@ import Control.Exception import Control.Lens ((^.)) import Control.Monad (guard) import Control.Monad.Error.Class (MonadError (throwError)) -import Control.Monad.Trans.Except (ExceptT (..), runExceptT) import Control.Monad.IO.Class (MonadIO (liftIO)) import Control.Monad.Trans.Class (MonadTrans (lift)) +import Control.Monad.Trans.Except (ExceptT (..), runExceptT) import Data.Bifunctor (bimap) import Data.List (intercalate) import Data.Maybe (catMaybes) From a2c339afddfb1032d608af464fa0384d2ff9e679 Mon Sep 17 00:00:00 2001 From: George Thomas Date: Sun, 29 Oct 2023 22:19:13 +0000 Subject: [PATCH 09/11] Fix build on old Fourmolu versions --- plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs b/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs index dad2e21814..c125c5e957 100644 --- a/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs +++ b/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs @@ -93,7 +93,10 @@ provider recorder plId ideState typ contents fp fo = ExceptT $ withIndefinitePro errorMessage = "Failed to load " <> T.pack f <> ": " <> T.pack (show err) let config = - refineConfig ModuleSource Nothing Nothing Nothing defaultConfig +#if MIN_VERSION_fourmolu(0,13,0) + refineConfig ModuleSource Nothing Nothing Nothing +#endif + defaultConfig { cfgDynOptions = map DynOption fileOpts , cfgFixityOverrides = cfgFileFixities , cfgRegion = region From 71cc7b019aeee91cb5e7dfb37f64cfcd7e7205da Mon Sep 17 00:00:00 2001 From: George Thomas Date: Mon, 30 Oct 2023 23:57:35 +0000 Subject: [PATCH 10/11] Avoid pattern match warning --- plugins/hls-fourmolu-plugin/test/Main.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/hls-fourmolu-plugin/test/Main.hs b/plugins/hls-fourmolu-plugin/test/Main.hs index 875720c826..1e6ab5eaea 100644 --- a/plugins/hls-fourmolu-plugin/test/Main.hs +++ b/plugins/hls-fourmolu-plugin/test/Main.hs @@ -4,6 +4,7 @@ module Main ) where import Data.Aeson +import qualified Data.Aeson.KeyMap as KM import Data.Functor import Ide.Plugin.Config import qualified Ide.Plugin.Fourmolu as Fourmolu @@ -33,7 +34,7 @@ tests = goldenWithFourmolu :: Bool -> TestName -> FilePath -> FilePath -> (TextDocumentIdentifier -> Session ()) -> TestTree goldenWithFourmolu cli title path desc = goldenWithHaskellDocFormatter def fourmoluPlugin "fourmolu" conf title testDataDir path desc "hs" where - conf = def{plcConfig = (\(Object obj) -> obj) $ object ["external" .= cli]} + conf = def{plcConfig = KM.fromList ["external" .= cli]} testDataDir :: FilePath testDataDir = "test" "testdata" From 1c55cb4a478b2920c727652aeda238e80ae9fb54 Mon Sep 17 00:00:00 2001 From: George Thomas Date: Tue, 31 Oct 2023 00:09:35 +0000 Subject: [PATCH 11/11] Add regression test for Fourmolu fixities --- plugins/hls-fourmolu-plugin/test/Main.hs | 2 ++ .../test/testdata/Fourmolu3.formatted.hs | 7 +++++++ plugins/hls-fourmolu-plugin/test/testdata/Fourmolu3.hs | 6 ++++++ 3 files changed, 15 insertions(+) create mode 100644 plugins/hls-fourmolu-plugin/test/testdata/Fourmolu3.formatted.hs create mode 100644 plugins/hls-fourmolu-plugin/test/testdata/Fourmolu3.hs diff --git a/plugins/hls-fourmolu-plugin/test/Main.hs b/plugins/hls-fourmolu-plugin/test/Main.hs index 1e6ab5eaea..36d462b833 100644 --- a/plugins/hls-fourmolu-plugin/test/Main.hs +++ b/plugins/hls-fourmolu-plugin/test/Main.hs @@ -29,6 +29,8 @@ tests = formatDoc doc (FormattingOptions 4 True Nothing Nothing Nothing) , goldenWithFourmolu cli "formats imports correctly" "Fourmolu2" "formatted" $ \doc -> do formatDoc doc (FormattingOptions 4 True Nothing Nothing Nothing) + , goldenWithFourmolu cli "uses correct operator fixities" "Fourmolu3" "formatted" $ \doc -> do + formatDoc doc (FormattingOptions 4 True Nothing Nothing Nothing) ] goldenWithFourmolu :: Bool -> TestName -> FilePath -> FilePath -> (TextDocumentIdentifier -> Session ()) -> TestTree diff --git a/plugins/hls-fourmolu-plugin/test/testdata/Fourmolu3.formatted.hs b/plugins/hls-fourmolu-plugin/test/testdata/Fourmolu3.formatted.hs new file mode 100644 index 0000000000..ca766959cc --- /dev/null +++ b/plugins/hls-fourmolu-plugin/test/testdata/Fourmolu3.formatted.hs @@ -0,0 +1,7 @@ +b :: Bool +b = + id $ + id $ + case True && True of + True -> True + False -> False diff --git a/plugins/hls-fourmolu-plugin/test/testdata/Fourmolu3.hs b/plugins/hls-fourmolu-plugin/test/testdata/Fourmolu3.hs new file mode 100644 index 0000000000..fafe4da859 --- /dev/null +++ b/plugins/hls-fourmolu-plugin/test/testdata/Fourmolu3.hs @@ -0,0 +1,6 @@ +b :: Bool +b = + id $ id $ + case True && True of + True -> True + False -> False