Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor cabalInstallVersions, add make doctest-cli #6720

Merged
merged 1 commit into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ ghcid-cli :
doctest :
doctest --fast Cabal/Distribution Cabal/Language

# This is not run as part of validate.sh (we need hackage-security, which is tricky to get).
doctest-cli :
doctest -D__DOCTEST__ --fast cabal-install/Distribution

# tests

check-tests :
Expand Down
8 changes: 2 additions & 6 deletions cabal-install/Distribution/Client/BuildReports/Anonymous.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,13 @@ import qualified Distribution.Client.Types as BR
( BuildOutcome, BuildFailure(..), BuildResult(..)
, DocsResult(..), TestsResult(..) )
import Distribution.Client.Utils
( mergeBy, MergeResult(..) )
import qualified Paths_cabal_install (version)
( mergeBy, MergeResult(..), cabalInstallVersion )

import Distribution.Package
( PackageIdentifier(..), mkPackageName )
import Distribution.PackageDescription
( FlagName, mkFlagName, unFlagName
, FlagAssignment, mkFlagAssignment, unFlagAssignment )
import Distribution.Version
( mkVersion' )
import Distribution.System
( OS, Arch )
import Distribution.Compiler
Expand Down Expand Up @@ -159,8 +156,7 @@ new os' arch' comp pkgid flags deps result =

cabalInstallID :: PackageIdentifier
cabalInstallID =
PackageIdentifier (mkPackageName "cabal-install")
(mkVersion' Paths_cabal_install.version)
PackageIdentifier (mkPackageName "cabal-install") cabalInstallVersion

-- ------------------------------------------------------------
-- * External format
Expand Down
8 changes: 3 additions & 5 deletions cabal-install/Distribution/Client/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ import Distribution.Simple.Program
( defaultProgramDb )
import Distribution.Simple.Utils
( die', notice, warn, lowercase, cabalVersion )
import Distribution.Client.Utils
( cabalInstallVersion )
import Distribution.Compiler
( CompilerFlavor(..), defaultCompilerFlavor )
import Distribution.Verbosity
Expand Down Expand Up @@ -145,10 +147,6 @@ import Distribution.Compat.Environment
( getEnvironment, lookupEnv )
import Distribution.Compat.Exception
( catchIO )
import qualified Paths_cabal_install
( version )
import Data.Version
( showVersion )
import Data.Char
( isSpace )
import qualified Data.Map as M
Expand Down Expand Up @@ -829,7 +827,7 @@ writeConfigFile file comments vals = do
,"-- This config file was generated using the following versions"
,"-- of Cabal and cabal-install:"
,"-- Cabal library version: " ++ Text.display cabalVersion
,"-- cabal-install version: " ++ showVersion Paths_cabal_install.version
,"-- cabal-install version: " ++ Text.display cabalInstallVersion
,"",""
]

Expand Down
4 changes: 4 additions & 0 deletions cabal-install/Distribution/Client/GZipUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ import Distribution.Client.Compat.Prelude
import Codec.Compression.Zlib.Internal
import Data.ByteString.Lazy.Internal as BS (ByteString(Empty, Chunk))

#ifndef MIN_VERSION_zlib
#define MIN_VERSION_zlib(x,y,z) 1
#endif

#if MIN_VERSION_zlib(0,6,0)
import Control.Exception (throw)
import Control.Monad.ST.Lazy (ST, runST)
Expand Down
6 changes: 2 additions & 4 deletions cabal-install/Distribution/Client/HttpUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@ import Control.DeepSeq
( force )
import Control.Monad
( guard )
import qualified Paths_cabal_install (version)
import Distribution.Verbosity (Verbosity)
import Distribution.Pretty (prettyShow)
import Distribution.Simple.Utils
( die', info, warn, debug, notice
, copyFileVerbose, withTempFile, IOData (..) )
import Distribution.Client.Utils
( withTempFileName )
( withTempFileName, cabalInstallVersion )
import Distribution.Client.Types
( unRepoName, RemoteRepo(..) )
import Distribution.System
Expand Down Expand Up @@ -72,7 +71,6 @@ import Distribution.Simple.Program.Run
import Numeric (showHex)
import System.Random (randomRIO)
import System.Exit (ExitCode(..))
import Data.Version (showVersion)

import qualified Crypto.Hash.SHA256 as SHA256
import qualified Data.ByteString.Base16 as Base16
Expand Down Expand Up @@ -872,7 +870,7 @@ plainHttpTransport =
--

userAgent :: String
userAgent = concat [ "cabal-install/", showVersion Paths_cabal_install.version
userAgent = concat [ "cabal-install/", prettyShow cabalInstallVersion
, " (", prettyShow buildOS, "; ", prettyShow buildArch, ")"
]

Expand Down
4 changes: 2 additions & 2 deletions cabal-install/Distribution/Client/ProjectPlanOutput.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import Distribution.Client.Types.PackageLocation (PackageLocation(..))
import Distribution.Client.Types.ConfiguredId (confInstId)
import Distribution.Client.Types.SourceRepo (SourceRepoMaybe, SourceRepositoryPackage (..))
import Distribution.Client.HashValue (showHashValue, hashValue)
import Distribution.Client.Utils (cabalInstallVersion)

import qualified Distribution.Client.InstallPlan as InstallPlan
import qualified Distribution.Client.Utils.Json as J
Expand All @@ -49,7 +50,6 @@ import Distribution.Compat.Graph (Graph, Node)
import qualified Distribution.Compat.Binary as Binary
import Distribution.Simple.Utils
import Distribution.Verbosity
import qualified Paths_cabal_install as Our (version)

import Prelude ()
import Distribution.Client.Compat.Prelude
Expand Down Expand Up @@ -90,7 +90,7 @@ encodePlanAsJson :: DistDirLayout -> ElaboratedInstallPlan -> ElaboratedSharedCo
encodePlanAsJson distDirLayout elaboratedInstallPlan elaboratedSharedConfig =
--TODO: [nice to have] include all of the sharedPackageConfig and all of
-- the parts of the elaboratedInstallPlan
J.object [ "cabal-version" J..= jdisplay Our.version
J.object [ "cabal-version" J..= jdisplay cabalInstallVersion
, "cabal-lib-version" J..= jdisplay cabalVersion
, "compiler-id" J..= (J.String . showCompilerId . pkgConfigCompiler)
elaboratedSharedConfig
Expand Down
15 changes: 14 additions & 1 deletion cabal-install/Distribution/Client/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ module Distribution.Client.Utils ( MergeResult(..)
, tryFindPackageDesc
, relaxEncodingErrors
, ProgressPhase (..)
, progressMessage)
, progressMessage
, cabalInstallVersion)
where

import Prelude ()
Expand All @@ -29,6 +30,7 @@ import Distribution.Compat.Environment
import Distribution.Compat.Exception ( catchIO )
import Distribution.Compat.Time ( getModTime )
import Distribution.Simple.Setup ( Flag(..) )
import Distribution.Version
import Distribution.Verbosity
import Distribution.Simple.Utils ( die', findPackageDesc, noticeNoWrap )
import qualified Data.ByteString.Lazy as BS
Expand Down Expand Up @@ -61,6 +63,10 @@ import qualified System.Directory as Dir
import qualified System.IO.Error as IOError
#endif

#ifndef __DOCTEST__
import qualified Paths_cabal_install (version)
#endif

-- | Generic merging utility. For sorted input lists this is a full outer join.
--
mergeBy :: (a -> b -> Ordering) -> [a] -> [b] -> [MergeResult a b]
Expand Down Expand Up @@ -356,3 +362,10 @@ progressMessage verbosity phase subject = do
ProgressHaddock -> "Haddock "
ProgressInstalling -> "Installing "
ProgressCompleted -> "Completed "

cabalInstallVersion :: Version
#ifdef __DOCTEST__
cabalInstallVersion = mkVersion [3,3]
#else
cabalInstallVersion = mkVersion' Paths_cabal_install.version
#endif
2 changes: 1 addition & 1 deletion cabal-install/Distribution/Client/VCS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ svnProgram = (simpleProgram "svn") {
--
-- % cat foo
-- first line
-- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-- >> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-- branch BBB
-- ================================
-- branch AAA
Expand Down