From 8e76a26c226b979fb47c98104f8bc67c2fb16bb5 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Mon, 12 Jun 2023 22:51:39 +0200 Subject: [PATCH] fix(tasty-golden): add missing query for goldenVsString (#97) --- CHANGELOG.md | 4 ++++ queries/haskell/tasty-positions.scm | 8 ++++++++ .../cabal/multi-package/tasty-pkg/test/Spec.hs | 18 ++++++++++++++++++ tests/tasty_spec.lua | 6 ++++++ 4 files changed, 36 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 070bbf0..4ae7f3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/queries/haskell/tasty-positions.scm b/queries/haskell/tasty-positions.scm index bc3d38a..4e2b826 100644 --- a/queries/haskell/tasty-positions.scm +++ b/queries/haskell/tasty-positions.scm @@ -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 diff --git a/tests/fixtures/tasty/cabal/multi-package/tasty-pkg/test/Spec.hs b/tests/fixtures/tasty/cabal/multi-package/tasty-pkg/test/Spec.hs index 0a1bada..3054c56 100644 --- a/tests/fixtures/tasty/cabal/multi-package/tasty-pkg/test/Spec.hs +++ b/tests/fixtures/tasty/cabal/multi-package/tasty-pkg/test/Spec.hs @@ -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 @@ -32,6 +33,7 @@ main = do , hspecTests , programTests , waiTests + , goldenTests ] properties :: TestTree @@ -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 diff --git a/tests/tasty_spec.lua b/tests/tasty_spec.lua index b796807..9358496 100644 --- a/tests/tasty_spec.lua +++ b/tests/tasty_spec.lua @@ -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()