mirror of
https://github.com/sol/hpack.git
synced 2024-10-04 03:38:00 +03:00
package.yaml -> package.yml
This commit is contained in:
parent
f5d6d9ef17
commit
270875c8ad
16
hpack.cabal
16
hpack.cabal
@ -1,4 +1,4 @@
|
||||
-- This file has been generated from package.yaml by hpack version 0.1.2.
|
||||
-- This file has been generated from package.yml by hpack version 0.1.2.
|
||||
--
|
||||
-- see: https://github.com/sol/hpack
|
||||
|
||||
@ -18,8 +18,12 @@ source-repository head
|
||||
location: https://github.com/sol/hpack
|
||||
|
||||
executable hpack
|
||||
hs-source-dirs: driver, src
|
||||
hs-source-dirs: src, driver
|
||||
main-is: Main.hs
|
||||
other-modules:
|
||||
Config
|
||||
Run
|
||||
Util
|
||||
build-depends:
|
||||
aeson >= 0.8
|
||||
, base == 4.*
|
||||
@ -35,16 +39,16 @@ executable hpack
|
||||
|
||||
test-suite spec
|
||||
type: exitcode-stdio-1.0
|
||||
hs-source-dirs: test, src
|
||||
hs-source-dirs: src, test
|
||||
main-is: Spec.hs
|
||||
other-modules:
|
||||
Config
|
||||
Run
|
||||
Util
|
||||
ConfigSpec
|
||||
Helper
|
||||
RunSpec
|
||||
UtilSpec
|
||||
Config
|
||||
Run
|
||||
Util
|
||||
build-depends:
|
||||
aeson >= 0.8
|
||||
, base == 4.*
|
||||
|
@ -18,17 +18,17 @@ dependencies:
|
||||
- unordered-containers
|
||||
- yaml
|
||||
|
||||
source-dirs: src
|
||||
|
||||
executables:
|
||||
hpack:
|
||||
main: Main.hs
|
||||
source-dirs: driver, src
|
||||
source-dirs: driver
|
||||
|
||||
tests:
|
||||
spec:
|
||||
main: Spec.hs
|
||||
source-dirs:
|
||||
- test
|
||||
- src
|
||||
source-dirs: test
|
||||
dependencies:
|
||||
- hspec == 2.*
|
||||
- mockery
|
@ -132,7 +132,9 @@ readPackageConfig file = do
|
||||
where
|
||||
errToString err = file ++ case err of
|
||||
AesonException e -> ": " ++ e
|
||||
InvalidYaml (Just e) -> let loc = yamlProblemMark e in ":" ++ show (yamlLine loc) ++ ":" ++ show (yamlColumn loc) ++ ": " ++ yamlProblem e ++ " " ++ yamlContext e
|
||||
InvalidYaml (Just (YamlException s)) -> ": " ++ s
|
||||
InvalidYaml (Just (YamlParseException{..})) -> ":" ++ show yamlLine ++ ":" ++ show yamlColumn ++ ": " ++ yamlProblem ++ " " ++ yamlContext
|
||||
where YamlMark{..} = yamlProblemMark
|
||||
_ -> ": " ++ show err
|
||||
|
||||
type Dependency = String
|
||||
|
@ -16,7 +16,7 @@ import Util
|
||||
import Config
|
||||
|
||||
configFile :: FilePath
|
||||
configFile = "package.yaml"
|
||||
configFile = "package.yml"
|
||||
|
||||
run :: IO ([String], FilePath, String)
|
||||
run = do
|
||||
|
@ -30,255 +30,255 @@ spec :: Spec
|
||||
spec = around_ (inTempDirectoryNamed "foo") $ do
|
||||
describe "readPackageConfig" $ do
|
||||
it "warns on unknown fields" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
bar: 23
|
||||
baz: 42
|
||||
|]
|
||||
fmap fst <$> readPackageConfig "package.yaml" `shouldReturn` Right [
|
||||
fmap fst <$> readPackageConfig "package.yml" `shouldReturn` Right [
|
||||
"Ignoring unknown field \"bar\" in package description"
|
||||
, "Ignoring unknown field \"baz\" in package description"
|
||||
]
|
||||
|
||||
it "accepts name" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
name: bar
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
c `shouldBe` package {packageName = "bar"}
|
||||
|
||||
it "accepts version" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
version: 0.1.0
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
c `shouldBe` package {packageVersion = "0.1.0"}
|
||||
|
||||
it "accepts synopsis" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
synopsis: some synopsis
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
c `shouldBe` package {packageSynopsis = Just "some synopsis"}
|
||||
|
||||
it "accepts description" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
description: some description
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
c `shouldBe` package {packageDescription = Just "some description"}
|
||||
|
||||
it "accepts category" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
category: Data
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
c `shouldBe` package {packageCategory = Just "Data"}
|
||||
|
||||
it "accepts author" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
author: John Doe
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
c `shouldBe` package {packageAuthor = ["John Doe"]}
|
||||
|
||||
it "accepts maintainer" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
maintainer: John Doe <john.doe@example.com>
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
c `shouldBe` package {packageMaintainer = ["John Doe <john.doe@example.com>"]}
|
||||
|
||||
it "accepts copyright" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
copyright: (c) 2015 John Doe
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
c `shouldBe` package {packageCopyright = ["(c) 2015 John Doe"]}
|
||||
|
||||
it "accepts stability" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
stability: experimental
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
packageStability c `shouldBe` Just "experimental"
|
||||
|
||||
it "accepts homepage URL" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
github: hspec/hspec
|
||||
homepage: https://example.com/
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
packageHomepage c `shouldBe` Just "https://example.com/"
|
||||
|
||||
it "infers homepage URL from github" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
github: hspec/hspec
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
packageHomepage c `shouldBe` Just "https://github.com/hspec/hspec#readme"
|
||||
|
||||
it "omits homepage URL if it is null" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
github: hspec/hspec
|
||||
homepage: null
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
packageHomepage c `shouldBe` Nothing
|
||||
|
||||
it "accepts bug-reports URL" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
github: hspec/hspec
|
||||
bug-reports: https://example.com/issues
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
packageBugReports c `shouldBe` Just "https://example.com/issues"
|
||||
|
||||
it "infers bug-reports URL from github" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
github: hspec/hspec
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
packageBugReports c `shouldBe` Just "https://github.com/hspec/hspec/issues"
|
||||
|
||||
it "omits bug-reports URL if it is null" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
github: hspec/hspec
|
||||
bug-reports: null
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
packageBugReports c `shouldBe` Nothing
|
||||
|
||||
it "accepts license" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
license: MIT
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
c `shouldBe` package {packageLicense = Just "MIT"}
|
||||
|
||||
it "infers license file" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
name: foo
|
||||
|]
|
||||
touch "LICENSE"
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
c `shouldBe` package {packageLicenseFile = Just "LICENSE"}
|
||||
|
||||
it "accepts extra-source-files" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
extra-source-files:
|
||||
- CHANGES.markdown
|
||||
- README.markdown
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
packageExtraSourceFiles c `shouldBe` ["CHANGES.markdown", "README.markdown"]
|
||||
|
||||
it "accepts github" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
github: hspec/hspec
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
packageSourceRepository c `shouldBe` Just "https://github.com/hspec/hspec"
|
||||
|
||||
context "when reading library section" $ do
|
||||
it "warns on unknown fields" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
library:
|
||||
bar: 23
|
||||
baz: 42
|
||||
|]
|
||||
|
||||
fmap fst <$> readPackageConfig "package.yaml" `shouldReturn` Right [
|
||||
fmap fst <$> readPackageConfig "package.yml" `shouldReturn` Right [
|
||||
"Ignoring unknown field \"bar\" in library section"
|
||||
, "Ignoring unknown field \"baz\" in library section"
|
||||
]
|
||||
|
||||
it "accepts source-dirs" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
library:
|
||||
source-dirs:
|
||||
- foo
|
||||
- bar
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
packageLibrary c `shouldBe` Just library {librarySourceDirs = ["foo", "bar"]}
|
||||
|
||||
it "accepts default-extensions" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
library:
|
||||
default-extensions:
|
||||
- Foo
|
||||
- Bar
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
packageLibrary c `shouldBe` Just library {libraryDefaultExtensions = ["Foo", "Bar"]}
|
||||
|
||||
it "accepts global default-extensions" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
default-extensions:
|
||||
- Foo
|
||||
- Bar
|
||||
library: {}
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
packageLibrary c `shouldBe` Just library {libraryDefaultExtensions = ["Foo", "Bar"]}
|
||||
|
||||
it "accepts global source-dirs" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
source-dirs:
|
||||
- foo
|
||||
- bar
|
||||
library: {}
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
packageLibrary c `shouldBe` Just library {librarySourceDirs = ["foo", "bar"]}
|
||||
|
||||
it "allows to specify exposed-modules" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
library:
|
||||
source-dirs: src
|
||||
exposed-modules: Foo
|
||||
|]
|
||||
touch "src/Foo.hs"
|
||||
touch "src/Bar.hs"
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
packageLibrary c `shouldBe` Just library {librarySourceDirs = ["src"], libraryExposedModules = ["Foo"], libraryOtherModules = ["Bar"]}
|
||||
|
||||
it "allows to specify other-modules" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
library:
|
||||
source-dirs: src
|
||||
other-modules: Bar
|
||||
|]
|
||||
touch "src/Foo.hs"
|
||||
touch "src/Bar.hs"
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
packageLibrary c `shouldBe` Just library {librarySourceDirs = ["src"], libraryExposedModules = ["Foo"], libraryOtherModules = ["Bar"]}
|
||||
|
||||
it "allows to specify both exposed-modules and other-modules" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
library:
|
||||
source-dirs: src
|
||||
exposed-modules: Foo
|
||||
other-modules: Bar
|
||||
|]
|
||||
touch "src/Baz.hs"
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
packageLibrary c `shouldBe` Just library {librarySourceDirs = ["src"], libraryExposedModules = ["Foo"], libraryOtherModules = ["Bar"]}
|
||||
|
||||
context "when neither exposed-module nor other-module are specified" $ do
|
||||
it "exposes all modules" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
library:
|
||||
source-dirs: src
|
||||
|]
|
||||
touch "src/Foo.hs"
|
||||
touch "src/Bar.hs"
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
packageLibrary c `shouldBe` Just library {librarySourceDirs = ["src"], libraryExposedModules = ["Bar", "Foo"]}
|
||||
|
||||
context "when reading executable section" $ do
|
||||
it "warns on unknown fields" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
executables:
|
||||
foo:
|
||||
main: Main.hs
|
||||
@ -286,22 +286,22 @@ spec = around_ (inTempDirectoryNamed "foo") $ do
|
||||
baz: 23
|
||||
|]
|
||||
|
||||
fmap fst <$> readPackageConfig "package.yaml" `shouldReturn` Right [
|
||||
fmap fst <$> readPackageConfig "package.yml" `shouldReturn` Right [
|
||||
"Ignoring unknown field \"bar\" in executable section \"foo\""
|
||||
, "Ignoring unknown field \"baz\" in executable section \"foo\""
|
||||
]
|
||||
|
||||
it "reads executable section" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
executables:
|
||||
foo:
|
||||
main: driver/Main.hs
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
packageExecutables c `shouldBe` [executable "foo" "driver/Main.hs"]
|
||||
|
||||
it "accepts source-dirs" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
executables:
|
||||
foo:
|
||||
main: Main.hs
|
||||
@ -309,11 +309,11 @@ spec = around_ (inTempDirectoryNamed "foo") $ do
|
||||
- foo
|
||||
- bar
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
packageExecutables c `shouldBe` [(executable "foo" "Main.hs") {executableSourceDirs = ["foo", "bar"]}]
|
||||
|
||||
it "accepts global source-dirs" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
source-dirs:
|
||||
- foo
|
||||
- bar
|
||||
@ -321,7 +321,7 @@ spec = around_ (inTempDirectoryNamed "foo") $ do
|
||||
foo:
|
||||
main: Main.hs
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
packageExecutables c `shouldBe` [(executable "foo" "Main.hs") {executableSourceDirs = ["foo", "bar"]}]
|
||||
|
||||
it "infers other-modules" $ do
|
||||
@ -329,30 +329,30 @@ spec = around_ (inTempDirectoryNamed "foo") $ do
|
||||
touch "src/Foo.hs"
|
||||
touch "src/Bar.hs"
|
||||
touch "src/Baz.lhs"
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
executables:
|
||||
foo:
|
||||
main: Main.hs
|
||||
source-dirs: src
|
||||
|]
|
||||
Right (_, [r]) <- (fmap . fmap) packageExecutables <$> readPackageConfig "package.yaml"
|
||||
Right (_, [r]) <- (fmap . fmap) packageExecutables <$> readPackageConfig "package.yml"
|
||||
executableOtherModules r `shouldBe` ["Bar", "Baz", "Foo"]
|
||||
|
||||
it "allows to specify other-modules" $ do
|
||||
touch "src/Foo.hs"
|
||||
touch "src/Bar.hs"
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
executables:
|
||||
foo:
|
||||
main: Main.hs
|
||||
source-dirs: src
|
||||
other-modules: Baz
|
||||
|]
|
||||
Right (_, [r]) <- (fmap . fmap) packageExecutables <$> readPackageConfig "package.yaml"
|
||||
Right (_, [r]) <- (fmap . fmap) packageExecutables <$> readPackageConfig "package.yml"
|
||||
executableOtherModules r `shouldBe` ["Baz"]
|
||||
|
||||
it "accepts default-extensions" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
executables:
|
||||
foo:
|
||||
main: driver/Main.hs
|
||||
@ -360,11 +360,11 @@ spec = around_ (inTempDirectoryNamed "foo") $ do
|
||||
- Foo
|
||||
- Bar
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
packageExecutables c `shouldBe` [(executable "foo" "driver/Main.hs") {executableDefaultExtensions = ["Foo", "Bar"]}]
|
||||
|
||||
it "accepts global default-extensions" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
default-extensions:
|
||||
- Foo
|
||||
- Bar
|
||||
@ -372,32 +372,32 @@ spec = around_ (inTempDirectoryNamed "foo") $ do
|
||||
foo:
|
||||
main: driver/Main.hs
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
packageExecutables c `shouldBe` [(executable "foo" "driver/Main.hs") {executableDefaultExtensions = ["Foo", "Bar"]}]
|
||||
|
||||
it "accepts GHC options" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
executables:
|
||||
foo:
|
||||
main: driver/Main.hs
|
||||
ghc-options: -Wall
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
c `shouldBe` package {packageExecutables = [(executable "foo" "driver/Main.hs") {executableGhcOptions = ["-Wall"]}]}
|
||||
|
||||
it "accepts global GHC options" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
ghc-options: -Wall
|
||||
executables:
|
||||
foo:
|
||||
main: driver/Main.hs
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
c `shouldBe` package {packageExecutables = [(executable "foo" "driver/Main.hs") {executableGhcOptions = ["-Wall"]}]}
|
||||
|
||||
context "when reading test section" $ do
|
||||
it "warns on unknown fields" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
tests:
|
||||
foo:
|
||||
main: Main.hs
|
||||
@ -405,32 +405,32 @@ spec = around_ (inTempDirectoryNamed "foo") $ do
|
||||
baz: 23
|
||||
|]
|
||||
|
||||
fmap fst <$> readPackageConfig "package.yaml" `shouldReturn` Right [
|
||||
fmap fst <$> readPackageConfig "package.yml" `shouldReturn` Right [
|
||||
"Ignoring unknown field \"bar\" in test section \"foo\""
|
||||
, "Ignoring unknown field \"baz\" in test section \"foo\""
|
||||
]
|
||||
|
||||
it "reads test section" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
tests:
|
||||
spec:
|
||||
main: test/Spec.hs
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
c `shouldBe` package {packageTests = [executable "spec" "test/Spec.hs"]}
|
||||
|
||||
it "accepts single dependency" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
tests:
|
||||
spec:
|
||||
main: test/Spec.hs
|
||||
dependencies: hspec
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
c `shouldBe` package {packageTests = [(executable "spec" "test/Spec.hs") {executableDependencies = [["hspec"]]}]}
|
||||
|
||||
it "accepts list of dependencies" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
tests:
|
||||
spec:
|
||||
main: test/Spec.hs
|
||||
@ -438,12 +438,12 @@ spec = around_ (inTempDirectoryNamed "foo") $ do
|
||||
- hspec
|
||||
- QuickCheck
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
c `shouldBe` package {packageTests = [(executable "spec" "test/Spec.hs") {executableDependencies = [["hspec", "QuickCheck"]]}]}
|
||||
|
||||
context "when both top-level and section specific dependencies are specified" $ do
|
||||
it "combines dependencies" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
dependencies:
|
||||
- base
|
||||
|
||||
@ -452,12 +452,12 @@ spec = around_ (inTempDirectoryNamed "foo") $ do
|
||||
main: test/Spec.hs
|
||||
dependencies: hspec
|
||||
|]
|
||||
Right (_, c) <- readPackageConfig "package.yaml"
|
||||
Right (_, c) <- readPackageConfig "package.yml"
|
||||
c `shouldBe` package {packageTests = [(executable "spec" "test/Spec.hs") {executableDependencies = [["base"], ["hspec"]]}]}
|
||||
|
||||
context "when a specified source directory does not exist" $ do
|
||||
it "warns" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
source-dirs:
|
||||
- some-dir
|
||||
- some-existing-dir
|
||||
@ -473,26 +473,30 @@ spec = around_ (inTempDirectoryNamed "foo") $ do
|
||||
source-dirs: some-test-dir
|
||||
|]
|
||||
touch "some-existing-dir/foo"
|
||||
fmap fst <$> readPackageConfig "package.yaml" `shouldReturn` Right [
|
||||
fmap fst <$> readPackageConfig "package.yml" `shouldReturn` Right [
|
||||
"Specified source-dir " ++ show "some-dir" ++ " does not exist"
|
||||
, "Specified source-dir " ++ show "some-exec-dir" ++ " does not exist"
|
||||
, "Specified source-dir " ++ show "some-lib-dir" ++ " does not exist"
|
||||
, "Specified source-dir " ++ show "some-test-dir" ++ " does not exist"
|
||||
]
|
||||
|
||||
context "when package.yaml can not be parsed" $ do
|
||||
context "when package.yml can not be parsed" $ do
|
||||
it "returns an error" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
foo: bar
|
||||
foo baz
|
||||
|]
|
||||
readPackageConfig "package.yaml" `shouldReturn` Left "package.yaml:3:10: could not find expected ':' while scanning a simple key"
|
||||
readPackageConfig "package.yml" `shouldReturn` Left "package.yml:3:10: could not find expected ':' while scanning a simple key"
|
||||
|
||||
context "when package.yaml is invalid" $ do
|
||||
context "when package.yml is invalid" $ do
|
||||
it "returns an error" $ do
|
||||
writeFile "package.yaml" [i|
|
||||
writeFile "package.yml" [i|
|
||||
executables:
|
||||
foo:
|
||||
ain: driver/Main.hs
|
||||
|]
|
||||
readPackageConfig "package.yaml" `shouldReturn` Left "package.yaml: The key \"main\" was not found"
|
||||
readPackageConfig "package.yml" `shouldReturn` Left "package.yml: The key \"main\" was not found"
|
||||
|
||||
context "when package.yml does not exist" $ do
|
||||
it "returns an error" $
|
||||
readPackageConfig "package.yml" `shouldReturn` Left "package.yml: Yaml file not found: package.yml"
|
||||
|
Loading…
Reference in New Issue
Block a user