From f960e2298ea1112e4c8e604f812a01e0ab42b129 Mon Sep 17 00:00:00 2001 From: "Brian J. Cardiff" Date: Sat, 17 Aug 2024 23:21:05 -0300 Subject: [PATCH] Update UnitTest regarding _runPrompt rename --- .../Distribution/Client/Init/FileCreators.hs | 2 +- .../Distribution/Client/Init/Golden.hs | 10 ++++---- .../Distribution/Client/Init/Interactive.hs | 20 ++++++++-------- .../Client/Init/NonInteractive.hs | 24 +++++++++---------- .../Distribution/Client/Init/Simple.hs | 14 +++++------ 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/cabal-install/tests/UnitTests/Distribution/Client/Init/FileCreators.hs b/cabal-install/tests/UnitTests/Distribution/Client/Init/FileCreators.hs index 38c488dd3a7..63a5774acb1 100644 --- a/cabal-install/tests/UnitTests/Distribution/Client/Init/FileCreators.hs +++ b/cabal-install/tests/UnitTests/Distribution/Client/Init/FileCreators.hs @@ -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 diff --git a/cabal-install/tests/UnitTests/Distribution/Client/Init/Golden.hs b/cabal-install/tests/UnitTests/Distribution/Client/Init/Golden.hs index 19efe2eea1a..78387d404da 100644 --- a/cabal-install/tests/UnitTests/Distribution/Client/Init/Golden.hs +++ b/cabal-install/tests/UnitTests/Distribution/Client/Init/Golden.hs @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/cabal-install/tests/UnitTests/Distribution/Client/Init/Interactive.hs b/cabal-install/tests/UnitTests/Distribution/Client/Init/Interactive.hs index eb125e6daa4..9ba237cbadc 100644 --- a/cabal-install/tests/UnitTests/Distribution/Client/Init/Interactive.hs +++ b/cabal-install/tests/UnitTests/Distribution/Client/Init/Interactive.hs @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 () @@ -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) diff --git a/cabal-install/tests/UnitTests/Distribution/Client/Init/NonInteractive.hs b/cabal-install/tests/UnitTests/Distribution/Client/Init/NonInteractive.hs index cd618622201..711d50c8e3b 100644 --- a/cabal-install/tests/UnitTests/Distribution/Client/Init/NonInteractive.hs +++ b/cabal-install/tests/UnitTests/Distribution/Client/Init/NonInteractive.hs @@ -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 @@ -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 @@ -356,7 +356,7 @@ driverFunctionTest pkgIx srcDb comp = , "[\"test/Main.hs\", \"test/Foo.hs\", \"test/bar.y\"]" ] - case ( _runPrompt $ + case ( runPrompt $ createProject comp silent @@ -508,7 +508,7 @@ driverFunctionTest pkgIx srcDb comp = , "[\"test/Main.hs\", \"test/Foo.hs\", \"test/bar.y\"]" ] - case ( _runPrompt $ + case ( runPrompt $ createProject comp silent @@ -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 @@ -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 @@ -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 @@ -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 () ] @@ -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 () ] @@ -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 () ] @@ -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 () ] @@ -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 diff --git a/cabal-install/tests/UnitTests/Distribution/Client/Init/Simple.hs b/cabal-install/tests/UnitTests/Distribution/Client/Init/Simple.hs index 13a12ba0827..bbe3c0401bb 100644 --- a/cabal-install/tests/UnitTests/Distribution/Client/Init/Simple.hs +++ b/cabal-install/tests/UnitTests/Distribution/Client/Init/Simple.hs @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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