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

Add haddock --keep-temp-files test #10392

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

9999years
Copy link
Collaborator

@9999years 9999years commented Sep 27, 2024

Split off of #10292

Thanks to @mpickering for helping with this test case.

  • Patches conform to the coding conventions.
  • Is this a PR that fixes CI? If so, it will need to be backported to older cabal release branches (ask maintainers for directions).

Depends-on: #10388

@mpickering
Copy link
Collaborator

This seems to depend on #10388

@geekosaur
Copy link
Collaborator

Yes, that's why there's a Depends-on: in the header.

@9999years 9999years force-pushed the wiggles/add-haddock-keep-temp-files-test branch 2 times, most recently from 833cc2c to 3001d28 Compare September 30, 2024 21:38
@9999years 9999years force-pushed the wiggles/add-haddock-keep-temp-files-test branch from 3001d28 to 7a181f1 Compare September 30, 2024 21:41
@9999years
Copy link
Collaborator Author

@mpickering This seems to be failing on Windows, would you mind taking a look at it?

@mpickering
Copy link
Collaborator

mpickering commented Oct 1, 2024

It appears on windows the response file is called had5244.txt rather than haddock-response.txt, I will look into modifying the test.

@mpickering
Copy link
Collaborator

@9999years It seems that in the original patch I provided it worked on windows. Could you restore that approach to the test? I

+{-# LANGUAGE LambdaCase #-}
+import Test.Cabal.Prelude
+import Data.List (sort)
+import Distribution.Verbosity
+import Distribution.Simple.Glob
+import Distribution.Simple.Glob.Internal
+import Distribution.Simple.Utils
+
+-- Test that "cabal haddock" preserves temporary files
+-- We use haddock-keep-temp-file: True in the cabal.project.
+main = cabalTest $ recordMode DoNotRecord $ withProjectFile "cabal.project" $ do
+    cabal "haddock" []
+
+    cwd <- fmap testCurrentDir getTestEnv
+
+    -- Windows has multiple response files, and only the last one (alphabetically) is the important one.
+    (safeLast . sort . globMatches <$> liftIO (runDirFileGlob silent Nothing cwd (GlobDirRecursive [WildCard, Literal "txt"]))) >>= \case
+      Nothing -> error "Expecting a response file to exist"
+      Just m -> do
+        -- Assert the matched response file is not empty, and indeed a haddock rsp
+        assertFileDoesContain (cwd </> m) "--package-name"

I tried to push a commit which restored the test to this form but I don't have permission to push to your branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants