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

Conversation

@patrickt
Copy link
Contributor

@patrickt patrickt commented Jun 12, 2019

This patch:

  • divests from our fork of hspec-expectations-pretty-diff, which partially unblocks Publish to Hackage/Stackage. #16.
  • pulls in https://github.com/feuerbach/tasty as a test harness/runner
  • pulls in https://github.com/feuerbach/tasty-golden to provide golden tests
  • pulls in https://github.com/mitchellwrosen/tasty-hspec for backcompat with our hspec suite (after an abortive attempt to convert the hspec suite, which produced a diff of truly depressing size)
  • uses unsafePerformIO in places where it is somewhat unavoidable (I defend unsafePerformIO’s use in tests)
  • gets good diff output because tasty-golden lets us provide our own diff command, and attempts to use jd for JSON comparisons.
  • makes all the other unit tests use normal hspec-expectations
  • adds some missing version bounds
  • removes a ton of unused imports in the specs

Fixes #120.


source-repository-package
type: git
location: https://github.com/rewinfrey/hspec-expectations-pretty-diff
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Down to only two vendored packages left (the hard ones, unfortunately).

testsForLanguage language = do
let dir = "test/fixtures" </> language </> "corpus"
let items = unsafePerformIO (examples dir)
localOption (mkTimeout 3000000) $ testGroup language $ fmap testForExample items
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These tests sometimes get held up; I’m not sure why (I think it’s a race condition w/r/t file I/O), but this timeout remedies it so the builders won’t get stuck for 10 minutes before it happens. (Worth filing a bug about, I think.)

-- tests and find this output hard to read, install the `jd` CLI tool
-- (https://github.com/josephburnett/jd), which will print a detailed
-- summary of the differences between these JSON files.
renderDiff :: String -> String -> [String]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The major compromise associated with giving up hspec-expectations-pretty-diff is that the quality of the diffs went down. However, tasty-golden lets us provide our own diffing invocation, which means we can retain the excellent output.

let nativeSpecs = tests session
asTastySpecs <- Tasty.testSpecs $ legacySpecs session
let allSpecs = nativeSpecs <> asTastySpecs
pure . Tasty.localOption Tasty.Success $ testGroup "semantic" allSpecs
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tasty has no concept of pending tests, so we mark our pending tests as successes.

{-(KeyValue
{-(TextElement)-}
{-(Float)-})-}
{-(KeyValue
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that we don’t use verbatim, we care about whitespace here.

Copy link
Contributor

Choose a reason for hiding this comment

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

A feature, IMO.

@@ -1,36 +1,53 @@
{-# LANGUAGE ImplicitParams, LambdaCase, NamedFieldPuns #-}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Countdown to Rob requesting NoImplicitParams in 3… 2… 1… 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(I do think implicit params are a better solution than plumbing parameters everywhere or Reader + umpteen calls to pure. But we should arguably do the let ?session in the top-level Spec.hs file.)

Copy link
Contributor

Choose a reason for hiding this comment

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

u wot m8

The purist in me would prefer a Reader effect, but I see the appeal. Tell you what: you maintain it and we’re good 😉

Copy link
Contributor

Choose a reason for hiding this comment

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

(I kid, I kid. I’m cool with this 👍)

@patrickt patrickt requested review from a team, rewinfrey and robrix and removed request for rewinfrey and robrix June 12, 2019 17:04
Copy link
Contributor

@robrix robrix left a comment

Choose a reason for hiding this comment

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

Nice one @patrickt ❤️

other-modules: Paths_semantic
build-depends: base >= 4.12 && < 5
, ansi-terminal ^>= 0.8.2
, ansi-terminal >= 0.8.2 && <1
Copy link
Contributor

Choose a reason for hiding this comment

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

Pourquoi?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not technically needed, but ansi-terminal just hit 0.9.0, and the old hspec-expectations-pretty-diff was complaining about it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha.

import: haskell, dependencies, executable-flags
type: exitcode-stdio-1.0
hs-source-dirs: test
ghc-options: -Wunused-imports
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we apply this in a common stanza?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup. We should really just turn on -Wall everywhere, but I’ll file a separate issue about that.

Copy link
Contributor

Choose a reason for hiding this comment

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

I dig it; the thing fused-effects does is working pretty nicely.

@@ -1,36 +1,53 @@
{-# LANGUAGE ImplicitParams, LambdaCase, NamedFieldPuns #-}
Copy link
Contributor

Choose a reason for hiding this comment

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

u wot m8

The purist in me would prefer a Reader effect, but I see the appeal. Tell you what: you maintain it and we’re good 😉

{-(KeyValue
{-(TextElement)-}
{-(Float)-})-}
{-(KeyValue
Copy link
Contributor

Choose a reason for hiding this comment

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

A feature, IMO.

@patrickt patrickt merged commit c6607e4 into master Jun 12, 2019
@robrix robrix deleted the tasty-golden-scrumptious-tests branch June 12, 2019 21:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use tasty + tasty-golden for parse-examples tests.

3 participants