mirror of
https://github.com/tweag/ormolu.git
synced 2024-09-11 13:16:13 +03:00
Cabal file lookup: fix handling of hs-source-dirs: .
This commit is contained in:
parent
7fc42d1929
commit
84a3f0eaba
@ -6,6 +6,9 @@
|
||||
* Indent closing bracket for list comprehensions in `do` blocks.
|
||||
[Issue 893](https://github.com/tweag/ormolu/issues/893).
|
||||
|
||||
* Fix `hs-source-dirs: .` resulting in failing to find a `.cabal` file for a
|
||||
Haskell source file. [Issue 909](https://github.com/tweag/ormolu/issues/909).
|
||||
|
||||
## Ormolu 0.5.0.0
|
||||
|
||||
* Changed the way operator fixities and precedences are inferred.
|
||||
|
3
data/cabal-tests/Bar.hs
Normal file
3
data/cabal-tests/Bar.hs
Normal file
@ -0,0 +1,3 @@
|
||||
module Foo where
|
||||
|
||||
import Data.List qualified as List
|
3
data/cabal-tests/Foo.hs
Normal file
3
data/cabal-tests/Foo.hs
Normal file
@ -0,0 +1,3 @@
|
||||
module Foo where
|
||||
|
||||
import Data.List qualified as List
|
13
data/cabal-tests/test.cabal
Normal file
13
data/cabal-tests/test.cabal
Normal file
@ -0,0 +1,13 @@
|
||||
cabal-version: 2.4
|
||||
name: test
|
||||
version: 0
|
||||
|
||||
library
|
||||
exposed-modules: Foo
|
||||
hs-source-dirs: .
|
||||
default-extensions: ImportQualifiedPost
|
||||
|
||||
executable app
|
||||
main-is: Main
|
||||
other-modules: Bar
|
||||
default-extensions: ImportQualifiedPost
|
@ -14,6 +14,7 @@ build-type: Simple
|
||||
extra-source-files:
|
||||
data/**/*.hs
|
||||
data/**/*.txt
|
||||
data/**/*.cabal
|
||||
extract-hackage-info/hackage-info.json
|
||||
|
||||
extra-doc-files:
|
||||
|
@ -168,7 +168,7 @@ getExtensionAndDepsMap cabalFile GenericPackageDescription {..} =
|
||||
|
||||
extractFromBuildInfo extraModules BuildInfo {..} = (,(exts, deps)) $ do
|
||||
m <- extraModules ++ (ModuleName.toFilePath <$> otherModules)
|
||||
(takeDirectory cabalFile </>) <$> prependSrcDirs (dropExtensions m)
|
||||
normalise . (takeDirectory cabalFile </>) <$> prependSrcDirs (dropExtensions m)
|
||||
where
|
||||
prependSrcDirs f
|
||||
| null hsSourceDirs = [f]
|
||||
|
@ -42,3 +42,13 @@ spec = do
|
||||
it "extracts correct dependencies from ormolu.cabal (tests/Ormolu/PrinterSpec.hs)" $ do
|
||||
CabalInfo {..} <- parseCabalInfo "ormolu.cabal" "tests/Ormolu/PrinterSpec.hs"
|
||||
ciDependencies `shouldBe` Set.fromList ["QuickCheck", "base", "containers", "directory", "filepath", "ghc-lib-parser", "hspec", "hspec-megaparsec", "megaparsec", "ormolu", "path", "path-io", "temporary", "text"]
|
||||
|
||||
it "handles `hs-source-dirs: .`" $ do
|
||||
CabalInfo {..} <- parseTestCabalInfo "Foo.hs"
|
||||
ciDynOpts `shouldContain` [DynOption "-XImportQualifiedPost"]
|
||||
it "handles empty hs-source-dirs" $ do
|
||||
CabalInfo {..} <- parseTestCabalInfo "Bar.hs"
|
||||
ciDynOpts `shouldContain` [DynOption "-XImportQualifiedPost"]
|
||||
where
|
||||
parseTestCabalInfo f =
|
||||
parseCabalInfo "data/cabal-tests/test.cabal" ("data/cabal-tests" </> f)
|
||||
|
Loading…
Reference in New Issue
Block a user