Skip to content

Commit

Permalink
Rewrite the test suite, AGAIN. (#4095)
Browse files Browse the repository at this point in the history
See cabal-testsuite/README.md for a detailed description
of the new architecture.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
  • Loading branch information
ezyang committed Nov 18, 2016
1 parent 2f5c861 commit e496b09
Show file tree
Hide file tree
Showing 127 changed files with 2,872 additions and 2,547 deletions.
12 changes: 11 additions & 1 deletion Cabal/Distribution/Simple/GHC.hs
Expand Up @@ -82,6 +82,7 @@ import Distribution.Package
import qualified Distribution.ModuleName as ModuleName
import Distribution.ModuleName (ModuleName)
import Distribution.Simple.Program
import Distribution.Simple.Program.Builtin (runghcProgram)
import qualified Distribution.Simple.Program.HcPkg as HcPkg
import qualified Distribution.Simple.Program.Ar as Ar
import qualified Distribution.Simple.Program.Ld as Ld
Expand Down Expand Up @@ -148,9 +149,13 @@ configure verbosity hcPath hcPkgPath conf0 = do
hpcProgram' = hpcProgram {
programFindLocation = guessHpcFromGhcPath ghcProg
}
runghcProgram' = runghcProgram {
programFindLocation = guessRunghcFromGhcPath ghcProg
}
progdb3 = addKnownProgram haddockProgram' $
addKnownProgram hsc2hsProgram' $
addKnownProgram hpcProgram' progdb2
addKnownProgram hpcProgram' $
addKnownProgram runghcProgram' progdb2

languages <- Internal.getLanguages verbosity implInfo ghcProg
extensions0 <- Internal.getExtensions verbosity implInfo ghcProg
Expand Down Expand Up @@ -283,6 +288,11 @@ guessHpcFromGhcPath :: ConfiguredProgram
-> IO (Maybe (FilePath, [FilePath]))
guessHpcFromGhcPath = guessToolFromGhcPath hpcProgram

guessRunghcFromGhcPath :: ConfiguredProgram
-> Verbosity -> ProgramSearchPath
-> IO (Maybe (FilePath, [FilePath]))
guessRunghcFromGhcPath = guessToolFromGhcPath runghcProgram


getGhcInfo :: Verbosity -> ConfiguredProgram -> IO [(String, String)]
getGhcInfo verbosity ghcProg = Internal.getGhcInfo verbosity implInfo ghcProg
Expand Down
11 changes: 11 additions & 0 deletions Cabal/Distribution/Simple/Program/Builtin.hs
Expand Up @@ -18,6 +18,7 @@ module Distribution.Simple.Program.Builtin (
-- * Programs that Cabal knows about
ghcProgram,
ghcPkgProgram,
runghcProgram,
ghcjsProgram,
ghcjsPkgProgram,
lhcProgram,
Expand Down Expand Up @@ -70,6 +71,7 @@ builtinPrograms =
[
-- compilers and related progs
ghcProgram
, runghcProgram
, ghcPkgProgram
, ghcjsProgram
, ghcjsPkgProgram
Expand Down Expand Up @@ -121,6 +123,15 @@ ghcProgram = (simpleProgram "ghc") {
(programVersion ghcProg)
}

runghcProgram :: Program
runghcProgram = (simpleProgram "runghc") {
programFindVersion = findProgramVersion "--version" $ \str ->
case words str of
-- "runghc 7.10.3"
(_:ver:_) -> ver
_ -> ""
}

ghcPkgProgram :: Program
ghcPkgProgram = (simpleProgram "ghc-pkg") {
programFindVersion = findProgramVersion "--version" $ \str ->
Expand Down
4 changes: 2 additions & 2 deletions Cabal/misc/gen-extra-source-files.hs
Expand Up @@ -28,8 +28,8 @@ main' fp = do
let testModuleFiles = getOtherModulesFiles cabal
let skipPredicates' = skipPredicates ++ map (==) testModuleFiles

-- Read all files git knows about under "tests" and "PackageTests" (cabal-testsuite)
files0 <- lines <$> readProcess "git" ["ls-files", "tests", "PackageTests"] ""
-- Read all files git knows about under "tests"
files0 <- lines <$> readProcess "git" ["ls-files", "tests"] ""

-- Filter
let files1 = filter (\f -> takeExtension f `elem` whitelistedExtensionss ||
Expand Down
10 changes: 8 additions & 2 deletions appveyor.yml
Expand Up @@ -21,11 +21,17 @@ build_script:
- Setup test --show-details=streaming --test-option=--hide-successes
- Setup install
- cd ..\cabal-testsuite
- ghc --make -threaded -i Setup.hs -package Cabal-1.25.0.0
- echo "" | ..\cabal install --only-dependencies --enable-tests
- ghc --make -threaded -i -i. Setup.hs -Wall -Werror
- Setup configure --user --ghc-option=-Werror --enable-tests
- Setup build
- Setup test --show-details=streaming --test-option=--hide-successes
# Must install the test suite, so that our GHCi invocation picks it up
- Setup install
# Copy the setup script into the spot cabal-tests expects it
- mkdir dist\setup
- cp Setup.exe dist\setup
- dist\build\cabal-tests\cabal-tests.exe -j3
# - Setup test --show-details=streaming --test-option=--hide-successes
- cd ..\cabal-install
- ghc --make -threaded -i -i. Setup.hs -Wall -Werror
- echo "" | ..\cabal install happy
Expand Down
10 changes: 8 additions & 2 deletions cabal-install/Distribution/Client/Configure.hs
Expand Up @@ -296,7 +296,10 @@ planLocalPackage :: Verbosity -> Compiler
-> IO (Progress String String SolverInstallPlan)
planLocalPackage verbosity comp platform configFlags configExFlags
installedPkgIndex (SourcePackageDb _ packagePrefs) pkgConfigDb = do
pkg <- readPackageDescription verbosity =<< defaultPackageDesc verbosity
pkg <- readPackageDescription verbosity =<<
case flagToMaybe (configCabalFilePath configFlags) of
Nothing -> defaultPackageDesc verbosity
Just fp -> return fp
solver <- chooseSolver verbosity (fromFlag $ configSolver configExFlags)
(compilerInfo comp)

Expand Down Expand Up @@ -387,7 +390,10 @@ configurePackage verbosity platform comp scriptOptions configFlags
where
gpkg = packageDescription spkg
configureFlags = filterConfigureFlags configFlags {
configIPID = toFlag (display ipid),
configIPID = if isJust (flagToMaybe (configIPID configFlags))
-- Make sure cabal configure --ipid works.
then configIPID configFlags
else toFlag (display ipid),
configConfigurationsFlags = flags,
-- We generate the legacy constraints as well as the new style precise
-- deps. In the end only one set gets passed to Setup.hs configure,
Expand Down
1 change: 1 addition & 0 deletions cabal-testsuite/.gitignore
@@ -0,0 +1 @@
*.dist

0 comments on commit e496b09

Please sign in to comment.