Ticket #2608: cabal-test-support.patch

File cabal-test-support.patch, 14.7 KB (added by kaol, 6 years ago)

patch against 6.6.1

  • libraries/Cabal/Cabal.cabal

    diff -x configure -x config.status -x config.guess -x config.sub -Nru ghc6-6.6.1.orig/libraries/Cabal/Cabal.cabal ghc6-6.6.1/libraries/Cabal/Cabal.cabal
    old new  
    4242        Distribution.Simple.LocalBuildInfo, 
    4343        Distribution.Simple.NHC, 
    4444        Distribution.Simple.Register, 
     45        Distribution.Simple.RunTests, 
    4546        Distribution.Simple.SrcDist, 
    4647        Distribution.Simple.Utils, 
    4748        Distribution.Version, 
  • libraries/Cabal/Distribution/PackageDescription.hs

    diff -x configure -x config.status -x config.guess -x config.sub -Nru ghc6-6.6.1.orig/libraries/Cabal/Distribution/PackageDescription.hs ghc6-6.6.1/libraries/Cabal/Distribution/PackageDescription.hs
    old new  
    213213-- Consider refactoring into executable and library versions. 
    214214data BuildInfo = BuildInfo { 
    215215        buildable         :: Bool,      -- ^ component is buildable here 
     216        doNotInstall      :: Bool,      -- ^ set to true to suppress installing an exe or library 
     217        isTest            :: Bool,      -- ^ set to true to run an executable from the test target 
    216218        ccOptions         :: [String],  -- ^ options for C compiler 
    217219        ldOptions         :: [String],  -- ^ options for linker 
    218220        frameworks        :: [String], -- ^support frameworks for Mac OS X 
     
    233235emptyBuildInfo :: BuildInfo 
    234236emptyBuildInfo = BuildInfo { 
    235237                      buildable         = True, 
     238                      doNotInstall      = False, 
     239                      isTest            = False, 
    236240                      ccOptions         = [], 
    237241                      ldOptions         = [], 
    238242                      frameworks        = [], 
     
    322326unionBuildInfo :: BuildInfo -> BuildInfo -> BuildInfo 
    323327unionBuildInfo b1 b2 
    324328    = b1{buildable         = buildable b1 && buildable b2, 
     329         doNotInstall      = doNotInstall b1 && doNotInstall b2, 
     330         isTest            = isTest b1 && isTest b2, 
    325331         ccOptions         = combine ccOptions, 
    326332         ldOptions         = combine ldOptions, 
    327333         frameworks        = combine frameworks, 
     
    443449 
    444450binfoFields :: [StanzaField BuildInfo] 
    445451binfoFields = 
    446  [ simpleField "buildable" 
    447                            (text . show)      parseReadS 
     452 [ boolField "buildable" 
    448453                           buildable          (\val binfo -> binfo{buildable=val}) 
     454 , boolField "do-not-install" 
     455                           doNotInstall       (\val binfo -> binfo{doNotInstall=val}) 
     456 , boolField "is-test" 
     457                           isTest             (\val binfo -> binfo{isTest=val}) 
    449458 , listField "cc-options" 
    450459                           showToken          parseTokenQ 
    451460                           ccOptions          (\val binfo -> binfo{ccOptions=val}) 
  • libraries/Cabal/Distribution/ParseUtils.hs

    diff -x configure -x config.status -x config.guess -x config.sub -Nru ghc6-6.6.1.orig/libraries/Cabal/Distribution/ParseUtils.hs ghc6-6.6.1/libraries/Cabal/Distribution/ParseUtils.hs
    old new  
    5353        parsePackageNameQ, parseVersionRangeQ, 
    5454        parseTestedWithQ, parseLicenseQ, parseExtensionQ, parseCommaList, parseOptCommaList, 
    5555        showFilePath, showToken, showTestedWith, showDependency, showFreeText, 
    56         liftField, simpleField, listField, commaListField, optsField, 
     56        liftField, simpleField, boolField, listField, commaListField, optsField, 
    5757        parseReadS, parseQuoted, 
    5858  ) where 
    5959 
     
    140140       x <- runP lineNo name readF val 
    141141       return (set x st)) 
    142142 
     143boolField :: String -> (a -> Bool) -> (Bool -> a -> a) -> StanzaField a 
     144boolField name get set = simpleField name (text . show) parseReadS get set 
     145 
    143146commaListField :: String -> (a -> Doc) -> (ReadP [a] a) -> (b -> [a]) -> ([a] -> b -> b) -> StanzaField b 
    144147commaListField name showF readF get set = StanzaField name 
    145148   (\st -> fsep (punctuate comma (map showF (get st)))) 
  • libraries/Cabal/Distribution/Simple/GHC.hs

    diff -x configure -x config.status -x config.guess -x config.sub -Nru ghc6-6.6.1.orig/libraries/Cabal/Distribution/Simple/GHC.hs ghc6-6.6.1/libraries/Cabal/Distribution/Simple/GHC.hs
    old new  
    362362              -> FilePath -- ^Build location 
    363363              -> PackageDescription -> IO () 
    364364installExe verbose pref buildPref pkg_descr 
    365     = do createDirectoryIfMissing True pref 
    366          withExe pkg_descr $ \ (Executable e _ b) -> do 
     365    = do withExe pkg_descr $ \ (Executable e _ b) -> when (not $ doNotInstall b) $ do 
     366             createDirectoryIfMissing True pref 
    367367             let exeName = e `joinFileExt` exeExtension 
    368368             copyFileVerbose verbose (buildPref `joinFileName` e `joinFileName` exeName) (pref `joinFileName` exeName) 
    369369 
     
    379379installLib verbose programConf hasVanilla hasProf hasGHCi pref buildPref 
    380380              pd@PackageDescription{library=Just l, 
    381381                                    package=p} 
    382     = do ifVanilla $ smartCopySources verbose [buildPref] pref (libModules pd) ["hi"] True False 
     382    = when (not $ doNotInstall $ libBuildInfo l) $ do 
     383         ifVanilla $ smartCopySources verbose [buildPref] pref (libModules pd) ["hi"] True False 
    383384         ifProf $ smartCopySources verbose [buildPref] pref (libModules pd) ["p_hi"] True False 
    384385         let libTargetLoc = mkLibName pref (showPackageId p) 
    385386             profLibTargetLoc = mkProfLibName pref (showPackageId p) 
  • libraries/Cabal/Distribution/Simple/Hugs.hs

    diff -x configure -x config.status -x config.guess -x config.sub -Nru ghc6-6.6.1.orig/libraries/Cabal/Distribution/Simple/Hugs.hs ghc6-6.6.1/libraries/Cabal/Distribution/Simple/Hugs.hs
    old new  
    306306    -> PackageDescription 
    307307    -> IO () 
    308308install verbose libDir installProgDir binDir targetProgDir buildPref pkg_descr = do 
    309     withLib pkg_descr () $ \ libInfo -> do 
     309    withLib pkg_descr () $ \ libInfo -> when (not $ doNotInstall $ libBuildInfo libInfo) $ do 
    310310        try $ removeDirectoryRecursive libDir 
    311311        smartCopySources verbose [buildPref] libDir (libModules pkg_descr) hugsInstallSuffixes True False 
    312     let buildProgDir = buildPref `joinFileName` "programs" 
    313     when (any (buildable . buildInfo) (executables pkg_descr)) $ 
     312    let buildProgDir      = buildPref `joinFileName` "programs" 
     313        okToInstall bInfo = buildable bInfo && not (doNotInstall bInfo) 
     314    when (any (okToInstall . buildInfo) (executables pkg_descr)) $ 
    314315        createDirectoryIfMissing True binDir 
    315     withExe pkg_descr $ \ exe -> do 
     316    withExe pkg_descr $ \ exe -> when (okToInstall $ buildInfo exe) $ do 
    316317        let buildDir = buildProgDir `joinFileName` exeName exe 
    317318        let installDir = installProgDir `joinFileName` exeName exe 
    318319        let targetDir = targetProgDir `joinFileName` exeName exe 
  • libraries/Cabal/Distribution/Simple/JHC.hs

    diff -x configure -x config.status -x config.guess -x config.sub -Nru ghc6-6.6.1.orig/libraries/Cabal/Distribution/Simple/JHC.hs ghc6-6.6.1/libraries/Cabal/Distribution/Simple/JHC.hs
    old new  
    111111             ] 
    112112                          
    113113installLib :: Int -> FilePath -> FilePath -> PackageDescription -> Library -> IO () 
    114 installLib verb dest build pkg_descr _ = do 
     114installLib verb dest build pkg_descr lib = when (not $ doNotInstall $ libBuildInfo lib) $ do 
    115115    let p = showPackageId (package pkg_descr)++".hl" 
    116116    createDirectoryIfMissing True dest 
    117117    copyFileVerbose verb (joinFileName build p) (joinFileName dest p) 
    118118 
    119119installExe :: Int -> FilePath -> FilePath -> PackageDescription -> Executable -> IO () 
    120 installExe verb dest build pkg_descr exe = do 
     120installExe verb dest build pkg_descr exe = when (not $ doNotInstall $ buildInfo exe) $ do 
    121121    let out   = exeName exe `joinFileName` exeExtension 
    122122    createDirectoryIfMissing True dest 
    123123    copyFileVerbose verb (joinFileName build out) (joinFileName dest out) 
  • libraries/Cabal/Distribution/Simple/RunTests.hs

    diff -x configure -x config.status -x config.guess -x config.sub -Nru ghc6-6.6.1.orig/libraries/Cabal/Distribution/Simple/RunTests.hs ghc6-6.6.1/libraries/Cabal/Distribution/Simple/RunTests.hs
    old new  
     1-- | 
     2-- Module       : RunTests 
     3-- Copyright    : Daniel Burrows 2007 
     4-- Maintainer   : Daniel Burrows <dburrows@algebraicthunk.net> 
     5-- Stability    : alpha 
     6-- Portability  : portable 
     7-- 
     8-- Explanation: Support for running tests from the "test" target or at 
     9-- other points in the build. 
     10 
     11module Distribution.Simple.RunTests where 
     12 
     13import Data.List ( foldl' ) 
     14 
     15import Distribution.Compat.FilePath 
     16                                ( joinFileName, exeExtension, joinFileExt ) 
     17import Distribution.PackageDescription 
     18                                ( BuildInfo(..), 
     19                                  Executable(..), 
     20                                  PackageDescription(..) ) 
     21import Distribution.Simple.LocalBuildInfo 
     22                                ( LocalBuildInfo(..) ) 
     23import Distribution.Simple.Utils 
     24                                ( rawSystemVerbose ) 
     25 
     26import System.Cmd 
     27import System.Exit(ExitCode(..), exitWith) 
     28 
     29-- | Run all the executables flagged in the .cabal file via 'isTest'. 
     30-- 
     31-- All tests are run even if one fails; the first failing error code 
     32-- is returned.  Executables that have not been built will fail with 
     33-- \"command not found\" or the system equivalent. 
     34doTests :: Int -> PackageDescription -> LocalBuildInfo -> IO ExitCode 
     35doTests verbose pkgDesc lbi = 
     36    do ecs <- sequence [invokeTest exe 
     37                            | exe <- (executables pkgDesc), 
     38                              isTest $ buildInfo exe] 
     39       return $ foldl' combineExitCodes ExitSuccess ecs 
     40    where 
     41      -- The builder creates an executable named 
     42      -- $buildDir/$exeName/$exeName$exeExtension. 
     43      invokeTest exe = 
     44          let exeBase    = (exeName exe) `joinFileExt` exeExtension 
     45              buildPath  = (buildDir lbi) `joinFileName` (exeName exe) 
     46              exePath    = buildPath `joinFileName` exeBase in 
     47          rawSystemVerbose verbose exePath [] 
     48 
     49      combineExitCodes ExitSuccess e2 = e2 
     50      combineExitCodes e1      _  = e1 
  • libraries/Cabal/Distribution/Simple.hs

    diff -x configure -x config.status -x config.guess -x config.sub -Nru ghc6-6.6.1.orig/libraries/Cabal/Distribution/Simple.hs ghc6-6.6.1/libraries/Cabal/Distribution/Simple.hs
    old new  
    8282                                          writeInstalledConfig, installedPkgConfigFile, 
    8383                                          regScriptLocation, unregScriptLocation 
    8484                                        ) 
     85import Distribution.Simple.RunTests     ( doTests ) 
    8586 
    8687import Distribution.Simple.Configure(getPersistBuildConfig, maybeGetPersistBuildConfig, 
    8788                                     findProgram, configure, writePersistBuildConfig, 
     
    130131-- to specify additional preprocessors. 
    131132data UserHooks = UserHooks 
    132133    { 
    133      runTests :: Args -> Bool -> PackageDescription -> LocalBuildInfo -> IO ExitCode, -- ^Used for @.\/setup test@ 
     134     runTests :: Args -> Int -> PackageDescription -> LocalBuildInfo -> IO ExitCode, -- ^Used for @.\/setup test@ 
    134135     readDesc :: IO (Maybe PackageDescription), -- ^Read the description file 
    135136     hookedPreProcessors :: [ PPSuffixHandler ], 
    136137        -- ^Custom preprocessors in addition to and overriding 'knownSuffixHandlers'. 
     
    348349                case hooks of 
    349350                 Nothing -> return ExitSuccess 
    350351                 Just h  -> do localbuildinfo <- getPersistBuildConfig 
    351                                out <- (runTests h) args False pkg_descr_in localbuildinfo 
     352                               out <- (runTests h) args verbose pkg_descr_in localbuildinfo 
    352353                               when (isFailure out) (exitWith out) 
    353354                               return out 
    354355 
     
    613614defaultUserHooks 
    614615    = emptyUserHooks 
    615616      { 
     617       runTests  = defaultRunTests, 
    616618       postConf  = defaultPostConf, 
    617619       confHook  = configure, 
    618620       preBuild  = readHook buildVerbose, 
     
    669671      register pkg_descr localbuildinfo  
    670672           emptyRegisterFlags{ regUser=uInstFlag, regVerbose=verbose } 
    671673 
     674defaultRunTests :: Args -> Int -> PackageDescription -> LocalBuildInfo -> IO ExitCode 
     675defaultRunTests _ = doTests 
     676 
    672677defaultBuildHook :: PackageDescription -> LocalBuildInfo 
    673678        -> Maybe UserHooks -> BuildFlags -> IO () 
    674679defaultBuildHook pkg_descr localbuildinfo hooks flags = do 
  • libraries/Cabal/doc/Cabal.xml

    diff -x configure -x config.status -x config.guess -x config.sub -Nru ghc6-6.6.1.orig/libraries/Cabal/doc/Cabal.xml ghc6-6.6.1/libraries/Cabal/doc/Cabal.xml
    old new  
    652652            </listitem> 
    653653          </varlistentry> 
    654654 
     655          <varlistentry> 
     656            <term> 
     657              <literal>do-not-install:</literal> <replaceable>Boolean</replaceable> 
     658              (default: <literal>False</literal>) 
     659            </term> 
     660 
     661            <listitem> 
     662              <para>Should the component be installed?  Setting this 
     663              flag to <literal>True</literal> will prevent the 
     664              executable or library from being installed by the 
     665              <quote><literal>install</literal></quote> target of the 
     666              setup script.  A typical use case is a test suite that 
     667              should be built but not installed.</para> 
     668            </listitem> 
     669          </varlistentry> 
     670 
     671          <varlistentry> 
     672            <term> 
     673              <literal>is-test:</literal> <replaceable>Boolean</replaceable> 
     674              (default: <literal>False</literal>) 
     675            </term> 
     676 
     677            <listitem> 
     678              <para>Setting this flag to <literal>True</literal> will 
     679              cause the executable to be invoked by the 
     680              <quote><literal>test</literal></quote> target of the 
     681              setup script.</para> 
     682            </listitem> 
     683          </varlistentry> 
     684 
    655685          <varlistentry> 
    656686            <term> 
    657687              <literal>other-modules:</literal>