diff options
author | Daniel Gröber <dxld@darkboxed.org> | 2019-06-19 00:49:38 +0200 |
---|---|---|
committer | Daniel Gröber <dxld@darkboxed.org> | 2019-06-19 01:53:29 +0200 |
commit | 97d8c5384b90b88ead7cddbf0c8cf63021b2fed9 (patch) | |
tree | 5e418222e8726e2b8a3e37b2b19f395839306263 | |
parent | edf99c36d2aa8cd7311234d1f134d2b8db246ac0 (diff) |
compile-test: Read cabal versions from file
This allows them to be checked for up-to-date'nes in CI like the
stack-resolvers.
-rw-r--r-- | .gitlab-ci.yml | 5 | ||||
-rw-r--r-- | cabal-helper.cabal | 3 | ||||
-rwxr-xr-x | scripts/ci/check-testdata.sh | 18 | ||||
-rwxr-xr-x | scripts/ci/update-cabal-versions.sh | 6 | ||||
-rw-r--r-- | tests/CompileTest.hs | 64 | ||||
-rw-r--r-- | tests/cabal-versions | 57 |
6 files changed, 102 insertions, 51 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2b895d0..4e36e41 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,3 +1,4 @@ +--- stages: - build @@ -35,5 +36,5 @@ job-check-upd: image: registry.gitlab.com/dxld/ghc-mod:ghc7.10.3-cabal-install2.4.1.0-stack2.1.0.1 stage: build script: - - "$CI_PROJECT_DIR"/scripts/ci/update-stack-resolvers.sh | tee tests/stack-resolvers.new - - git diff --exit-code -- tests/stack-resolvers tests/stack-resolvers.new + - apt-get install -yy jq + - "$CI_PROJECT_DIR/scripts/ci/check-testdata.sh" diff --git a/cabal-helper.cabal b/cabal-helper.cabal index c065779..9cc7215 100644 --- a/cabal-helper.cabal +++ b/cabal-helper.cabal @@ -36,6 +36,7 @@ extra-source-files: README.md tests/*.hs tests/stack-resolvers + tests/cabal-versions tests/exelib/*.hs tests/exelib/*.cabal @@ -173,6 +174,8 @@ test-suite compile-test ghc-options: -Wall build-depends: c-h-internal + + test-suite ghc-session import: build-deps, extensions type: exitcode-stdio-1.0 diff --git a/scripts/ci/check-testdata.sh b/scripts/ci/check-testdata.sh new file mode 100755 index 0000000..9e2182d --- /dev/null +++ b/scripts/ci/check-testdata.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e -o pipefail + +echo "=== Stack resolvers" + +$CI_PROJECT_DIR/scripts/ci/update-stack-resolvers.sh \ + | tee tests/stack-resolvers.new + +git diff --exit-code -- tests/stack-resolvers tests/stack-resolvers.new \ + && echo OK + +echo; echo; echo "=== Cabal versions" +$CI_PROJECT_DIR/scripts/ci/update-cabal-versions.sh \ + | tee tests/cabal-versions.new + +git diff --exit-code -- tests/cabal-versions tests/cabal-versions.new \ + && echo OK diff --git a/scripts/ci/update-cabal-versions.sh b/scripts/ci/update-cabal-versions.sh new file mode 100755 index 0000000..52dd5d2 --- /dev/null +++ b/scripts/ci/update-cabal-versions.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# Example: +# $ scripts/ci/update-cabal-versions.sh | tee tests/cabal-versions + +wget -q -O- https://hackage.haskell.org/package/Cabal/preferred.json \ + | jq -r '."normal-version"[]' | sort -V diff --git a/tests/CompileTest.hs b/tests/CompileTest.hs index ea5202e..2df6c2d 100644 --- a/tests/CompileTest.hs +++ b/tests/CompileTest.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE ScopedTypeVariables, GADTs, ImplicitParams #-} +{-# LANGUAGE ScopedTypeVariables, GADTs, ImplicitParams, OverloadedStrings #-} {-| This test tries to compile the Helper against every supported version of the Cabal library. Since we compile the Helper at runtime, on the user's machine, @@ -69,16 +69,16 @@ main = do args <- getArgs case args of "list-versions":[] -> do - mapM_ print =<< (allCabalVersions <$> ghcVersion) + mapM_ print =<< relevantCabalVersions =<< ghcVersion "list-versions":ghc_ver_str:[] -> - mapM_ print $ allCabalVersions (GhcVersion (parseVer ghc_ver_str)) + mapM_ print =<< relevantCabalVersions (GhcVersion (parseVer ghc_ver_str)) _ -> test args test :: Env => [String] -> IO () test args = do let action - | null args = testAllCabalVersions + | null args = testRelevantCabalVersions | otherwise = testCabalVersions $ map parseVer' args setupHOME @@ -89,47 +89,14 @@ parseVer' :: String -> CabalVersion parseVer' "HEAD" = CabalHEAD () parseVer' v = CabalVersion $ parseVer v -allCabalVersions :: GhcVersion -> [Version] -allCabalVersions (GhcVersion ghc_ver) = let - cabal_versions :: [Version] - cabal_versions = map parseVer - -- , "1.18.0" - -- , "1.18.1" - -- , "1.18.1.1" - -- , "1.18.1.2" - -- , "1.18.1.3" - -- , "1.18.1.4" - -- , "1.18.1.5" - -- , "1.18.1.6" - -- , "1.18.1.7" - -- , "1.20.0.0" - -- , "1.20.0.1" - -- , "1.20.0.2" - -- , "1.20.0.3" - -- , "1.20.0.4" - -- , "1.22.0.0" - -- , "1.22.1.0" - -- , "1.22.1.1" - [ "1.22.2.0" - , "1.22.3.0" - , "1.22.4.0" - , "1.22.5.0" - , "1.22.6.0" - , "1.22.7.0" - , "1.22.8.0" - , "1.24.0.0" - -- , "1.24.1.0" -- deprecated - , "1.24.2.0" - , "2.0.0.2" - , "2.0.1.0" - , "2.0.1.1" - , "2.2.0.0" - , "2.2.0.1" - , "2.4.0.0" - , "2.4.0.1" - , "2.4.1.0" - ] +relevantCabalVersions :: GhcVersion -> IO [Version] +relevantCabalVersions g = map snd . filter fst <$> allCabalVersions g +allCabalVersions :: GhcVersion -> IO [(Bool,Version)] +allCabalVersions (GhcVersion ghc_ver) = do + cabal_versions + <- map parseVer . lines <$> readFile "tests/cabal-versions" + let constraint :: VersionRange Just constraint = fmap snd $ @@ -147,14 +114,13 @@ allCabalVersions (GhcVersion ghc_ver) = let , ("8.4", ">= 2.0.0.2 ") , ("8.6", ">= 2.0.0.2 ") ] - in - reverse $ filter (flip withinRange'CH constraint) cabal_versions + return $ reverse $ map (flip withinRange'CH constraint &&& id) cabal_versions -testAllCabalVersions :: Env => IO () -testAllCabalVersions = do +testRelevantCabalVersions :: Env => IO () +testRelevantCabalVersions = do ghc_ver <- ghcVersion - let relevant_cabal_versions = allCabalVersions ghc_ver + relevant_cabal_versions <- relevantCabalVersions ghc_ver testCabalVersions $ map CabalVersion relevant_cabal_versions ++ [CabalHEAD ()] testCabalVersions :: Env => [CabalVersion] -> IO () diff --git a/tests/cabal-versions b/tests/cabal-versions new file mode 100644 index 0000000..f0da0a4 --- /dev/null +++ b/tests/cabal-versions @@ -0,0 +1,57 @@ +1.1.6 +1.2.1 +1.2.2.0 +1.2.3.0 +1.2.4.0 +1.4.0.0 +1.4.0.1 +1.4.0.2 +1.6.0.1 +1.6.0.2 +1.6.0.3 +1.8.0.2 +1.8.0.4 +1.8.0.6 +1.10.0.0 +1.10.1.0 +1.10.2.0 +1.12.0 +1.14.0 +1.16.0 +1.16.0.1 +1.16.0.2 +1.16.0.3 +1.18.0 +1.18.1 +1.18.1.1 +1.18.1.2 +1.18.1.3 +1.18.1.4 +1.18.1.5 +1.18.1.6 +1.18.1.7 +1.20.0.0 +1.20.0.1 +1.20.0.2 +1.20.0.3 +1.20.0.4 +1.22.0.0 +1.22.1.0 +1.22.1.1 +1.22.2.0 +1.22.3.0 +1.22.4.0 +1.22.5.0 +1.22.6.0 +1.22.7.0 +1.22.8.0 +1.24.0.0 +1.24.2.0 +2.0.0.2 +2.0.1.0 +2.0.1.1 +2.2.0.0 +2.2.0.1 +2.4.0.0 +2.4.0.1 +2.4.1.0 |