Skip to content
This repository was archived by the owner on Apr 20, 2026. It is now read-only.
This repository was archived by the owner on Apr 20, 2026. It is now read-only.

use hspec Env in naming files #64

@aavogt

Description

@aavogt

Hi, I was surprised that s in defaultGolden s is the actual filename. I expected it to add hspec's Env. Here is the motivating example and hacky workaround:

-- hspec-core definitions:
-- newtype SpecM a r = SpecM { unSpecM :: WriterT (Endo Config, [SpecTree a]) (ReaderT Env IO) r }
-- newtype Env = Env {
-- -- | The path of _parent_ `Hspec.Core.Spec.describe` labels from innermost to
-- -- outermost.
-- envSpecDescriptionPath :: [String]
-- }
gold s v = do
  env <- SpecM (lift ask)
  it s $ defaultGolden (intercalate "." (unsafeCoerce env) ++ "." ++ s) (pretty 1000 $ ppr v)
gold s v = it s $ defaultGolden s (pretty 1000 (ppr v)) -- this version leads to the second set of tests failing on the first run
spec :: Spec
spec = do
  describe "array[10]" do
    let fn = [cunit| void f() { while (true) { static int array[10]; } } |]
        spec = buildStateSpec fn
    gold "language-c-quote AST" fn
    gold "structdef" $ buildStateMembers (fields spec)

  describe "array[10][7]" do
    let fn = [cunit| void f() { while (true) { static int array[10][7]; } } |]
        spec = buildStateSpec fn
    gold "language-c-quote AST" fn
    gold "structdef" $ buildStateMembers (fields spec)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions