Skip to content

Commit 130893e

Browse files
authored
ci/tests: handle known issues as expected failures (#325)
* ci/tests: handle known issues as expected failures * conventional import naming
1 parent 43b0c67 commit 130893e

3 files changed

Lines changed: 43 additions & 2 deletions

File tree

.known-issues

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
frontend/tests/cases/positive/indexed/infer-kinds.gr #299
2+
frontend/tests/cases/positive/security/level_pos3.gr #314
3+
frontend/tests/cases/rewrite/split-in-box.gr #313
4+
frontend/tests/cases/synthesis/graded-base/list/drop.gr #281
5+
frontend/tests/cases/synthesis/graded-base/misc/either.gr #281
6+
examples/effects_nondet.gr #312
7+
examples/effects_state.gr #312
8+
frontend/tests/cases/positive/effect-handlers/effects_state.gr #312

granule.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ test-suite gr-golden
277277
, strict
278278
, tasty
279279
, tasty-golden
280+
, tasty-expected-failure
280281

281282
-- Executables
282283
--

interpreter/tests/Golden.hs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@ import Control.Monad (unless)
33
import Data.Algorithm.Diff (getGroupedDiff)
44
import Data.Algorithm.DiffOutput (ppDiff)
55
import Data.List (sort, isInfixOf)
6+
import qualified Data.Map as M
7+
import Data.Maybe (mapMaybe)
68
import Data.Functor((<&>))
79
import Test.Tasty (defaultMain, TestTree, testGroup)
10+
import Test.Tasty.ExpectedFailure (expectFailBecause)
811
import Test.Tasty.Golden (goldenVsFile)
912
import qualified Test.Tasty.Golden as G
1013
import Test.Tasty.Golden.Advanced (goldenTest)
14+
import Test.Tasty.Runners (TestTree(..))
1115
import System.Directory (renameFile, doesFileExist)
1216
import System.Exit (ExitCode)
1317
import System.FilePath (dropExtension, pathSeparator)
@@ -33,6 +37,15 @@ main = do
3337
putStrLn $ "\nExcluding 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
5890
applyConfig :: 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

Comments
 (0)