From c0dac2e61c131a8c489c5cf5ee73846ea4658531 Mon Sep 17 00:00:00 2001 From: ktf Date: Tue, 30 Jan 2024 16:27:06 -0800 Subject: [PATCH] Tighten up Stan plugin language extension test cases These changes ensure that the tests will fail given bad mappings in either the `cabalExtensionsMap` OR the `checksMap`. Either of these could cause bad behavior as seen in issue #3174. --- plugins/hls-stan-plugin/test/Main.hs | 8 ++++++-- .../testdata/extension-tests/cabal-file/CabalFileTest.hs | 3 +++ .../extension-tests/language-pragma/LanguagePragmaTest.hs | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/hls-stan-plugin/test/Main.hs b/plugins/hls-stan-plugin/test/Main.hs index 6f0a41ca9b..32cdd7c41e 100644 --- a/plugins/hls-stan-plugin/test/Main.hs +++ b/plugins/hls-stan-plugin/test/Main.hs @@ -44,13 +44,17 @@ tests = runStanSession "" $ do doc <- openDoc "extension-tests/language-pragma/LanguagePragmaTest.hs" "haskell" diags <- waitForDiagnosticsFromSource doc "stan" - liftIO $ length diags @?= 0 + -- We must include at least one valid diagnostic in our test file to avoid + -- the false-positive case where Stan finds no analyses to perform due to a + -- bad mapping, which would also lead to zero diagnostics being returned. + liftIO $ length diags @?= 1 return () , testCase "respects language extensions defined in the .cabal file" $ runStanSession "" $ do doc <- openDoc "extension-tests/cabal-file/CabalFileTest.hs" "haskell" diags <- waitForDiagnosticsFromSource doc "stan" - liftIO $ length diags @?= 0 + -- We need at least one valid diagnostic here too, for the same reason as above. + liftIO $ length diags @?= 1 return () ] diff --git a/plugins/hls-stan-plugin/test/testdata/extension-tests/cabal-file/CabalFileTest.hs b/plugins/hls-stan-plugin/test/testdata/extension-tests/cabal-file/CabalFileTest.hs index 71b4380104..77b6dc3845 100644 --- a/plugins/hls-stan-plugin/test/testdata/extension-tests/cabal-file/CabalFileTest.hs +++ b/plugins/hls-stan-plugin/test/testdata/extension-tests/cabal-file/CabalFileTest.hs @@ -2,3 +2,6 @@ module CabalFileTest () where -- With `StrictData` enabled in the `.cabal` file, Stan shouldn't complain here: data A = A Int Int + +-- ...but it should still complain here! +kewlFunc = undefined diff --git a/plugins/hls-stan-plugin/test/testdata/extension-tests/language-pragma/LanguagePragmaTest.hs b/plugins/hls-stan-plugin/test/testdata/extension-tests/language-pragma/LanguagePragmaTest.hs index 3da9a28254..6f5631ac8c 100644 --- a/plugins/hls-stan-plugin/test/testdata/extension-tests/language-pragma/LanguagePragmaTest.hs +++ b/plugins/hls-stan-plugin/test/testdata/extension-tests/language-pragma/LanguagePragmaTest.hs @@ -4,3 +4,6 @@ module LanguagePragmaTest () where -- With the above `StrictData` language pragma, Stan shouldn't complain here: data A = A Int Int + +-- ...but it should still complain here! +kewlFunc = undefined