Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
Packages
Cabal
Commits
3aee78dd
Commit
3aee78dd
authored
Dec 18, 2016
by
kristenk
Committed by
Edward Z. Yang
Dec 26, 2016
Browse files
Add a test for incremental cycle detection.
parent
f4f57f24
Changes
1
Hide whitespace changes
Inline
Side-by-side
cabal-install/tests/UnitTests/Distribution/Solver/Modular/Solver.hs
View file @
3aee78dd
...
@@ -86,6 +86,7 @@ tests = [
...
@@ -86,6 +86,7 @@ tests = [
,
runTest
$
mkTest
db15
"cycleThroughSetupDep3"
[
"C"
]
(
solverSuccess
[(
"C"
,
2
),
(
"D"
,
1
)])
,
runTest
$
mkTest
db15
"cycleThroughSetupDep3"
[
"C"
]
(
solverSuccess
[(
"C"
,
2
),
(
"D"
,
1
)])
,
runTest
$
mkTest
db15
"cycleThroughSetupDep4"
[
"D"
]
(
solverSuccess
[(
"D"
,
1
)])
,
runTest
$
mkTest
db15
"cycleThroughSetupDep4"
[
"D"
]
(
solverSuccess
[(
"D"
,
1
)])
,
runTest
$
mkTest
db15
"cycleThroughSetupDep5"
[
"E"
]
(
solverSuccess
[(
"C"
,
2
),
(
"D"
,
1
),
(
"E"
,
1
)])
,
runTest
$
mkTest
db15
"cycleThroughSetupDep5"
[
"E"
]
(
solverSuccess
[(
"C"
,
2
),
(
"D"
,
1
),
(
"E"
,
1
)])
,
runTest
$
testCyclicDependencyErrorMessages
"cyclic dependency error messages"
]
]
,
testGroup
"Extensions"
[
,
testGroup
"Extensions"
[
runTest
$
mkTestExts
[
EnableExtension
CPP
]
dbExts1
"unsupported"
[
"A"
]
anySolverFailure
runTest
$
mkTestExts
[
EnableExtension
CPP
]
dbExts1
"unsupported"
[
"A"
]
anySolverFailure
...
@@ -500,6 +501,39 @@ db15 = [
...
@@ -500,6 +501,39 @@ db15 = [
,
Right
$
exAv
"E"
1
[
ExFix
"C"
2
]
,
Right
$
exAv
"E"
1
[
ExFix
"C"
2
]
]
]
-- | Packages pkg-A, pkg-B, and pkg-C form a cycle. The solver should backtrack
-- as soon as it chooses the last package in the cycle, to avoid searching parts
-- of the tree that have no solution. Since there is no way to break the cycle,
-- it should fail with an error message describing the cycle.
testCyclicDependencyErrorMessages
::
String
->
SolverTest
testCyclicDependencyErrorMessages
name
=
goalOrder
goals
$
mkTest
db
name
[
"pkg-A"
]
$
SolverResult
checkFullLog
$
Left
checkSummarizedLog
where
db
::
ExampleDb
db
=
[
Right
$
exAv
"pkg-A"
1
[
ExAny
"pkg-B"
]
,
Right
$
exAv
"pkg-B"
1
[
ExAny
"pkg-C"
]
,
Right
$
exAv
"pkg-C"
1
[
ExAny
"pkg-A"
,
ExAny
"pkg-D"
]
,
Right
$
exAv
"pkg-D"
1
[
ExAny
"pkg-E"
]
,
Right
$
exAv
"pkg-E"
1
[]
]
-- The solver should backtrack as soon as pkg-A, pkg-B, and pkg-C form a
-- cycle. It shouldn't try pkg-D or pkg-E.
checkFullLog
::
[
String
]
->
Bool
checkFullLog
=
not
.
any
(
\
l
->
"pkg-D"
`
isInfixOf
`
l
||
"pkg-E"
`
isInfixOf
`
l
)
checkSummarizedLog
::
String
->
Bool
checkSummarizedLog
=
isInfixOf
"rejecting: pkg-C-1.0.0 (cyclic dependencies; conflict set: pkg-A, pkg-B, pkg-C)"
-- Solve for pkg-D and pkg-E last.
goals
::
[
ExampleVar
]
goals
=
[
P
None
(
"pkg-"
++
[
c
])
|
c
<-
[
'A'
..
'E'
]]
-- | Check that the solver can backtrack after encountering the SIR (issue #2843)
-- | Check that the solver can backtrack after encountering the SIR (issue #2843)
--
--
-- When A and B are installed as independent goals, the single instance
-- When A and B are installed as independent goals, the single instance
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment