Skip to content
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

Various cabal-testsuite improvements #10225

Merged
merged 12 commits into from
Sep 2, 2024
Merged

Conversation

jasagredo
Copy link
Collaborator

@jasagredo jasagredo commented Jul 23, 2024

  • Make .bat scripts for CCompilerOverride test look into the shipped toolchain for gcc/clang.
  • The flaky combinator can be used to specify flaky tests with a ticket number. These will be reported as passing or failing but will not make the test-suite error.
  • Broken tests can be broken by accept-test, i.e. by the output not matching. Previously a test that failed this way had to be skipped because it didn't pass but the expectBroken logic would deem it not broken.
  • Also makes postCheckoutCommand not flaky on Windows.
  • It removes some outdated tests (old GHCs) and some tests that will never pass again.
  • Fixes some issues with output normalization in MacOS

Depends-On: #10282

@jasagredo jasagredo marked this pull request as draft July 23, 2024 23:55
cabal-testsuite/src/Test/Cabal/Monad.hs Outdated Show resolved Hide resolved
cabal-testsuite/src/Test/Cabal/TestCode.hs Outdated Show resolved Hide resolved
@jasagredo jasagredo changed the title Implement flaky combinator Implement flaky combinator Jul 24, 2024
@jasagredo jasagredo marked this pull request as ready for review July 24, 2024 15:31
@jasagredo
Copy link
Collaborator Author

Hm what a surprising failure on macOS! Will investigate

Comment on lines 952 to 1016
skipIfOSX :: String -> IO ()
skipIfOSX why = skipIfIO ("OSX " <> why) isOSX

skipIfCI :: Int -> IO ()
skipIfCI ticket = skipIfIO ("CI, see #" <> show ticket) =<< isCI

skipIfCIAndWindows :: Int -> IO ()
skipIfCIAndWindows ticket = skipIfIO ("Windows CI, see #" <> show ticket) . (isWindows &&) =<< isCI

skipIfCIAndOSX :: Int -> IO ()
skipIfCIAndOSX ticket = skipIfIO ("OSX CI, see #" <> show ticket) . (isOSX &&) =<< isCI

expectBrokenIfWindows :: Int -> TestM a -> TestM a
expectBrokenIfWindows ticket = expectBrokenIf isWindows ticket

expectBrokenIfWindowsCI :: Int -> TestM a -> TestM a
expectBrokenIfWindowsCI ticket m = do
ci <- liftIO isCI
expectBrokenIf (isWindows && ci) ticket m

expectBrokenIfWindowsCIAndGhc :: String -> Int -> TestM a -> TestM a
expectBrokenIfWindowsCIAndGhc range ticket m = do
ghcVer <- isGhcVersion range
ci <- liftIO isCI
expectBrokenIf (isWindows && ghcVer && ci) ticket m

expectBrokenIfWindowsAndGhc :: String -> Int -> TestM a -> TestM a
expectBrokenIfWindowsAndGhc range ticket m = do
ghcVer <- isGhcVersion range
expectBrokenIf (isWindows && ghcVer) ticket m

expectBrokenIfOSXAndGhc :: String -> Int -> TestM a -> TestM a
expectBrokenIfOSXAndGhc range ticket m = do
ghcVer <- isGhcVersion range
expectBrokenIf (isOSX && ghcVer) ticket m

expectBrokenIfGhc :: String -> Int -> TestM a -> TestM a
expectBrokenIfGhc range ticket m = do
ghcVer <- isGhcVersion range
expectBrokenIf ghcVer ticket m

flakyIfCI :: Int -> TestM a -> TestM a
flakyIfCI ticket m = do
ci <- liftIO isCI
flakyIf ci ticket m

flakyIfWindows :: Int -> TestM a -> TestM a
flakyIfWindows ticket m = flakyIf isWindows ticket m
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure I buy it as an improvement having separate functions for so many combinations. It'd be great to have a little DSL for expressing such things and this looks like a step away from that. But it is tempting to go this route because it does save on typing. Perhaps if Haskell had a built-in the monadic bang (in the sense of this plugin), the savings here wouldn't be as noticeable. So, overall, I don't feel strongly about it, just curious what others think.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, as I was writing them I was thinking the same. But overall I think it is useful to make the skip and broken messages as uniform as possible, to be able to grep the output.

Otherwise one might use "shared libs", another person uses "dynamic libs", another one makes a typo "shred libs", etc.

I will consider whether to add something like a DSL. But maybe this would be mergeable? At the very least I could put a comment in the code saying "TODO: this should be reworked into a DSL or some such".

Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't need to risk loss of uniformity. See for example https://hackage.haskell.org/package/xmonad-contrib-0.18.0/docs/XMonad-Util-WindowProperties.html.
In this case I'd have 4 parameters: expected state or action (skip, expect fail, expect pass, flaky…), predicate (cf. above WindowProperties, replacing your multiple conditionals), ticket, message. But this might indeed be future work.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah i didn't explain myself. I think a DSL would be uniform and the best solution. What is not uniform is

skipIf noShared "no shared libs"

And somewhere else

skipIf noShared "no dyn libs"

Which is what was there before I introduced these functions.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would make that aspect of the message come from the DSL, and the explanation should give details. (In which case perhaps it should be optional, or absorbed into the ticket.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok I managed to make the CI green. From my side there are no other blockers for merging this.

What is your opinion on the combinators then @ulysses4ever @geekosaur ? Could this be merged and the DSL be done in a later PR or do you think this should not be merged before the DSL is done?

Copy link
Collaborator

Choose a reason for hiding this comment

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

By no means I meant that the DSL should be a prerequisite.

I simply struggle to get to the bottom of the long line of commits. For me personally, it'd be much easier to approve commits in separate PRs one by one. But I understand how inconvenient that approach is for the author. So I'll try to get a review done.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Some points I wanted to note down:

  • It would have been perfectly ok if you said you wanted the DSL before approving, it is a perfectly valid opinion and I asked because I would have thought it was perfectly ok if you said "I will not give my approval until this PR has better ergonomics for the combinators like a DSL maybe"
  • I have tried to split the changes semantically, one on each commit, so that it would be easier to review. Some of them are interesting, some are boring 😄
  • (Btw, while reviewing you can choose to see only one commit at a time, that might make it easier)
  • I'm fine with splitting the work in multiple PRs if it is independent (kind of like in this case, it could have been 4-5 PRs) but I think it is more work to drag attention to 5 PRs for review than to one. There is usually not enough volunteer-time to review this so I prefer just making it in one go 🙂 (as long as the commits are related, like in this case they are all about CI and tests)
  • This being said, if you prefer I can split this PR in multiple PRs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I already suggested it should be future work? It wants some up-front design.

Copy link
Collaborator

Choose a reason for hiding this comment

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

For splitting: I think you should do it the way you prefer. For me personally reviewing and approving 5 small PRs can take much less time than reviewing 5 commits and approving one PR with those. That's simply because it's not possible to "save state" (meaning my mental state) in between the commits while there's a way to do that for multiple PRs (by approving them one by one). Unless I'm missing something in GitHub UI. I know that you can review commits separately (that's what I've been doing with this PR), but that's not the same as reviewing/approving/and forgetting about individual PRs (which works better for me). Again, you should do it the way you find it more convenient, I think.

For the DSL, I share Brandon's opinion (see the comment just above) entirely.

@jasagredo
Copy link
Collaborator Author

I think I fixed the MacOS issue with 4285454. Let's see what CI says, then I will address the review comments.

For the DSL, I tried doing something last night but things started looking very bad as there were just too many edge cases and conditions applied in different places. I will give it some more thought.

@jasagredo jasagredo changed the title Implement flaky combinator Various cabal-testsuite improvements Jul 25, 2024
@jasagredo
Copy link
Collaborator Author

The RejectFutureIndexStates test is timing-out on Windows on CI. This doesn't happen on my local machine, which is kind of weird.

I will probably have to mark it as Skip on Windows+CI 🙄 or investigate with the tmate action.

@jasagredo
Copy link
Collaborator Author

I deferred the investigation of those two tests to #10230. Before this PR they were skipped anyway on all OSes.

@jasagredo jasagredo force-pushed the js/flaky-tests branch 2 times, most recently from 54f1d18 to b25a3ca Compare July 26, 2024 15:40
@jasagredo
Copy link
Collaborator Author

May I ask for an approval if there are no further comments @ulysses4ever ? (Just pinging you because you had reviewed the pr already, I can ask in matrix if you can't review it)

@ulysses4ever
Copy link
Collaborator

@jasagredo it's on my radar, yes. In the meantime, applying the needs-review label (just did it) and asking on Matrix may speed it up. I can't guarantee that I get to it today but I'll try my best.

@ulysses4ever
Copy link
Collaborator

@mpickering I think you were one of the last people to do a meaningful update to the Cabal testsuite. Could you, perhaps, take a look at this PR?

Comment on lines +248 to +255
(e, out, err) <- readProcessWithExitCode real_path real_args ""
putStrLn "# STDOUT:"
putStrLn out
putStrLn "# STDERR:"
putStrLn err
if "TestCodeFlaky" `isInfixOf` err
then pure ()
else throwIO e
Copy link
Collaborator

@ulysses4ever ulysses4ever Jul 30, 2024

Choose a reason for hiding this comment

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

This grepping through stderr feels a little crude although I don't know a better way. Also, usually, when you switch from showing direct output to showing captured one, there are some side effects. E.g. colored output would be unavailable, etc. Of course, Cabal testsuite doesn't have colored output in particular but there may be spooky actions at the distance...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought maybe there was some other way to pipe this output of the process but I didn't seem to find one.

In any case this is only for when you invoke the tests with one test. I don't know how much that is used, I personally run the validate script always

Copy link
Collaborator

Choose a reason for hiding this comment

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

this is only for when you invoke the tests with one test

Oh, that's much less of a concern then. Thank you!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's leave it as unresolved for now maybe to see if anyone has other thoughts...

@jasagredo jasagredo added the squash+merge me Tell Mergify Bot to squash-merge label Aug 26, 2024
@mergify mergify bot added the ready and waiting Mergify is waiting out the cooldown period label Aug 28, 2024
@jasagredo jasagredo removed squash+merge me Tell Mergify Bot to squash-merge ready and waiting Mergify is waiting out the cooldown period labels Aug 28, 2024
@jasagredo
Copy link
Collaborator Author

Let's wait until the Windows CI is reenabled before merging this

@geekosaur geekosaur added the squash+merge me Tell Mergify Bot to squash-merge label Aug 28, 2024
@mergify mergify bot added the ready and waiting Mergify is waiting out the cooldown period label Aug 28, 2024
@geekosaur
Copy link
Collaborator

I set a dependency so Mergify should merge it automatically when #10282 goes in.

@mergify mergify bot added the merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days label Aug 30, 2024
@mergify mergify bot merged commit 39b6924 into haskell:master Sep 2, 2024
42 checks passed
9999years added a commit to 9999years/cabal that referenced this pull request Sep 25, 2024
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 ready and waiting Mergify is waiting out the cooldown period squash+merge me Tell Mergify Bot to squash-merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants