Unverified Commit d7fd25ac authored by Oleg Grenrus's avatar Oleg Grenrus Committed by GitHub

Merge pull request #6924 from phadej/default-language-check

Add check tests for default-language (#6288)
parents b256029a 06571650
......@@ -189,6 +189,18 @@ extra-source-files:
tests/ParserTests/regressions/issue-6083-pkg-pkg.cabal
tests/ParserTests/regressions/issue-6083-pkg-pkg.expr
tests/ParserTests/regressions/issue-6083-pkg-pkg.format
tests/ParserTests/regressions/issue-6288-a.cabal
tests/ParserTests/regressions/issue-6288-a.check
tests/ParserTests/regressions/issue-6288-b.cabal
tests/ParserTests/regressions/issue-6288-b.check
tests/ParserTests/regressions/issue-6288-c.cabal
tests/ParserTests/regressions/issue-6288-c.check
tests/ParserTests/regressions/issue-6288-d.cabal
tests/ParserTests/regressions/issue-6288-d.check
tests/ParserTests/regressions/issue-6288-e.cabal
tests/ParserTests/regressions/issue-6288-e.check
tests/ParserTests/regressions/issue-6288-f.cabal
tests/ParserTests/regressions/issue-6288-f.check
tests/ParserTests/regressions/issue-774.cabal
tests/ParserTests/regressions/issue-774.check
tests/ParserTests/regressions/issue-774.expr
......
......@@ -158,6 +158,10 @@ instance (Newtype a b, Ord a, Sep sep, Parsec b) => Parsec (Set' sep b a) where
instance (Newtype a b, Sep sep, Pretty b) => Pretty (Set' sep b a) where
pretty = prettySep (Proxy :: Proxy sep) . map (pretty . (pack :: a -> b)) . Set.toList . unpack
-------------------------------------------------------------------------------
-- Identifiers
-------------------------------------------------------------------------------
-- | Haskell string or @[^ ,]+@
newtype Token = Token { getToken :: String }
......@@ -191,6 +195,21 @@ instance Parsec a => Parsec (MQuoted a) where
instance Pretty a => Pretty (MQuoted a) where
pretty = pretty . unpack
-- | Filepath are parsed as 'Token'.
newtype FilePathNT = FilePathNT { getFilePathNT :: String }
instance Newtype String FilePathNT
instance Parsec FilePathNT where
parsec = pack <$> parsecToken
instance Pretty FilePathNT where
pretty = showFilePath . unpack
-------------------------------------------------------------------------------
-- SpecVersion
-------------------------------------------------------------------------------
-- | Version range or just version, i.e. @cabal-version@ field.
--
-- There are few things to consider:
......@@ -278,6 +297,10 @@ instance Pretty SpecVersion where
| csv >= CabalSpecV1_12 = text (showCabalSpecVersion csv)
| otherwise = text ">=" <<>> text (showCabalSpecVersion csv)
-------------------------------------------------------------------------------
-- SpecLicense
-------------------------------------------------------------------------------
-- | SPDX License expression or legacy license
newtype SpecLicense = SpecLicense { getSpecLicense :: Either SPDX.License License }
......@@ -293,6 +316,10 @@ instance Parsec SpecLicense where
instance Pretty SpecLicense where
pretty = either pretty pretty . unpack
-------------------------------------------------------------------------------
-- TestedWith
-------------------------------------------------------------------------------
-- | Version range or just version
newtype TestedWith = TestedWith { getTestedWith :: (CompilerFlavor, VersionRange) }
......@@ -305,21 +332,6 @@ instance Pretty TestedWith where
pretty x = case unpack x of
(compiler, vr) -> pretty compiler <+> pretty vr
-- | Filepath are parsed as 'Token'.
newtype FilePathNT = FilePathNT { getFilePathNT :: String }
instance Newtype String FilePathNT
instance Parsec FilePathNT where
parsec = pack <$> parsecToken
instance Pretty FilePathNT where
pretty = showFilePath . unpack
-------------------------------------------------------------------------------
-- Internal
-------------------------------------------------------------------------------
parsecTestedWith :: CabalParsing m => m (CompilerFlavor, VersionRange)
parsecTestedWith = do
name <- lexemeParsec
......
......@@ -42,6 +42,12 @@ checkTests = testGroup "regressions"
, checkTest "assoc-cpp-options.cabal"
, checkTest "public-multilib-1.cabal"
, checkTest "public-multilib-2.cabal"
, checkTest "issue-6288-a.cabal"
, checkTest "issue-6288-b.cabal"
, checkTest "issue-6288-c.cabal"
, checkTest "issue-6288-d.cabal"
, checkTest "issue-6288-e.cabal"
, checkTest "issue-6288-f.cabal"
]
checkTest :: FilePath -> TestTree
......
cabal-version: >=1.8
name: issue
version: 6288
build-type: Simple
synopsis: default-language optionality
category: Test
description: Field is introduced in 1.10, defaulted in 3.4
license: BSD3
license-file: LICENSE
maintainer: Cabal Contributors
library
default-language: Haskell2010
exposed-modules: Foo
To use the 'default-language' field the package needs to specify at least 'cabal-version: >= 1.10'.
cabal-version: >= 1.8
name: issue
version: 6288
build-type: Simple
synopsis: default-language optionality
category: Test
description: Field is introduced in 1.10, defaulted in 3.4
license: BSD3
license-file: LICENSE
maintainer: Cabal Contributors
library
exposed-modules: Foo
cabal-version: >= 1.10
name: issue
version: 6288
build-type: Simple
synopsis: default-language optionality
category: Test
description: Field is introduced in 1.10, defaulted in 3.4
license: BSD3
license-file: LICENSE
maintainer: Cabal Contributors
library
default-language: Haskell2010
exposed-modules: Foo
cabal-version: >=1.10
name: issue
version: 6288
build-type: Simple
synopsis: default-language optionality
category: Test
description: Field is introduced in 1.10, defaulted in 3.4
license: BSD3
license-file: LICENSE
maintainer: Cabal Contributors
library
exposed-modules: Foo
Packages using 'cabal-version: >= 1.10' must specify the 'default-language' field for each component (e.g. Haskell98 or Haskell2010). If a component uses different languages in different modules then list the other ones in the 'other-languages' field.
cabal-version: 3.4
name: issue
version: 6288
synopsis: default-language optionality
category: Test
description: Field is introduced in 1.10, defaulted in 3.4
license: BSD-3-Clause
license-file: LICENSE
maintainer: Cabal Contributors
library
default-language: Haskell2010
exposed-modules: Foo
cabal-version: 3.4
name: issue
version: 6288
build-type: Simple
synopsis: default-language optionality
category: Test
description: Field is introduced in 1.10, defaulted in 3.4
license: BSD-3-Clause
license-file: LICENSE
maintainer: Cabal Contributors
library
exposed-modules: Foo
Packages using 'cabal-version: >= 1.10' must specify the 'default-language' field for each component (e.g. Haskell98 or Haskell2010). If a component uses different languages in different modules then list the other ones in the 'other-languages' field.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment