Commit 3d4db709 authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

Partial documentation for solver DSL unit tests.


Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
parent a7bd866c
......@@ -136,6 +136,15 @@ data ExampleAvailable = ExAv {
, exAvDeps :: ComponentDeps [ExampleDependency]
} deriving Show
-- | Constructs an 'ExampleAvailable' package for the 'ExampleDb',
-- given:
--
-- 1. The name 'ExamplePkgName' of the available package,
-- 2. The version 'ExamplePkgVersion' available
-- 3. The list of dependency constraints 'ExampleDependency'
-- that this package has. 'ExampleDependency' provides
-- a number of pre-canned dependency types to look at.
--
exAv :: ExamplePkgName -> ExamplePkgVersion -> [ExampleDependency]
-> ExampleAvailable
exAv n v ds = ExAv { exAvName = n, exAvVersion = v
......@@ -146,6 +155,7 @@ withSetupDeps ex setupDeps = ex {
exAvDeps = exAvDeps ex <> CD.fromSetupDeps setupDeps
}
-- | An installed package in 'ExampleDb'; construct me with 'exInst'.
data ExampleInstalled = ExInst {
exInstName :: ExamplePkgName
, exInstVersion :: ExamplePkgVersion
......@@ -153,10 +163,23 @@ data ExampleInstalled = ExInst {
, exInstBuildAgainst :: [ExamplePkgHash]
} deriving Show
-- | Constructs an example installed package given:
--
-- 1. The name of the package 'ExamplePkgName', i.e., 'String'
-- 2. The version of the package 'ExamplePkgVersion', i.e., 'Int'
-- 3. The IPID for the package 'ExamplePkgHash', i.e., 'String'
-- (just some unique identifier for the package.)
-- 4. The 'ExampleInstalled' packages which this package was
-- compiled against.)
--
exInst :: ExamplePkgName -> ExamplePkgVersion -> ExamplePkgHash
-> [ExampleInstalled] -> ExampleInstalled
exInst pn v hash deps = ExInst pn v hash (map exInstHash deps)
-- | An example package database is a list of installed packages
-- 'ExampleInstalled' and available packages 'ExampleAvailable'.
-- Generally, you want to use 'exInst' and 'exAv' to construct
-- these packages.
type ExampleDb = [Either ExampleInstalled ExampleAvailable]
type DependencyTree a = C.CondTree C.ConfVar [C.Dependency] a
......
......@@ -122,6 +122,9 @@ tests = [
]
]
where
-- | Combinator to turn on --independent-goals behavior, i.e. solve
-- for the goals as if we were solving for each goal independently.
-- (This doesn't really work well at the moment, see #2842)
indep test = test { testIndepGoals = IndepGoals True }
soft prefs test = test { testSoftConstraints = prefs }
mkvrThis = V.thisVersion . makeV
......@@ -144,6 +147,19 @@ data SolverTest = SolverTest {
, testPkgConfigDb :: PkgConfigDb
}
-- | Makes a solver test case, consisting of the following components:
--
-- 1. An 'ExampleDb', representing the package database (both
-- installed and remote) we are doing dependency solving over,
-- 2. A 'String' name for the test,
-- 3. A list '[String]' of package names to solve for
-- 4. The expected result, either 'Nothing' if there is no
-- satisfying solution, or a list '[(String, Int)]' of
-- packages to install, at which versions.
--
-- See 'UnitTests.Distribution.Client.Dependency.Modular.DSL' for how
-- to construct an 'ExampleDb', as well as definitions of 'db1' etc.
-- in this file.
mkTest :: ExampleDb
-> String
-> [String]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment