Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
"url":"pull/5659",
"account":"haskell",
"repo":"cabal",
"commit": "adfc9279a234a06ec6d7ec93090a5d74c480185a",
"tag":"linux-8.2.2"
}
  • Loading branch information
DanielG committed Nov 10, 2018
0 parents commit 1c7954c
Show file tree
Hide file tree
Showing 271 changed files with 25,163 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
language: c
dist: trusty
# This doesn't actually help because we always push a single
# commit to the branch in question
#git:
# # https://github.com/travis-ci/travis-ci/issues/4575
# depth: 1
sudo: required
before_install:
- export PATH=/opt/ghc/$GHCVER/bin:$PATH
- export PATH=$HOME/.ghc-install/$GHCVER/bin:$PATH
- export PATH=$HOME/bin:$PATH
- export PATH=$HOME/.cabal/bin:$PATH
- export PATH=$HOME/.local/bin:$PATH
- export PATH=/opt/cabal/2.0/bin:$PATH
- export PATH=/opt/happy/1.19.5/bin:$PATH
- export PATH=/opt/alex/3.1.7/bin:$PATH
- ./travis-install.sh
script:
- ./travis-test.sh
after_success:
- ./travis-cleanup.sh
notifications:
webhooks:
urls: https://sake-bot.herokuapp.com/
on_start: always
irc:
channels:
- "chat.freenode.net##haskell-cabal"
slack: haskell-cabal:sCq6GLfy9N8MJrInosg871n4
# To append on:
# env: GHCVER=7.6.3 UPSTREAM_BUILD_DIR=/home/travis/user/repo
# os: linux
env: GHCVER=8.2.2 UPSTREAM_BUILD_DIR=/home/travis/build/haskell/cabal CABAL_LIB_ONLY= TEST_OTHER_VERSIONS=
os: linux
79 changes: 79 additions & 0 deletions Cabal/tests/CheckTests.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
module Main
( main
) where

import Test.Tasty
import Test.Tasty.Golden.Advanced (goldenTest)

import Data.Algorithm.Diff (Diff (..), getGroupedDiff)
import Distribution.PackageDescription.Check (checkPackage)
import Distribution.PackageDescription.Parsec (parseGenericPackageDescription)
import Distribution.Parsec.Common (showPError, showPWarning)
import Distribution.Parsec.ParseResult (runParseResult)
import Distribution.Utils.Generic (fromUTF8BS, toUTF8BS)
import System.FilePath (replaceExtension, (</>))

import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BS8

tests :: TestTree
tests = checkTests

-------------------------------------------------------------------------------
-- Regressions
-------------------------------------------------------------------------------

checkTests :: TestTree
checkTests = testGroup "regressions"
[ checkTest "nothing-unicode.cabal"
, checkTest "haddock-api-2.18.1-check.cabal"
, checkTest "issue-774.cabal"
, checkTest "MiniAgda.cabal"
, checkTest "extensions-paths-5054.cabal"
, checkTest "pre-1.6-glob.cabal"
, checkTest "pre-2.4-globstar.cabal"
, checkTest "bad-glob-syntax.cabal"
, checkTest "cc-options-with-optimization.cabal"
, checkTest "cxx-options-with-optimization.cabal"
, checkTest "ghc-option-j.cabal"
]

checkTest :: FilePath -> TestTree
checkTest fp = cabalGoldenTest fp correct $ do
contents <- BS.readFile input
let res = parseGenericPackageDescription contents
let (ws, x) = runParseResult res

return $ toUTF8BS $ case x of
Right gpd ->
-- Note: parser warnings are reported by `cabal check`, but not by
-- D.PD.Check functionality.
unlines (map (showPWarning fp) ws) ++
unlines (map show (checkPackage gpd Nothing))
Left (_, errs) -> unlines $ map (("ERROR: " ++) . showPError fp) errs
where
input = "tests" </> "ParserTests" </> "regressions" </> fp
correct = replaceExtension input "check"

-------------------------------------------------------------------------------
-- Main
-------------------------------------------------------------------------------

main :: IO ()
main = defaultMain tests

cabalGoldenTest :: TestName -> FilePath -> IO BS.ByteString -> TestTree
cabalGoldenTest name ref act = goldenTest name (BS.readFile ref) act cmp upd
where
upd = BS.writeFile ref
cmp x y | x == y = return Nothing
cmp x y = return $ Just $ unlines $
concatMap f (getGroupedDiff (BS8.lines x) (BS8.lines y))
where
f (First xs) = map (cons3 '-' . fromUTF8BS) xs
f (Second ys) = map (cons3 '+' . fromUTF8BS) ys
-- we print unchanged lines too. It shouldn't be a problem while we have
-- reasonably small examples
f (Both xs _) = map (cons3 ' ' . fromUTF8BS) xs
-- we add three characters, so the changed lines are easier to spot
cons3 c cs = c : c : c : ' ' : cs

0 comments on commit 1c7954c

Please sign in to comment.