@@ -19,7 +19,6 @@ module Test.Hls.Util
1919 , fromAction
2020 , fromCommand
2121 , getCompletionByLabel
22- , getHspecFormattedConfig
2322 , ghcVersion , GhcVersion (.. )
2423 , hostOS , OS (.. )
2524 , matchesCurrentEnv , EnvSpec (.. )
@@ -50,9 +49,7 @@ import Control.Monad.IO.Class
5049import qualified Data.Aeson as A
5150import Data.Bool (bool )
5251import Data.Default
53- import Data.List (intercalate )
5452import Data.List.Extra (find )
55- import Data.Maybe
5653import qualified Data.Set as Set
5754import qualified Data.Text as T
5855import Development.IDE (GhcVersion (.. ), ghcVersion )
@@ -66,15 +63,11 @@ import System.FilePath
6663import System.IO.Temp
6764import System.Info.Extra (isMac , isWindows )
6865import System.Time.Extra (Seconds , sleep )
69- import Test.Hspec.Core.Formatters hiding (Seconds )
70- import Test.Hspec.Runner
7166import Test.Tasty (TestTree )
7267import Test.Tasty.ExpectedFailure (expectFailBecause ,
7368 ignoreTestBecause )
7469import Test.Tasty.HUnit (Assertion , assertFailure ,
7570 (@?=) )
76- import Text.Blaze.Internal hiding (null )
77- import Text.Blaze.Renderer.String (renderMarkup )
7871
7972noLiteralCaps :: C. ClientCapabilities
8073noLiteralCaps = def { C. _textDocument = Just textDocumentCaps }
@@ -167,88 +160,6 @@ hieYamlCradleDirectContents = unlines
167160 ]
168161
169162
170- -- ---------------------------------------------------------------------
171-
172- getHspecFormattedConfig :: String -> IO Config
173- getHspecFormattedConfig name = do
174- -- https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables
175- isCI <- isJust <$> lookupEnv " CI"
176-
177- -- Only use the xml formatter on CI since it hides console output
178- if isCI
179- then do
180- let subdir = " test-results" </> name
181- createDirectoryIfMissing True subdir
182-
183- return $ defaultConfig { configFormatter = Just xmlFormatter
184- , configOutputFile = Right $ subdir </> " results.xml"
185- }
186- else return defaultConfig
187-
188- -- | A Hspec formatter for CircleCI.
189- -- Originally from https://github.com/LeastAuthority/hspec-jenkins
190- xmlFormatter :: Formatter
191- xmlFormatter = silent {
192- headerFormatter = do
193- writeLine " <?xml version='1.0' encoding='UTF-8'?>"
194- writeLine " <testsuite>"
195- , exampleSucceeded
196- , exampleFailed
197- , examplePending
198- , footerFormatter = writeLine " </testsuite>"
199- }
200- where
201-
202- #if MIN_VERSION_hspec(2,5,0)
203- exampleSucceeded path _ =
204- #else
205- exampleSucceeded path =
206- #endif
207- writeLine $ renderMarkup $ testcase path " "
208-
209- #if MIN_VERSION_hspec(2,5,0)
210- exampleFailed path _ err =
211- #else
212- exampleFailed path (Left err) =
213- writeLine $ renderMarkup $ testcase path $
214- failure ! message (show err) $ " "
215- exampleFailed path (Right err) =
216- #endif
217- writeLine $ renderMarkup $ testcase path $
218- failure ! message (reasonAsString err) $ " "
219-
220- #if MIN_VERSION_hspec(2,5,0)
221- examplePending path _ reason =
222- #else
223- examplePending path reason =
224- #endif
225- writeLine $ renderMarkup $ testcase path $
226- case reason of
227- Just desc -> skipped ! message desc $ " "
228- Nothing -> skipped " "
229-
230- failure , skipped :: Markup -> Markup
231- failure = customParent " failure"
232- skipped = customParent " skipped"
233-
234- name , className , message :: String -> Attribute
235- name = customAttribute " name" . stringValue
236- className = customAttribute " classname" . stringValue
237- message = customAttribute " message" . stringValue
238-
239- testcase :: Path -> Markup -> Markup
240- testcase (xs,x) = customParent " testcase" ! name x ! className (intercalate " ." xs)
241-
242- reasonAsString :: FailureReason -> String
243- reasonAsString NoReason = " no reason given"
244- reasonAsString (Reason x) = x
245- reasonAsString (ExpectedButGot Nothing expected got) = " Expected " ++ expected ++ " but got " ++ got
246- reasonAsString (ExpectedButGot (Just src) expected got) = src ++ " expected " ++ expected ++ " but got " ++ got
247- #if MIN_VERSION_hspec(2,5,0)
248- reasonAsString (Error Nothing err ) = show err
249- reasonAsString (Error (Just s) err) = s ++ show err
250- #endif
251-
252163-- ---------------------------------------------------------------------
253164
254165flushStackEnvironment :: IO ()
0 commit comments