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

New build exception handling #3416

Merged
merged 3 commits into from
May 14, 2016
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
2 changes: 1 addition & 1 deletion Cabal/misc/gen-extra-source-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fi
set -ex

git ls-files tests \
| awk '/\.(hs|lhs|c|sh|cabal|hsc|err|out|in)$|ghc/ { print } { next }' \
| awk '/\.(hs|lhs|c|sh|cabal|hsc|err|out|in|project)$|ghc/ { print } { next }' \
| awk '/Check.hs$|UnitTests|PackageTester|autogen|register.sh|PackageTests.hs|IntegrationTests.hs|CreatePipe|^tests\/Test/ { next } { print }' \
| LC_ALL=C sort \
| sed -e 's/^/ /' \
Expand Down
10 changes: 6 additions & 4 deletions cabal-install/Distribution/Client/CmdBuild.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ buildAction (configFlags, configExFlags, installFlags, haddockFlags)

printPlan verbosity buildCtx

unless (buildSettingDryRun buildSettings) $
runProjectBuildPhase
verbosity
buildCtx
unless (buildSettingDryRun buildSettings) $ do
_plan <- runProjectBuildPhase
verbosity
buildCtx
--TODO: [required eventually] report on build failures in residual plan
return ()
where
verbosity = fromFlagOrDefault normal (configVerbosity configFlags)

Expand Down
10 changes: 6 additions & 4 deletions cabal-install/Distribution/Client/CmdRepl.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ replAction (configFlags, configExFlags, installFlags, haddockFlags)

printPlan verbosity buildCtx

unless (buildSettingDryRun buildSettings) $
runProjectBuildPhase
verbosity
buildCtx
unless (buildSettingDryRun buildSettings) $ do
_plan <- runProjectBuildPhase
verbosity
buildCtx
--TODO: [required eventually] report on build failures in residual plan
return ()
where
verbosity = fromFlagOrDefault normal (configVerbosity configFlags)

Expand Down
18 changes: 13 additions & 5 deletions cabal-install/Distribution/Client/ProjectBuilding.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,8 @@ buildInplaceUnpackedPackage verbosity
-- Configure phase
--
whenReConfigure $ do
setup configureCommand configureFlags []
annotateFailure ConfigureFailed $
setup configureCommand configureFlags []
invalidatePackageRegFileMonitor packageFileMonitor
updatePackageConfigFileMonitor packageFileMonitor srcdir pkg

Expand All @@ -1143,7 +1144,8 @@ buildInplaceUnpackedPackage verbosity

whenRebuild $ do
timestamp <- beginUpdateFileMonitor
setup buildCommand buildFlags buildArgs
annotateFailure BuildFailed $
setup buildCommand buildFlags buildArgs

--TODO: [required eventually] this doesn't track file
--non-existence, so we could fail to rebuild if someone
Expand All @@ -1154,7 +1156,7 @@ buildInplaceUnpackedPackage verbosity
pkg buildStatus
allSrcFiles buildSuccess

ipkgs <- whenReRegister $ do
ipkgs <- whenReRegister $ annotateFailure InstallFailed $ do
-- Register locally
ipkgs <- if pkgRequiresRegistration pkg
then do
Expand Down Expand Up @@ -1228,10 +1230,12 @@ buildInplaceUnpackedPackage verbosity
-- Repl phase
--
whenRepl $
annotateFailure BuildFailed $
setup replCommand replFlags replArgs

-- Haddock phase
whenHaddock $
annotateFailure BuildFailed $
setup haddockCommand haddockFlags []

return (BuildSuccess ipkgs buildSuccess)
Expand Down Expand Up @@ -1315,8 +1319,12 @@ annotateFailure annotate action =
]
where
handler :: Exception e => e -> IO a
handler = throwIO . annotate . show
--TODO: [nice to have] use displayException when available
handler = throwIO . annotate
#if MIN_VERSION_base(4,8,0)
. displayException
#else
. show
#endif


withTempInstalledPackageInfoFiles :: Verbosity -> FilePath
Expand Down
1 change: 1 addition & 0 deletions cabal-install/Distribution/Client/ProjectConfig.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module Distribution.Client.ProjectConfig (

-- * Packages within projects
ProjectPackageLocation(..),
BadPackageLocations(..),
BadPackageLocation(..),
BadPackageLocationMatch(..),
findProjectPackages,
Expand Down
18 changes: 8 additions & 10 deletions cabal-install/Distribution/Client/ProjectOrchestration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,14 @@ runProjectPreBuildPhase
--
runProjectBuildPhase :: Verbosity
-> ProjectBuildContext
-> IO ()
runProjectBuildPhase verbosity ProjectBuildContext {..} = do
_ <- rebuildTargets verbosity
distDirLayout
elaboratedPlan
elaboratedShared
pkgsBuildStatus
buildSettings
--TODO return the result plan and use it for other status reporting
return ()
-> IO ElaboratedInstallPlan
runProjectBuildPhase verbosity ProjectBuildContext {..} =
rebuildTargets verbosity
distDirLayout
elaboratedPlan
elaboratedShared
pkgsBuildStatus
buildSettings

-- Note that it is a deliberate design choice that the 'buildTargets' is
-- not passed to phase 1, and the various bits of input config is not
Expand Down
65 changes: 65 additions & 0 deletions cabal-install/cabal-install.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Extra-Source-Files:
tests/IntegrationTests/freeze/freezes_transitive_dependencies.sh
tests/IntegrationTests/freeze/my.cabal
tests/IntegrationTests/freeze/runs_without_error.sh
tests/IntegrationTests/internal-libs/cabal.project
tests/IntegrationTests/internal-libs/internal_lib_basic.sh
tests/IntegrationTests/internal-libs/internal_lib_shadow.sh
tests/IntegrationTests/internal-libs/new_build.sh
Expand All @@ -85,6 +86,7 @@ Extra-Source-Files:
tests/IntegrationTests/multiple-source/q/Setup.hs
tests/IntegrationTests/multiple-source/q/q.cabal
tests/IntegrationTests/new-build/monitor_cabal_files.sh
tests/IntegrationTests/new-build/monitor_cabal_files/cabal.project
tests/IntegrationTests/new-build/monitor_cabal_files/p/P.hs
tests/IntegrationTests/new-build/monitor_cabal_files/p/Setup.hs
tests/IntegrationTests/new-build/monitor_cabal_files/p/p.cabal
Expand Down Expand Up @@ -119,6 +121,12 @@ Extra-Source-Files:
tests/IntegrationTests/user-config/runs_without_error.sh
tests/IntegrationTests/user-config/uses_CABAL_CONFIG.out
tests/IntegrationTests/user-config/uses_CABAL_CONFIG.sh
tests/IntegrationTests2.hs
tests/IntegrationTests2/exception/build/Main.hs
tests/IntegrationTests2/exception/build/a.cabal
tests/IntegrationTests2/exception/configure/a.cabal
tests/IntegrationTests2/exception/no-pkg/empty.in
tests/IntegrationTests2/exception/no-pkg2/cabal.project
-- END gen-extra-source-files

source-repository head
Expand Down Expand Up @@ -464,6 +472,7 @@ Test-Suite solver-quickcheck

default-language: Haskell2010

-- Integration tests that call the cabal executable externally
test-suite integration-tests
type: exitcode-stdio-1.0
hs-source-dirs: tests
Expand Down Expand Up @@ -491,6 +500,62 @@ test-suite integration-tests
ghc-options: -Wall
default-language: Haskell2010

-- Integration tests that use the cabal-install code directly
-- but still build whole projects
test-suite integration-tests2
type: exitcode-stdio-1.0
main-is: IntegrationTests2.hs
hs-source-dirs: tests, .
ghc-options: -Wall -fwarn-tabs
other-modules:
build-depends:
async,
array,
base,
base16-bytestring,
binary,
bytestring,
Cabal,
containers,
cryptohash-sha256,
directory,
filepath,
hackage-security,
hashable,
HTTP,
mtl,
network,
network-uri,
pretty,
process,
random,
stm,
tar,
time,
zlib,
tasty,
tasty-hunit

if flag(old-bytestring)
build-depends: bytestring-builder

if flag(old-directory)
build-depends: old-time

if impl(ghc < 7.6)
build-depends: ghc-prim >= 0.2 && < 0.3

if os(windows)
build-depends: Win32
else
build-depends: unix

if arch(arm)
cc-options: -DCABAL_NO_THREADED
else
ghc-options: -threaded
default-language: Haskell2010

custom-setup
setup-depends: Cabal >= 1.25,
base,
Expand Down
Loading