-
Notifications
You must be signed in to change notification settings - Fork 697
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
standalone tests for cabal init
#7424
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
11ffc58
Non-interactive workflow for standalone tests
ptkato e9032c0
Interactive workflow for standalone tests
ptkato 12c2274
Simple workflow for standalone tests
ptkato 73bab9f
Removing lib dependency from test only targets
ptkato 965db57
Fixing test prompt for interactive
ptkato 1128e38
Golden testing for standalone test stanza
ptkato 5866938
Changelog entry and docs update for #7424
ptkato 7954c10
Code formatting and comments
ptkato File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,6 +164,7 @@ createProjectTest pkgIx srcDb = testGroup "createProject tests" | |
-- language | ||
, "2" | ||
-- test target | ||
, "y" | ||
-- main file | ||
, "1" | ||
-- test dir | ||
|
@@ -174,7 +175,7 @@ createProjectTest pkgIx srcDb = testGroup "createProject tests" | |
, "y" | ||
] | ||
|
||
case (_runPrompt $ createProject silent pkgIx srcDb (emptyFlags {initializeTestSuite = Flag True})) 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 | ||
|
@@ -258,6 +259,7 @@ createProjectTest pkgIx srcDb = testGroup "createProject tests" | |
-- language | ||
, "2" | ||
-- test target | ||
, "y" | ||
-- main file | ||
, "1" | ||
-- test dir | ||
|
@@ -268,7 +270,7 @@ createProjectTest pkgIx srcDb = testGroup "createProject tests" | |
, "y" | ||
] | ||
|
||
case (_runPrompt $ createProject silent pkgIx srcDb (emptyFlags {initializeTestSuite = Flag True})) 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 | ||
|
@@ -311,6 +313,79 @@ createProjectTest pkgIx srcDb = testGroup "createProject tests" | |
exe @?= Nothing | ||
test @?! Nothing | ||
Left e -> assertFailure $ show e | ||
|
||
, testCase "Check the interactive library workflow" $ do | ||
let inputs = fromList | ||
-- package type | ||
[ "4" | ||
-- package dir | ||
, "test-package" | ||
-- package description | ||
-- cabal version | ||
, "4" | ||
-- package name | ||
, "test-package" | ||
, "test-package" | ||
-- version | ||
, "3.1.2.3" | ||
-- license | ||
, "3" | ||
-- author | ||
, "Foobar" | ||
, "[email protected]" | ||
-- homepage | ||
, "qux.com" | ||
-- synopsis | ||
, "Qux's package" | ||
-- category | ||
, "3" | ||
-- test target | ||
-- main file | ||
, "1" | ||
-- test dir | ||
, "test" | ||
-- language | ||
, "1" | ||
-- comments | ||
, "y" | ||
] | ||
|
||
case (_runPrompt $ createProject silent pkgIx srcDb emptyFlags) inputs of | ||
Right (ProjectSettings opts desc Nothing Nothing (Just test), _) -> do | ||
_optOverwrite opts @?= False | ||
_optMinimal opts @?= False | ||
_optNoComments opts @?= False | ||
_optVerbosity opts @?= silent | ||
_optPkgDir opts @?= "/home/test/test-package" | ||
_optPkgType opts @?= TestSuite | ||
_optPkgName opts @?= mkPackageName "test-package" | ||
|
||
_pkgCabalVersion desc @?= CabalSpecV2_4 | ||
_pkgName desc @?= mkPackageName "test-package" | ||
_pkgVersion desc @?= mkVersion [3,1,2,3] | ||
_pkgLicense desc @?! SPDX.NONE | ||
_pkgAuthor desc @?= "Foobar" | ||
_pkgEmail desc @?= "[email protected]" | ||
_pkgHomePage desc @?= "qux.com" | ||
_pkgSynopsis desc @?= "Qux's package" | ||
_pkgCategory desc @?= "Control" | ||
_pkgExtraSrcFiles desc @?= mempty | ||
_pkgExtraDocFiles desc @?= pure (Set.singleton "CHANGELOG.md") | ||
|
||
_testMainIs test @?= HsFilePath "Main.hs" Standard | ||
_testDirs test @?= ["test"] | ||
_testLanguage test @?= Haskell2010 | ||
_testOtherModules test @?= [] | ||
_testOtherExts test @?= [] | ||
_testDependencies test @?! [] | ||
_testBuildTools test @?= [] | ||
|
||
Right (ProjectSettings _ _ lib exe test, _) -> do | ||
lib @?= Nothing | ||
exe @?= Nothing | ||
test @?! Nothing | ||
Left e -> assertFailure $ show e | ||
] | ||
, testGroup "without tests" | ||
[ testCase "Check the interactive library and executable workflow" $ do | ||
|
@@ -668,13 +743,13 @@ fileCreatorTests pkgIx srcDb _pkgName = testGroup "generators" | |
, testGroup "genTestTarget" | ||
[ testCase "Check test package flags workflow" $ do | ||
let inputs = fromList | ||
[ "1" -- pick the first main file option in the list | ||
[ "y" -- say yes to tests | ||
, "1" -- pick the first main file option in the list | ||
, "test" -- package test dir | ||
, "1" -- pick the first language in the list | ||
] | ||
|
||
runGenTest inputs $ genTestTarget | ||
(emptyFlags {initializeTestSuite = Flag True}) pkgIx | ||
runGenTest inputs $ genTestTarget emptyFlags pkgIx | ||
] | ||
] | ||
where | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. that's easy i suppose.