-
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
Finish off external commands feature #9412
Finish off external commands feature #9412
Conversation
mpickering
commented
Nov 6, 2023
c3b8109
to
02605e9
Compare
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.
LGTM! Great to have this feature rewritten in better shape, thanks a lot for that and all the corner cases you spotted and fixed :)
I'm new to Cabal
contributors and not sure to understand the point of adding new LICENSE
files?
They're added for the tests, which are implemented as full Cabal packages and therefore require license files. |
02605e9
to
56a8cb6
Compare
@@ -355,6 +355,28 @@ mainWorker args = do | |||
warnIfAssertionsAreEnabled | |||
action globalFlags | |||
where | |||
delegateToExternal :: [Command Action] |
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.
The logic for finding and calling subcommands is now contained solely here (inside cabal-install
) rather than leaking into the Cabal
library.
-> IO (CommandParse action) | ||
defaultCommandFallback commands' name _cmdArgs = pure $ badCommand commands' name | ||
|
||
commandsRunWithFallback |
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.
commandRun
is parameterised by a continuation which is used to handle the fallback case in different ways for Cabal
and cabal-install
.
-> [String] | ||
-> IO (CommandParse Action) | ||
delegateToExternal commands' name cmdArgs = do | ||
mCommand <- findProgramOnSearchPath normal defaultProgramSearchPath ("cabal-" <> name) |
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.
I thought this would fix the test failure on windows but it still seems to persist.
2a803aa
to
ec076de
Compare
I have fixed CI now, so this patch is ready to merge. |
I've given @yvan-sraka the Triage authority which, once accepted, will make the review binding for github. @mpickering: feel free to set a merge label, unless you'd like more reviews, in which case, please set the appropriate label, too. |
It turns out Write permission is needed for reviews to be counted for the 2-review threshold, so I've given this high level of authority to @yvan-sraka. I hope in 2 days this gets auto-merged. (Let me rebase via mergify just in case; edit: especially that CI mandatory tests settings have changed, so this is stuck.) |
@mergify rebase |
✅ Branch has been successfully rebased |
ec076de
to
1c3bd64
Compare
This adds 4 tests which test the new external commands feature: * ExternalCommand - Tests the expected usage of external command invoked via cabal-install * ExternalCommandSetup - Tests that the ./Setup interface does not support external commands (haskell#9403) * ExternalCommandEnv - Tests that environment variables are set and preserved appropiately (haskell#9402) * ExternalCommandHelp - Test that `cabal help <cmd>` is interpreted appropiately (haskell#9404)
* Remove 'CommandDelegate' in favour of abstracting the fallback in 'commandsRun', there is a new variant 'commdandRunWithFallback' which takes a continuation - This restores the modularity between the `Cabal` library and `cabal-install` as now `Cabal` doesn't need to know anything about the external command interface. - Fixes haskell#9403 * Set the $CABAL environment variable to the current executable path - This allows external commands to be implemented by calling $CABAL, which is strongly preferred to linking against the Cabal library as there is no easy way to guantee your tool and `cabal-install` link against the same `Cabal` library. - Fixes haskell#9402 * Pass the name of the argument - This allows external commands to be implemented as symlinks to an executable, and multiple commands can be interpreted by the same executable. - Fixes haskell#9405 * `cabal help <cmd>` is interpreted as `cabal-<cmd> --help` for external commands. - This allows the `help` command to also work for external commands and hence they are better integrated into cabal-install. - Fixes haskell#9404 The tests are updated to test all these additions. These features bring the external command interface up to par with the cargo external command interface.
1c3bd64
to
d8ebb81
Compare
I took the liberty of making up for the admin delays by setting the merge_delay_passed label manually. The PR is ready and reviewed since last week. |