@@ -3,11 +3,15 @@ import Control.Monad (unless)
33import Data.Algorithm.Diff (getGroupedDiff )
44import Data.Algorithm.DiffOutput (ppDiff )
55import Data.List (sort , isInfixOf )
6+ import qualified Data.Map as M
7+ import Data.Maybe (mapMaybe )
68import Data.Functor ((<&>) )
79import Test.Tasty (defaultMain , TestTree , testGroup )
10+ import Test.Tasty.ExpectedFailure (expectFailBecause )
811import Test.Tasty.Golden (goldenVsFile )
912import qualified Test.Tasty.Golden as G
1013import Test.Tasty.Golden.Advanced (goldenTest )
14+ import Test.Tasty.Runners (TestTree (.. ))
1115import System.Directory (renameFile , doesFileExist )
1216import System.Exit (ExitCode )
1317import System.FilePath (dropExtension , pathSeparator )
@@ -33,6 +37,15 @@ main = do
3337 putStrLn $ " \n Excluding directories: " ++ show (lines excludesData) ++ " \n "
3438 return $ Right $ IncludeAll (foldr Exclude Nil (lines excludesData))
3539 else return $ Right (IncludeAll Nil )
40+
41+ knownIssuesQuery <- doesFileExist " .known-issues"
42+ knownIssues <-
43+ if knownIssuesQuery
44+ then do
45+ issuesData <- readFile " .known-issues"
46+ return $ parseKnownIssues issuesData
47+ else return M. empty
48+
3649 case configE of
3750 Left error -> do
3851 putStrLn $ " Error in test arguments: " <> error
@@ -42,8 +55,9 @@ main = do
4255 rewrite <- goldenTestsRewrite config
4356 synthesis <- goldenTestsSynthesis config
4457
58+ let tests = testGroup " Golden tests" [negative, positive, rewrite, synthesis]
4559 catch
46- (defaultMain $ testGroup " Golden tests" [negative, positive, rewrite, synthesis] )
60+ (defaultMain $ wrapKnownIssues knownIssues tests)
4761 (\ (e :: ExitCode ) -> do
4862 -- Move all of the backup files back to their original place.
4963 backupFiles <- findByExtension config [" .bak" ] " frontend/tests/cases/rewrite"
@@ -53,6 +67,24 @@ main = do
5367 mapM_ (\ backup -> renameFile backup (dropExtension backup)) backupFiles
5468 throwIO e
5569 )
70+ where
71+ parseKnownIssues :: String -> M. Map FilePath String
72+ parseKnownIssues content =
73+ M. fromList (mapMaybe parseLine (lines content))
74+ where
75+ parseLine line = case words line of
76+ [path, issue] -> Just (path, issue)
77+ _ -> Nothing
78+
79+ wrapKnownIssues :: M. Map FilePath String -> TestTree -> TestTree
80+ wrapKnownIssues issues tree = case tree of
81+ SingleTest name test ->
82+ case M. lookup name issues of
83+ Just issue -> expectFailBecause issue tree
84+ Nothing -> tree
85+ TestGroup name trees ->
86+ TestGroup name (map (wrapKnownIssues issues) trees)
87+ _ -> tree -- we don't use the other constructors
5688
5789-- Applies a configuration to list of filepaths
5890applyConfig :: Config -> [FilePath ] -> [FilePath ]
@@ -259,4 +291,4 @@ runTestsAndCleanUp tests = do
259291 when (null contents) (removeFile outfile)
260292 throwIO e)
261293
262- -}
294+ -}
0 commit comments