mirror of
https://github.com/github/semantic.git
synced 2025-01-04 05:27:08 +03:00
better naming
This commit is contained in:
parent
973490b5d4
commit
efa949d402
@ -73,9 +73,8 @@ assertJQExpressionSucceeds directive core = do
|
|||||||
catch @_ @Streaming.Process.ProcessExitedUnsuccessfully jqPipeline $ \err -> do
|
catch @_ @Streaming.Process.ProcessExitedUnsuccessfully jqPipeline $ \err -> do
|
||||||
HUnit.assertFailure (unlines [errorMsg, dirMsg, jsonMsg, treeMsg, show err])
|
HUnit.assertFailure (unlines [errorMsg, dirMsg, jsonMsg, treeMsg, show err])
|
||||||
|
|
||||||
|
fixtureTestTreeForFile :: HasCallStack => FilePath -> Tasty.TestTree
|
||||||
assertTranslationSucceeds :: HasCallStack => FilePath -> Tasty.TestTree
|
fixtureTestTreeForFile fp = HUnit.testCaseSteps fp $ \step -> withFrozenCallStack $ do
|
||||||
assertTranslationSucceeds fp = HUnit.testCaseSteps fp $ \step -> withFrozenCallStack $ do
|
|
||||||
fileContents <- ByteString.readFile ("semantic-python/test/fixtures" </> fp)
|
fileContents <- ByteString.readFile ("semantic-python/test/fixtures" </> fp)
|
||||||
directives <- case Directive.parseDirectives fileContents of
|
directives <- case Directive.parseDirectives fileContents of
|
||||||
Right dir -> pure dir
|
Right dir -> pure dir
|
||||||
@ -86,17 +85,18 @@ assertTranslationSucceeds fp = HUnit.testCaseSteps fp $ \step -> withFrozenCallS
|
|||||||
for_ directives $ \directive -> do
|
for_ directives $ \directive -> do
|
||||||
step (Directive.describe directive)
|
step (Directive.describe directive)
|
||||||
case coreResult of
|
case coreResult of
|
||||||
Right (Left _) | directive == Directive.Fails -> pure ()
|
Left err -> HUnit.assertFailure ("Parsing failed: " <> err)
|
||||||
|
Right (Left _) | directive == Directive.Fails -> pure ()
|
||||||
|
Right (Right _) | directive == Directive.Fails -> HUnit.assertFailure ("Expected translation to fail")
|
||||||
Right (Right item) -> assertJQExpressionSucceeds directive item
|
Right (Right item) -> assertJQExpressionSucceeds directive item
|
||||||
Right (Left err) -> HUnit.assertFailure ("Compilation failed: " <> err)
|
Right (Left err) -> HUnit.assertFailure ("Compilation failed: " <> err)
|
||||||
Left err -> HUnit.assertFailure ("Parsing failed: " <> err)
|
|
||||||
|
|
||||||
|
|
||||||
milestoneFixtures :: IO Tasty.TestTree
|
milestoneFixtures :: IO Tasty.TestTree
|
||||||
milestoneFixtures = do
|
milestoneFixtures = do
|
||||||
files <- liftIO (listDirectory "semantic-python/test/fixtures")
|
files <- liftIO (listDirectory "semantic-python/test/fixtures")
|
||||||
let pythons = sort (filter ("py" `isExtensionOf`) files)
|
let pythons = sort (filter ("py" `isExtensionOf`) files)
|
||||||
pure $ Tasty.testGroup "Translation" (fmap assertTranslationSucceeds pythons)
|
pure $ Tasty.testGroup "Translation" (fmap fixtureTestTreeForFile pythons)
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
|
Loading…
Reference in New Issue
Block a user