Skip to content

Dependency solver quickcheck tests #3245

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

Merged
merged 1 commit into from
Mar 29, 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
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@ script:
- cp Setup.hs ./dist/setup/setup.hs
- ghc --make -odir ./dist/setup -hidir ./dist/setup -i -i. ./dist/setup/setup.hs -o ./dist/setup/setup -Wall -Werror -threaded # the command cabal-install would use to build setup

- cabal install happy
- cabal install --only-dependencies --enable-tests --enable-benchmarks
- ./dist/setup/setup configure --user --ghc-option=-Werror --enable-tests --enable-benchmarks -v2 # -v2 provides useful information for debugging
- ./dist/setup/setup build
- ./dist/setup/setup haddock # see https://github.com/haskell/cabal/issues/2198
- ./dist/setup/setup test --show-details=streaming --test-option=--hide-successes
- ./dist/setup/setup test unit-tests --show-details=streaming --test-option=--hide-successes
- ./dist/setup/setup test integration-tests --show-details=streaming --test-option=--hide-successes
- cabal check
- cabal sdist
- install_from_tarball
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ build_script:
- Setup install
- cd ..\cabal-install
- ghc --make -threaded -i -i. Setup.hs -Wall -Werror
- echo "" | ..\cabal install happy
- echo "" | ..\cabal install --only-dependencies --enable-tests
- ..\cabal configure --user --ghc-option=-Werror --enable-tests
- ..\cabal build
Expand Down
56 changes: 56 additions & 0 deletions cabal-install/cabal-install.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,62 @@ Test-Suite unit-tests
ghc-options: -threaded
default-language: Haskell2010

-- Slow solver tests
Test-Suite solver-quickcheck
type: exitcode-stdio-1.0
main-is: SolverQuickCheck.hs
hs-source-dirs: tests, .
ghc-options: -Wall -fwarn-tabs
other-modules:
UnitTests.Distribution.Client.Dependency.Modular.DSL
UnitTests.Distribution.Client.Dependency.Modular.QuickCheck
build-depends:
base,
array,
bytestring,
Cabal,
containers,
mtl,
pretty,
process,
directory,
filepath,
hashable,
stm,
tar,
time,
HTTP,
zlib,
binary,
random,
hackage-security,
tasty,
tasty-quickcheck,
QuickCheck >= 2.8.2,
pretty-show

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

if flag(network-uri)
build-depends: network-uri >= 2.6, network >= 2.6
else
build-depends: network-uri < 2.6, network < 2.6

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

test-suite integration-tests
type: exitcode-stdio-1.0
hs-source-dirs: tests
Expand Down
16 changes: 16 additions & 0 deletions cabal-install/tests/SolverQuickCheck.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module Main where

import Test.Tasty

import qualified UnitTests.Distribution.Client.Dependency.Modular.QuickCheck


tests :: TestTree
tests =
testGroup "Solver QuickCheck"
[ testGroup "UnitTests.Distribution.Client.Dependency.Modular.QuickCheck"
UnitTests.Distribution.Client.Dependency.Modular.QuickCheck.tests
]

main :: IO ()
main = defaultMain tests
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ module UnitTests.Distribution.Client.Dependency.Modular.DSL (
, ExampleDb
, ExampleVersionRange
, ExamplePkgVersion
, ExamplePkgName
, ExampleAvailable(..)
, ExampleInstalled(..)
, IndepGoals(..)
, ReorderGoals(..)
, exAv
, exInst
, exFlag
Expand Down Expand Up @@ -92,7 +97,9 @@ type ExamplePkgHash = String -- for example "installed" packages
type ExampleFlagName = String
type ExampleTestName = String
type ExampleVersionRange = C.VersionRange

data Dependencies = NotBuildable | Buildable [ExampleDependency]
deriving Show

data ExampleDependency =
-- | Simple dependency on any version
Expand All @@ -115,6 +122,7 @@ data ExampleDependency =

-- | Dependency on a pkg-config package
| ExPkg (ExamplePkgName, ExamplePkgVersion)
deriving Show

exFlag :: ExampleFlagName -> [ExampleDependency] -> [ExampleDependency]
-> ExampleDependency
Expand All @@ -126,7 +134,7 @@ data ExampleAvailable = ExAv {
exAvName :: ExamplePkgName
, exAvVersion :: ExamplePkgVersion
, exAvDeps :: ComponentDeps [ExampleDependency]
}
} deriving Show

exAv :: ExamplePkgName -> ExamplePkgVersion -> [ExampleDependency]
-> ExampleAvailable
Expand All @@ -142,17 +150,23 @@ data ExampleInstalled = ExInst {
exInstName :: ExamplePkgName
, exInstVersion :: ExamplePkgVersion
, exInstHash :: ExamplePkgHash
, exInstBuildAgainst :: [ExampleInstalled]
}
, exInstBuildAgainst :: [ExamplePkgHash]
} deriving Show

exInst :: ExamplePkgName -> ExamplePkgVersion -> ExamplePkgHash
-> [ExampleInstalled] -> ExampleInstalled
exInst = ExInst
exInst pn v hash deps = ExInst pn v hash (map exInstHash deps)

type ExampleDb = [Either ExampleInstalled ExampleAvailable]

type DependencyTree a = C.CondTree C.ConfVar [C.Dependency] a

newtype IndepGoals = IndepGoals Bool
deriving Show

newtype ReorderGoals = ReorderGoals Bool
deriving Show

exDbPkgs :: ExampleDb -> [ExamplePkgName]
exDbPkgs = map (either exInstName exAvName)

Expand Down Expand Up @@ -329,8 +343,7 @@ exInstInfo :: ExampleInstalled -> C.InstalledPackageInfo
exInstInfo ex = C.emptyInstalledPackageInfo {
C.installedUnitId = C.mkUnitId (exInstHash ex)
, C.sourcePackageId = exInstPkgId ex
, C.depends = map (C.mkUnitId . exInstHash)
(exInstBuildAgainst ex)
, C.depends = map C.mkUnitId (exInstBuildAgainst ex)
}

exInstPkgId :: ExampleInstalled -> C.PackageIdentifier
Expand All @@ -352,13 +365,15 @@ exResolve :: ExampleDb
-> Maybe [Language]
-> PC.PkgConfigDb
-> [ExamplePkgName]
-> Bool
-> Solver
-> IndepGoals
-> ReorderGoals
-> [ExPreference]
-> ([String], Either String CI.InstallPlan.InstallPlan)
exResolve db exts langs pkgConfigDb targets indepGoals prefs = runProgress $
exResolve db exts langs pkgConfigDb targets solver (IndepGoals indepGoals) (ReorderGoals reorder) prefs = runProgress $
resolveDependencies C.buildPlatform
compiler pkgConfigDb
Modular
solver
params
where
defaultCompiler = C.unknownCompilerInfo C.buildCompilerId C.NoAbiTag
Expand All @@ -377,9 +392,9 @@ exResolve db exts langs pkgConfigDb targets indepGoals prefs = runProgress $
targets' = fmap (\p -> NamedPackage (C.PackageName p) []) targets
params = addPreferences (fmap toPref prefs)
$ addConstraints (fmap toLpc enableTests)
$ (standardInstallPolicy instIdx avaiIdx targets') {
depResolverIndependentGoals = indepGoals
}
$ setIndependentGoals indepGoals
$ setReorderGoals reorder
$ standardInstallPolicy instIdx avaiIdx targets'
toLpc pc = LabeledPackageConstraint pc ConstraintSourceUnknown
toPref (ExPref n v) = PackageVersionPreference (C.PackageName n) v

Expand Down
Loading