@@ -73,46 +73,67 @@ deprecatedRareNixQuirkTests = Set.fromList
7373 ]
7474
7575genTests :: IO TestTree
76- genTests = do
77- (coerce -> testFiles :: [FilePath ]) <-
78- sort
79- -- Disabling the not yet done tests cases.
80- . filter ((`Set.notMember` (newFailingTests `Set.union` deprecatedRareNixQuirkTests)) . takeBaseName)
81- . filter ((/= " .xml" ) . takeExtension)
82- <$> coerce (globDir1 (compile " *-*-*.*" ) " data/nix/tests/lang" )
83- let
84- testsByName :: Map FilePath [FilePath ]
85- testsByName = groupBy (coerce (takeFileName . dropExtensions)) testFiles
86-
87- testsByType :: Map [String ] [(FilePath , [FilePath ])]
88- testsByType = groupBy testType (Map. toList testsByName)
89-
90- testGroups :: [TestTree ]
91- testGroups = mkTestGroup <$> coerce (Map. toList testsByType)
92-
93- pure $ localOption (mkTimeout 2000000 ) $
94- testGroup
95- " Nix (upstream) language tests"
96- testGroups
76+ genTests =
77+ do
78+ testFiles <- getTestFiles
79+ let
80+ testsGroupedByName :: Map Path [Path ]
81+ testsGroupedByName = groupBy (takeFileName . dropExtensions) testFiles
82+
83+ testsGroupedByTypeThenName :: Map [String ] [(Path , [Path ])]
84+ testsGroupedByTypeThenName = groupBy testType (Map. toList testsGroupedByName)
85+
86+ testTree :: [TestTree ]
87+ testTree = mkTestGroup <$> Map. toList testsGroupedByTypeThenName
88+
89+ pure $
90+ localOption
91+ (mkTimeout 2000000 )
92+ $ testGroup
93+ " Nix (upstream) language tests"
94+ testTree
9795 where
98- testType :: (FilePath , b ) -> [String ]
99- testType (fullpath, _files) = take 2 $ splitOn " -" $ coerce takeFileName fullpath
100-
101- mkTestGroup :: ([String ], [(String , [Path ])]) -> TestTree
102- mkTestGroup (kind, tests) =
103- testGroup (String. unwords kind) $ mkTestCase kind <$> tests
104-
105- mkTestCase :: [String ] -> (String , [Path ]) -> TestTree
106- mkTestCase kind (basename, files) = testCase (coerce takeFileName basename) $
107- do
108- time <- liftIO getCurrentTime
109- let opts = defaultOptions time
110- case kind of
111- [" parse" , " okay" ] -> assertParse opts $ the files
112- [" parse" , " fail" ] -> assertParseFail opts $ the files
113- [" eval" , " okay" ] -> assertEval opts files
114- [" eval" , " fail" ] -> assertEvalFail $ the files
115- _ -> fail $ " Unexpected: " <> show kind
96+
97+ getTestFiles :: IO [Path ]
98+ getTestFiles = sortTestFiles <$> collectTestFiles
99+ where
100+ collectTestFiles :: IO [Path ]
101+ collectTestFiles = coerce (globDir1 (compile " *-*-*.*" ) nixTestDir)
102+
103+ sortTestFiles :: [Path ] -> [Path ]
104+ sortTestFiles =
105+ sort
106+ -- Disabling the not yet done tests cases.
107+ . filter withoutDisabledTests
108+ . filter withoutXml
109+ where
110+ withoutDisabledTests :: Path -> Bool
111+ withoutDisabledTests = (`Set.notMember` (newFailingTests `Set.union` deprecatedRareNixQuirkTests)) . takeBaseName
112+
113+ withoutXml :: Path -> Bool
114+ withoutXml = (/= " .xml" ) . takeExtension
115+
116+ testType :: (Path , b ) -> [String ]
117+ testType (fullpath, _files) = coerce (take 2 . splitOn " -" ) $ takeFileName fullpath
118+
119+ mkTestGroup :: ([String ], [(Path , [Path ])]) -> TestTree
120+ mkTestGroup (tType, tests) =
121+ testGroup (String. unwords tType) $ mkTestCase <$> tests
122+ where
123+ mkTestCase :: (Path , [Path ]) -> TestTree
124+ mkTestCase (basename, files) =
125+ testCase
126+ (coerce $ takeFileName basename)
127+ $ do
128+ time <- liftIO getCurrentTime
129+ let opts = defaultOptions time
130+ case tType of
131+ [" parse" , " okay" ] -> assertParse opts $ the files
132+ [" parse" , " fail" ] -> assertParseFail opts $ the files
133+ [" eval" , " okay" ] -> assertEval opts files
134+ [" eval" , " fail" ] -> assertEvalFail $ the files
135+ _ -> fail $ " Unexpected: " <> show tType
136+
116137
117138assertParse :: Options -> Path -> Assertion
118139assertParse _opts file =
0 commit comments