Skip to content

Commit

Permalink
fix(tasty-golden): add missing query for goldenVsString (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb authored Jun 12, 2023
1 parent 12cbd97 commit 8e76a26
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.8.3] - 2023-06-12
### Fixed
- Add missing `tasty-golden` `goldenVsString` query.

## [0.8.2] - 2023-05-22
### Fixed
- Do not use deprecated health check API in neovim > 0.9.
Expand Down
8 changes: 8 additions & 0 deletions queries/haskell/tasty-positions.scm
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@
(exp_literal) @test.name
) @test.definition
)
;; tasty-golden goldenVsString (qualified or unqualified)
(_
(exp_apply
(exp_name) @func_name
(#lua-match? @func_name "^.*goldenVsString")
(exp_literal) @test.name
) @test.definition
)
;; tasty-golden goldenVsStringDiff (qualified or unqualified)
(_
(exp_apply
Expand Down
18 changes: 18 additions & 0 deletions tests/fixtures/tasty/cabal/multi-package/tasty-pkg/test/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Test.Tasty.Program
import Test.Tasty.HUnit
import Test.Tasty.Hspec
import Test.Tasty.Wai hiding (head)
import Test.Tasty.Golden as TG
import Test.Hspec
import Test.Tasty.ExpectedFailure
import Test.Hspec.QuickCheck
Expand All @@ -32,6 +33,7 @@ main = do
, hspecTests
, programTests
, waiTests
, goldenTests
]

properties :: TestTree
Expand Down Expand Up @@ -133,6 +135,22 @@ waiTests = testGroup "Tasty-Wai Tests"
assertBody "no route" res
]

goldenTests = testGroup "Golden tests"
[ goldenVsFile "goldenVsFile" "/some/golden/file.txt" "/some/output/file.txt" (pure ())
, goldenVsString "goldenVsString" "/some/golden/file.txt" (pure "")
, goldenVsFileDiff
"goldenVsFileDiff"
(\ref new -> ["diff", "-u", ref, new])
"/some/golden/file.txt"
"/some/output/file.txt"
(pure ())
, goldenVsStringDiff
"goldenVsStringDiff"
(\ref new -> ["diff", "-u", ref, new])
"/some/golden/file.txt"
(pure "")
]

genAlphaList :: H.Gen String
genAlphaList =
Gen.list (Range.linear 0 100) Gen.alpha
Expand Down
6 changes: 6 additions & 0 deletions tests/tasty_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ describe('tasty', function()
assert_has_position(result, wai_ns .. '::"Echo to thee"')
assert_has_position(result, wai_ns .. '::"Echo to thee (json)"')
assert_has_position(result, wai_ns .. '::"Will die!"')
local golden_ns = test_filename .. '::"Golden tests"'
assert_has_position(result, golden_ns)
assert_has_position(result, golden_ns .. '::"goldenVsFile"')
assert_has_position(result, golden_ns .. '::"goldenVsString"')
assert_has_position(result, golden_ns .. '::"goldenVsFileDiff"')
assert_has_position(result, golden_ns .. '::"goldenVsStringDiff"')
end)

describe('parse results', function()
Expand Down

0 comments on commit 8e76a26

Please sign in to comment.