Skip to content

Commit

Permalink
Update UnitTest regarding _runPrompt rename
Browse files Browse the repository at this point in the history
  • Loading branch information
bcardiff committed Aug 18, 2024
1 parent d2e597e commit f960e22
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ tests _v _initFlags comp pkgIx srcDb =
"False"
]

case flip _runPrompt inputs $ do
case flip runPrompt inputs $ do
projSettings <- createProject comp silent pkgIx srcDb dummyFlags'
writeProject projSettings of
Left (BreakException ex) -> assertFailure $ show ex
Expand Down
10 changes: 5 additions & 5 deletions cabal-install/tests/UnitTests/Distribution/Client/Init/Golden.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ goldenPkgDescTests v srcDb pkgDir pkgName =
]
where
runPkgDesc opts flags args = do
case _runPrompt (genPkgDescription flags srcDb) args of
case runPrompt (genPkgDescription flags srcDb) args of
Left e -> assertFailure $ show e
Right (pkg, _) -> mkStanza $ mkPkgDescription opts pkg

Expand Down Expand Up @@ -146,7 +146,7 @@ goldenExeTests v pkgIx pkgDir pkgName =
]
where
runGoldenExe opts args flags =
case _runPrompt (genExeTarget flags pkgIx) args of
case runPrompt (genExeTarget flags pkgIx) args of
Right (t, _) -> mkStanza [mkExeStanza opts $ t{_exeDependencies = mangleBaseDep t _exeDependencies}]
Left e -> assertFailure $ show e

Expand Down Expand Up @@ -192,7 +192,7 @@ goldenLibTests v pkgIx pkgDir pkgName =
]
where
runGoldenLib opts args flags =
case _runPrompt (genLibTarget flags pkgIx) args of
case runPrompt (genLibTarget flags pkgIx) args of
Right (t, _) -> mkStanza [mkLibStanza opts $ t{_libDependencies = mangleBaseDep t _libDependencies}]
Left e -> assertFailure $ show e

Expand Down Expand Up @@ -243,7 +243,7 @@ goldenTestTests v pkgIx pkgDir pkgName =
]
where
runGoldenTest opts args flags =
case _runPrompt (genTestTarget flags pkgIx) args of
case runPrompt (genTestTarget flags pkgIx) args of
Left e -> assertFailure $ show e
Right (Nothing, _) ->
assertFailure
Expand Down Expand Up @@ -286,7 +286,7 @@ goldenCabalTests v pkgIx srcDb =
]
where
runGoldenTest args flags =
case _runPrompt (createProject v pkgIx srcDb flags) args of
case runPrompt (createProject v pkgIx srcDb flags) args of
Left e -> assertFailure $ show e
(Right (ProjectSettings opts pkgDesc (Just libTarget) (Just exeTarget) (Just testTarget), _)) -> do
let pkgFields = mkPkgDescription opts pkgDesc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ createProjectTest pkgIx srcDb =
, dependencies = Flag []
}

case (_runPrompt $ createProject silent pkgIx srcDb dummyFlags') (fromList ["[]", "3", "quxTest/Main.hs"]) of
case (runPrompt $ createProject silent pkgIx srcDb dummyFlags') (fromList ["[]", "3", "quxTest/Main.hs"]) of
Right (ProjectSettings opts desc (Just lib) (Just exe) (Just test), _) -> do
_optOverwrite opts @?= False
_optMinimal opts @?= False
Expand Down Expand Up @@ -186,7 +186,7 @@ createProjectTest pkgIx srcDb =
"y"
]

case (_runPrompt $ createProject silent pkgIx srcDb emptyFlags) inputs of
case (runPrompt $ createProject silent pkgIx srcDb emptyFlags) inputs of
Right (ProjectSettings opts desc (Just lib) (Just exe) (Just test), _) -> do
_optOverwrite opts @?= False
_optMinimal opts @?= False
Expand Down Expand Up @@ -286,7 +286,7 @@ createProjectTest pkgIx srcDb =
"y"
]

case (_runPrompt $ createProject silent pkgIx srcDb emptyFlags) inputs of
case (runPrompt $ createProject silent pkgIx srcDb emptyFlags) inputs of
Right (ProjectSettings opts desc (Just lib) Nothing (Just test), _) -> do
_optOverwrite opts @?= False
_optMinimal opts @?= False
Expand Down Expand Up @@ -372,7 +372,7 @@ createProjectTest pkgIx srcDb =
"y"
]

case (_runPrompt $ createProject silent pkgIx srcDb emptyFlags) inputs of
case (runPrompt $ createProject silent pkgIx srcDb emptyFlags) inputs of
Right (ProjectSettings opts desc Nothing Nothing (Just test), _) -> do
_optOverwrite opts @?= False
_optMinimal opts @?= False
Expand Down Expand Up @@ -460,7 +460,7 @@ createProjectTest pkgIx srcDb =
"y"
]

case (_runPrompt $ createProject silent pkgIx srcDb emptyFlags) inputs of
case (runPrompt $ createProject silent pkgIx srcDb emptyFlags) inputs of
Right (ProjectSettings opts desc (Just lib) (Just exe) Nothing, _) -> do
_optOverwrite opts @?= False
_optMinimal opts @?= False
Expand Down Expand Up @@ -546,7 +546,7 @@ createProjectTest pkgIx srcDb =
"y"
]

case (_runPrompt $ createProject silent pkgIx srcDb emptyFlags) inputs of
case (runPrompt $ createProject silent pkgIx srcDb emptyFlags) inputs of
Right (ProjectSettings opts desc (Just lib) Nothing Nothing, _) -> do
_optOverwrite opts @?= False
_optMinimal opts @?= False
Expand Down Expand Up @@ -631,7 +631,7 @@ createProjectTest pkgIx srcDb =
, extraSrc = Flag ["README.md"]
}

case (_runPrompt $ createProject silent pkgIx srcDb flags) inputs of
case (runPrompt $ createProject silent pkgIx srcDb flags) inputs of
Right (ProjectSettings opts desc (Just lib) Nothing Nothing, _) -> do
_optOverwrite opts @?= False
_optMinimal opts @?= False
Expand Down Expand Up @@ -709,7 +709,7 @@ createProjectTest pkgIx srcDb =
"y"
]

case (_runPrompt $ createProject silent pkgIx srcDb emptyFlags) inputs of
case (runPrompt $ createProject silent pkgIx srcDb emptyFlags) inputs of
Right (ProjectSettings opts desc Nothing (Just exe) Nothing, _) -> do
_optOverwrite opts @?= False
_optMinimal opts @?= False
Expand Down Expand Up @@ -809,7 +809,7 @@ fileCreatorTests pkgIx srcDb _pkgName =
]
]
where
runGenTest inputs go = case _runPrompt go inputs of
runGenTest inputs go = case runPrompt go inputs of
Left e -> assertFailure $ show e
Right{} -> return ()

Expand Down Expand Up @@ -1127,7 +1127,7 @@ testPrompt
-> [String]
-> TestTree
testPrompt label f g h input = testCase label $
case (_runPrompt $ f emptyFlags) (fromList input) of
case (runPrompt $ f emptyFlags) (fromList input) of
Left x -> g x -- :: BreakException
Right x -> h x -- :: (a, other inputs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ driverFunctionTest pkgIx srcDb comp =
, "[\"quxTest/Main.hs\"]"
]

case (_runPrompt $ createProject comp silent pkgIx srcDb dummyFlags') inputs of
case (runPrompt $ createProject comp silent pkgIx srcDb dummyFlags') inputs of
Right (ProjectSettings opts desc (Just lib) (Just exe) (Just test), _) -> do
_optOverwrite opts @?= False
_optMinimal opts @?= False
Expand Down Expand Up @@ -180,7 +180,7 @@ driverFunctionTest pkgIx srcDb comp =
"False"
]

case (_runPrompt $ createProject comp silent pkgIx srcDb dummyFlags') inputs of
case (runPrompt $ createProject comp silent pkgIx srcDb dummyFlags') inputs of
Right (ProjectSettings opts desc (Just lib) (Just exe) (Just test), _) -> do
_optOverwrite opts @?= False
_optMinimal opts @?= False
Expand Down Expand Up @@ -356,7 +356,7 @@ driverFunctionTest pkgIx srcDb comp =
, "[\"test/Main.hs\", \"test/Foo.hs\", \"test/bar.y\"]"
]

case ( _runPrompt $
case ( runPrompt $
createProject
comp
silent
Expand Down Expand Up @@ -508,7 +508,7 @@ driverFunctionTest pkgIx srcDb comp =
, "[\"test/Main.hs\", \"test/Foo.hs\", \"test/bar.y\"]"
]

case ( _runPrompt $
case ( runPrompt $
createProject
comp
silent
Expand Down Expand Up @@ -664,7 +664,7 @@ driverFunctionTest pkgIx srcDb comp =
, "[\"app/Main.hs\", \"src/Foo.hs\", \"src/bar.y\"]"
]

case (_runPrompt $ createProject comp silent pkgIx srcDb emptyFlags) inputs of
case (runPrompt $ createProject comp silent pkgIx srcDb emptyFlags) inputs of
Right (ProjectSettings opts desc (Just lib) (Just exe) Nothing, _) -> do
_optOverwrite opts @?= False
_optMinimal opts @?= False
Expand Down Expand Up @@ -774,7 +774,7 @@ driverFunctionTest pkgIx srcDb comp =
, "[\"app/Main.hs\", \"src/Foo.hs\", \"src/bar.y\"]"
]

case (_runPrompt $ createProject comp silent pkgIx srcDb emptyFlags) inputs of
case (runPrompt $ createProject comp silent pkgIx srcDb emptyFlags) inputs of
Right (ProjectSettings opts desc (Just lib) Nothing Nothing, _) -> do
_optOverwrite opts @?= False
_optMinimal opts @?= False
Expand Down Expand Up @@ -865,7 +865,7 @@ driverFunctionTest pkgIx srcDb comp =
, "[\"app/Main.hs\", \"src/Foo.hs\", \"src/bar.y\"]"
]

case (_runPrompt $ createProject comp silent pkgIx srcDb emptyFlags) inputs of
case (runPrompt $ createProject comp silent pkgIx srcDb emptyFlags) inputs of
Right (ProjectSettings opts desc Nothing (Just exe) Nothing, _) -> do
_optOverwrite opts @?= False
_optMinimal opts @?= False
Expand Down Expand Up @@ -931,7 +931,7 @@ fileCreatorTests pkgIx srcDb comp =
, "[]"
]

case (_runPrompt $ genPkgDescription emptyFlags srcDb) inputs of
case (runPrompt $ genPkgDescription emptyFlags srcDb) inputs of
Left e -> assertFailure $ show e
Right{} -> return ()
]
Expand Down Expand Up @@ -980,7 +980,7 @@ fileCreatorTests pkgIx srcDb comp =
, "[\"app/Main.hs\", \"src/Foo.hs\", \"src/bar.y\"]"
]

case (_runPrompt $ genLibTarget emptyFlags comp pkgIx defaultCabalVersion) inputs of
case (runPrompt $ genLibTarget emptyFlags comp pkgIx defaultCabalVersion) inputs of
Left e -> assertFailure $ show e
Right{} -> return ()
]
Expand Down Expand Up @@ -1021,7 +1021,7 @@ fileCreatorTests pkgIx srcDb comp =
, "[\"app/Main.hs\", \"src/Foo.hs\", \"src/bar.y\"]"
]

case (_runPrompt $ genExeTarget emptyFlags comp pkgIx defaultCabalVersion) inputs of
case (runPrompt $ genExeTarget emptyFlags comp pkgIx defaultCabalVersion) inputs of
Left e -> assertFailure $ show e
Right{} -> return ()
]
Expand Down Expand Up @@ -1058,7 +1058,7 @@ fileCreatorTests pkgIx srcDb comp =
]
flags = emptyFlags{initializeTestSuite = Flag True}

case (_runPrompt $ genTestTarget flags comp pkgIx defaultCabalVersion) inputs of
case (runPrompt $ genTestTarget flags comp pkgIx defaultCabalVersion) inputs of
Left e -> assertFailure $ show e
Right{} -> return ()
]
Expand Down Expand Up @@ -1403,7 +1403,7 @@ testGo
-> [String]
-> TestTree
testGo label f g h inputs = testCase label $
case (_runPrompt $ f emptyFlags) (NEL.fromList inputs) of
case (runPrompt $ f emptyFlags) (NEL.fromList inputs) of
Left x -> g x
Right x -> h x

Expand Down
14 changes: 7 additions & 7 deletions cabal-install/tests/UnitTests/Distribution/Client/Init/Simple.hs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ simpleCreateProjectTests v pkgIx srcDb pkgName =
Nothing
Nothing

case _runPrompt (createProject v pkgIx srcDb flags) inputs of
case runPrompt (createProject v pkgIx srcDb flags) inputs of
Left e -> assertFailure $ "Failed to create simple lib project: " ++ show e
Right (settings', _) -> settings @=? settings'
, testCase "Simple lib createProject - with tests" $ do
Expand All @@ -83,7 +83,7 @@ simpleCreateProjectTests v pkgIx srcDb pkgName =
Nothing
(Just $ simpleTestTarget (Just pkgName) baseDep)

case _runPrompt (createProject v pkgIx srcDb flags) inputs of
case runPrompt (createProject v pkgIx srcDb flags) inputs of
Left e -> assertFailure $ "Failed to create simple lib (with tests)project: " ++ show e
Right (settings', _) -> settings @=? settings'
, testCase "Simple exe createProject" $ do
Expand All @@ -97,7 +97,7 @@ simpleCreateProjectTests v pkgIx srcDb pkgName =
(Just $ simpleExeTarget Nothing baseDep)
Nothing

case _runPrompt (createProject v pkgIx srcDb flags) inputs of
case runPrompt (createProject v pkgIx srcDb flags) inputs of
Left e -> assertFailure $ "Failed to create simple exe project: " ++ show e
Right (settings', _) -> settings @=? settings'
, testCase "Simple lib+exe createProject - no tests" $ do
Expand All @@ -111,7 +111,7 @@ simpleCreateProjectTests v pkgIx srcDb pkgName =
(Just $ simpleExeTarget (Just pkgName) baseDep)
Nothing

case _runPrompt (createProject v pkgIx srcDb flags) inputs of
case runPrompt (createProject v pkgIx srcDb flags) inputs of
Left e -> assertFailure $ "Failed to create simple lib+exe project: " ++ show e
Right (settings', _) -> settings @=? settings'
, testCase "Simple lib+exe createProject - with tests" $ do
Expand All @@ -125,7 +125,7 @@ simpleCreateProjectTests v pkgIx srcDb pkgName =
(Just $ simpleExeTarget (Just pkgName) baseDep)
(Just $ simpleTestTarget (Just pkgName) baseDep)

case _runPrompt (createProject v pkgIx srcDb flags) inputs of
case runPrompt (createProject v pkgIx srcDb flags) inputs of
Left e -> assertFailure $ "Failed to create simple lib+exe (with tests) project: " ++ show e
Right (settings', _) -> settings @=? settings'
, testCase "Simple standalone tests" $ do
Expand All @@ -139,12 +139,12 @@ simpleCreateProjectTests v pkgIx srcDb pkgName =
Nothing
(Just $ simpleTestTarget Nothing baseDep)

case _runPrompt (createProject v pkgIx srcDb flags) inputs of
case runPrompt (createProject v pkgIx srcDb flags) inputs of
Left e -> assertFailure $ "Failed to create simple standalone test project: " ++ show e
Right (settings', _) -> settings @=? settings'
]
where
baseDep = case _runPrompt (getBaseDep pkgIx emptyFlags) $ fromList [] of
baseDep = case runPrompt (getBaseDep pkgIx emptyFlags) $ fromList [] of
Left e -> error $ show e
Right a -> fst a

Expand Down

0 comments on commit f960e22

Please sign in to comment.