Skip to content

pretty-print run targets on failure #8234

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

Merged
merged 2 commits into from
Aug 9, 2022
Merged

Conversation

mgsium
Copy link
Collaborator

@mgsium mgsium commented Jun 19, 2022

Resolves #8189; run targets are pretty-printed when failing due to multiple targets. Duplicates are also removed.

i.e.

$ cabal run all -- --help
Resolving dependencies...
Error: cabal: The run command is for running a single executable at once. The
target 'all' refers to all the packages in the project which includes
- executables: cabal, cabal-tests, hackage-benchmark and setup
- test-suites:
| * cabal-benchmarks
| * check-tests
| * custom-setup-tests
| * hackage-tests
| * integration-tests2
| * long-tests
| * mem-use-tests
| * no-thunks-test
| * parser-tests
| * rpmvercmp
| * unit-tests

@Mikolaj
Copy link
Member

Mikolaj commented Jun 20, 2022

Splendid. And you got the right CI breakage: on golden test of the old kind of output. [edit: which means you probably don't need to write separate tests]

@mgsium mgsium marked this pull request as ready for review June 20, 2022 16:50
@Mikolaj Mikolaj requested a review from andreasabel June 22, 2022 08:56
| CExeName UnqualComponentName
| CTestName UnqualComponentName
| CBenchName UnqualComponentName
data ComponentName = CLibName { toLibName :: LibraryName }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m worried about introduction of partial field accessors. The proper solution would be to factor out the other four fields into a separate data type (NonLibComponentName or some such), which could have a total accessor. Didn’t check how much churn that would involve.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If throw in some pattern synonyms on the top, the churn could actually be none.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can forego the field accessors entirely, given a function like

extract :: ComponentName -> Either LibraryName UnqualComponentName
extract (CLibName   s) = Left s
extract (CFLibName  s) = Right s
extract (CExeName   s) = Right s
extract (CTestName  s) = Right s
extract (CBenchName s) = Right s

that way we can avoid redefining types while keeping componentNameRaw and componentNameString simple.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like @ulysses4ever 's proposal. One can define pattern synonyms for CFLibName etc. so that the change to the codebase remains small.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could either of you show me what you have in mind? Perhaps my lack of understanding but I can't see the change to the codebase being smaller.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either-based idea is not bad too, but here's an example of what I meant (can compile and run to get "x")

{-# LANGUAGE PatternSynonyms #-}

type LibraryName = String
type UnqualComponentName = String

data NotLibComponentName
        = CNLFLibName  UnqualComponentName
        | CNLExeName   UnqualComponentName
        | CNLTestName  UnqualComponentName
        | CNLBenchName UnqualComponentName
data ComponentName
        = CLibName   LibraryName
        | CNotLibName NotLibComponentName
pattern CFLibName n = CNotLibName (CNLFLibName n)
// ... 3 more of these

main = print n
  where
    c = CFLibName "x" -- using bidirectional pattern to construct
    (CFLibName n) = c -- using bidirectional pattern to destruct

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(And then change NotLibComponentName to have a field accessor, and possibly some convenience function for ComponentName)

@Mikolaj
Copy link
Member

Mikolaj commented Jun 27, 2022

Something got stuck after recent CI improvements, so let me restart CI (and rebase just in case, @mgsium, I hope you don't mind?).

@Mikolaj
Copy link
Member

Mikolaj commented Jun 27, 2022

@Mergifyio rebase

@mergify
Copy link
Contributor

mergify bot commented Jun 27, 2022

rebase

✅ Branch has been successfully rebased

Copy link
Member

@Mikolaj Mikolaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (but @ulysses4ever has a point)

@mgsium
Copy link
Collaborator Author

mgsium commented Jul 2, 2022

Looks like {-# COMPLETE ... #-} is giving an unrecognized pragma warning on ghc version 8.0.2. Afaict from the docs, the COMPLETE pragma was introduced sometime after 8.0.2.

Suggestions as to how to proceed?

@Mikolaj
Copy link
Member

Mikolaj commented Jul 2, 2022

GHC 8.0.2 has just fallen out of our support window, but I struggle to comprehend the consequences. Probably that means we no longer want to extend our custom prelude nor add CPP for the sake of 8.0.2. If you can make it work, fine, if not, we drop GHC 8.0.2 from CI.

But IANAL, so let's wait until somebody confirms my understanding. :)

@ulysses4ever
Copy link
Collaborator

It’s a warning, right? Maybe just leave it be?

@ulysses4ever
Copy link
Collaborator

Oh, I missed -Werror (I was sure that I saw warnings in cabal codebase, but I guess not?)

Another idea is to stitch {-# OPTIONS_GHC -Wno-unrecognised-pragmas -Wno-incomplete-patterns #-} in the file. Not sure how good of an idea it is.

@ulysses4ever ulysses4ever self-requested a review July 3, 2022 23:50
@ulysses4ever
Copy link
Collaborator

@mgsium do you have any trouble with finishing it off? Please, let us know. I'm looking forward for this change!

@mgsium
Copy link
Collaborator Author

mgsium commented Jul 22, 2022

Apologies for the delay, I'll get this done

@mgsium
Copy link
Collaborator Author

mgsium commented Jul 22, 2022

On second thoughts, do we need -Wno-unrecognised-pragmas? It fails regardless on 8.0.2 and shouldn't give the warning on later versions.

Edit: Ignore that, I lost track of the reason for the change. Looking at the most recent CI, we'll also need {-# OPTIONS_GHC -Wno-incomplete-patterns #-} in any file where we use the patterns. Is it worth doing this to support 8.0.2 or should it be dropped?

@Mikolaj
Copy link
Member

Mikolaj commented Jul 22, 2022

Looking at the most recent CI, we'll also need {-# OPTIONS_GHC -Wno-incomplete-patterns #-} in any file where we use the patterns. Is it worth doing this to support 8.0.2 or should it be dropped?

Please feel free to drop support for 8.0.2 in all parts of CI where you need to (including all of CI). This PR is a good place for that, because it contains the reason for removing 8.0.2 and the discussion of it.

Copy link
Collaborator

@ulysses4ever ulysses4ever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ulysses4ever
Copy link
Collaborator

Another thing: if you could i-rebase in the way that there are two commits: removing 8.0.2 support and implementing the feature, that may be a cleaner history overall (as opposed to squashing all of that in one commit).

@mgsium
Copy link
Collaborator Author

mgsium commented Jul 23, 2022

Do we still need the options?

Nope we shouldn't, I'll remove and test before rebasing.

@ulysses4ever
Copy link
Collaborator

ulysses4ever commented Jul 31, 2022

This looks good to go. Who should apply the label? If the author doesn't hold the appropriate role for that, should we fix it too?

@Mikolaj
Copy link
Member

Mikolaj commented Aug 1, 2022

Oh, yes, let's get this merged. I forgot how the new system of permissions works. @mgsium: I've given you Triage rights to the repo. Are you now able to set the "merge_me" label? That should start the merge process, which ends in 2 days if there are no more changes to the PR.

@mgsium mgsium added the merge me Tell Mergify Bot to merge label Aug 3, 2022
@Mikolaj
Copy link
Member

Mikolaj commented Aug 5, 2022

@mgsium: hah, you've got yelled at due to whitespace. See https://github.com/haskell/cabal/blob/master/CONTRIBUTING.md#whitespace-conventions

@Mikolaj
Copy link
Member

Mikolaj commented Aug 5, 2022

Perfect. Now mergify will sit on it for 2 days waiting for further comments, if any.

@mergify mergify bot merged commit dd312ec into haskell:master Aug 9, 2022
@ulysses4ever
Copy link
Collaborator

Should this be backported?

@fgaz
Copy link
Member

fgaz commented Aug 9, 2022

It isn't a bugfix so there's no need to backport it

@ulysses4ever
Copy link
Collaborator

ulysses4ever commented Aug 9, 2022

Fair enough, thanks!

@kokobd
Copy link
Collaborator

kokobd commented Sep 14, 2022

@mergify backport 3.8

@mergify
Copy link
Contributor

mergify bot commented Sep 14, 2022

backport 3.8

✅ Backports have been created

@mergify mergify bot added the merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days label Sep 16, 2022
@ulysses4ever ulysses4ever mentioned this pull request May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days merge me Tell Mergify Bot to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cabal is a poet
6 participants