Skip to content

Add testing support on ghc >= 9.4 #21

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 10 commits into from
Jan 3, 2025
Merged

Add testing support on ghc >= 9.4 #21

merged 10 commits into from
Jan 3, 2025

Conversation

jimbob88
Copy link
Collaborator

@jimbob88 jimbob88 commented Jan 2, 2025

Then, shall we drop support for 9.0 and 9.2 and proceed with 9.4 if the cost of support is low? I’m also thinking of adding CI settings for 9.6 and later.

This pull request adds testing on 9.6, 9.8, 9.12 and drops support for testing on 9.2 and 9.0. I also removed 9.0 and 9.2 from the supported versions in the cabal package.

(If the output changes in 9.12, it seems like preparing a new ghc.output specifically for 9.12 would be a good approach.)
I was incorrect with my original assessment. It changes for all of ghc 9 it seems. I have updated the test to work in a different way. The new output for ghc >= 9 looks as follows:

example: Uncaught exception ghc-internal:GHC.Internal.Exception.ErrorCall:

fError

HasCallStack backtrace:
  error, called at example/Main.hs:47:10 in haskell-stack-trace-plugin-0.1.3.0-inplace-example:Main
  fError, called at example/Main.hs:43:11 in haskell-stack-trace-plugin-0.1.3.0-inplace-example:Main
  f10, called at example/Main.hs:40:6 in haskell-stack-trace-plugin-0.1.3.0-inplace-example:Main
  f9, called at example/Main.hs:37:11 in haskell-stack-trace-plugin-0.1.3.0-inplace-example:Main
  f8, called at example/Main.hs:33:16 in haskell-stack-trace-plugin-0.1.3.0-inplace-example:Main
  f7, called at example/Main.hs:29:11 in haskell-stack-trace-plugin-0.1.3.0-inplace-example:Main
  f6, called at example/Main.hs:25:15 in haskell-stack-trace-plugin-0.1.3.0-inplace-example:Main
  f5, called at example/Main.hs:21:8 in haskell-stack-trace-plugin-0.1.3.0-inplace-example:Main
  f4, called at example/Main.hs:17:6 in haskell-stack-trace-plugin-0.1.3.0-inplace-example:Main
  f3, called at example/Main.hs:13:6 in haskell-stack-trace-plugin-0.1.3.0-inplace-example:Main
  f2, called at example/Main.hs:10:6 in haskell-stack-trace-plugin-0.1.3.0-inplace-example:Main
  f1, called at example/Main.hs:7:14 in haskell-stack-trace-plugin-0.1.3.0-inplace-example:Main
  main, called at example/Main.hs:7:1 in haskell-stack-trace-plugin-0.1.3.0-inplace-example:Main

However, when being run in the tests, it also adds the current commit hash as follows (see here):

example: Uncaught exception ghc-internal:GHC.Internal.Exception.ErrorCall:
                 
                 fError
                 
                 HasCallStack backtrace:
                   error, called at example/Main.hs:47:10 in haskell-stack-trace-plugin-0.1.3.0-e-example-2c146cc2a526fda8afc7cbecc1799d00a2e300df7bab1279aacb0d6bf26e10db:Main
                   fError, called at example/Main.hs:43:11 in haskell-stack-trace-plugin-0.1.3.0-e-example-2c146cc2a526fda8afc7cbecc1799d00a2e300df7bab1279aacb0d6bf26e10db:Main
                   f10, called at example/Main.hs:40:6 in haskell-stack-trace-plugin-0.1.3.0-e-example-2c146cc2a526fda8afc7cbecc1799d00a2e300df7bab1279aacb0d6bf26e10db:Main
                   f9, called at example/Main.hs:37:11 in haskell-stack-trace-plugin-0.1.3.0-e-example-2c146cc2a526fda8afc7cbecc1799d00a2e300df7bab1279aacb0d6bf26e10db:Main
                   f8, called at example/Main.hs:33:16 in haskell-stack-trace-plugin-0.1.3.0-e-example-2c146cc2a526fda8afc7cbecc1799d00a2e300df7bab1279aacb0d6bf26e10db:Main
                   f7, called at example/Main.hs:29:11 in haskell-stack-trace-plugin-0.1.3.0-e-example-2c146cc2a526fda8afc7cbecc1799d00a2e300df7bab1279aacb0d6bf26e10db:Main
                   f6, called at example/Main.hs:25:15 in haskell-stack-trace-plugin-0.1.3.0-e-example-2c146cc2a526fda8afc7cbecc1799d00a2e300df7bab1279aacb0d6bf26e10db:Main
                   f5, called at example/Main.hs:21:8 in haskell-stack-trace-plugin-0.1.3.0-e-example-2c146cc2a526fda8afc7cbecc1799d00a2e300df7bab1279aacb0d6bf26e10db:Main
                   f4, called at example/Main.hs:17:6 in haskell-stack-trace-plugin-0.1.3.0-e-example-2c146cc2a526fda8afc7cbecc1799d00a2e300df7bab1279aacb0d6bf26e10db:Main
                   f3, called at example/Main.hs:13:6 in haskell-stack-trace-plugin-0.1.3.0-e-example-2c146cc2a526fda8afc7cbecc1799d00a2e300df7bab1279aacb0d6bf26e10db:Main
                   f2, called at example/Main.hs:10:6 in haskell-stack-trace-plugin-0.1.3.0-e-example-2c146cc2a526fda8afc7cbecc1799d00a2e300df7bab1279aacb0d6bf26e10db:Main
                   f1, called at example/Main.hs:7:14 in haskell-stack-trace-plugin-0.1.3.0-e-example-2c146cc2a526fda8afc7cbecc1799d00a2e300df7bab1279aacb0d6bf26e10db:Main
                   main, called at example/Main.hs:7:1 in haskell-stack-trace-plugin-0.1.3.0-e-example-2c146cc2a526fda8afc7cbecc1799d00a2e300df7bab1279aacb0d6bf26e10db:Main

Due to this change, I updated the tests to use a regex and extract each function that appears in the call stack. It then checks that every function that should appear in the stack trace, appears in that order.

-- | Extracts the function names of all functions that appear in a stack trace
extractStackTraceFunctions :: String -> [String]
extractStackTraceFunctions input = map extractFunctionName matches
 where
  regex = [r|[ ]*([A-Za-z0-9]+), called at example/Main.hs:[0-9]+:[0-9]+ in [^:]+:Main|] :: String
  matches = (input =~ regex) :: [[String]]
  extractFunctionName :: [String] -> String
  extractFunctionName (_ : name : _) = name
  extractFunctionName _ = error "Regex match failed"

spec :: Spec
spec = do
  output <- runIO exe
  let outputStr = BS.unpack output
  let extractedFunctions = extractStackTraceFunctions outputStr

  -- each of these exceptions should appear in the stack trace
  let expectedFunctions = ["error", "fError", "f10", "f9", "f8", "f7", "f6", "f5", "f4", "f3", "f2", "f1", "main"] :: [String]

  it "integration test" $ extractedFunctions `shouldBe` expectedFunctions

Thank you. Are you currently working on the support for ghc-9.4?

This pull request fixes the tests on 9.4 (the code worked but the tests couldn't run due to a version constraint).

@jimbob88 jimbob88 changed the title build: move from deprecated gh action, invalidate cache Add testing support on ghc >= 9.4 Jan 2, 2025
@jimbob88 jimbob88 requested a review from waddlaw January 2, 2025 09:45
Copy link
Owner

@waddlaw waddlaw left a comment

Choose a reason for hiding this comment

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

LGTM

cabal: ["3.6"]
cache-version: ["2022-10-25"]

ghc-version: ["8.6", "8.8", "8.10", "9.4", "9.6", "9.8", "9.12"]
Copy link
Owner

Choose a reason for hiding this comment

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

I'd like to add support for 9.10 as well, but I think it would be better to handle it in a separate PR.

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 have tested locally and 9.10.1 works on my computer. Haven't tried running the tests in CI or locally though.

@waddlaw waddlaw merged commit 7a8a9ed into waddlaw:main Jan 3, 2025
7 checks passed
@waddlaw
Copy link
Owner

waddlaw commented Jan 3, 2025

@jimbob88 Thank you for your contribution! 👍

@waddlaw waddlaw mentioned this pull request Jan 3, 2025
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.

2 participants