From efa949d402870d07cee93cdf40d63f97bce0ea40 Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Thu, 29 Aug 2019 09:30:58 -0400 Subject: [PATCH] better naming --- semantic-python/test/Test.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/semantic-python/test/Test.hs b/semantic-python/test/Test.hs index 4ffd3aeb5..baf6e351b 100644 --- a/semantic-python/test/Test.hs +++ b/semantic-python/test/Test.hs @@ -73,9 +73,8 @@ assertJQExpressionSucceeds directive core = do catch @_ @Streaming.Process.ProcessExitedUnsuccessfully jqPipeline $ \err -> do HUnit.assertFailure (unlines [errorMsg, dirMsg, jsonMsg, treeMsg, show err]) - -assertTranslationSucceeds :: HasCallStack => FilePath -> Tasty.TestTree -assertTranslationSucceeds fp = HUnit.testCaseSteps fp $ \step -> withFrozenCallStack $ do +fixtureTestTreeForFile :: HasCallStack => FilePath -> Tasty.TestTree +fixtureTestTreeForFile fp = HUnit.testCaseSteps fp $ \step -> withFrozenCallStack $ do fileContents <- ByteString.readFile ("semantic-python/test/fixtures" fp) directives <- case Directive.parseDirectives fileContents of Right dir -> pure dir @@ -86,17 +85,18 @@ assertTranslationSucceeds fp = HUnit.testCaseSteps fp $ \step -> withFrozenCallS for_ directives $ \directive -> do step (Directive.describe directive) 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 (Left err) -> HUnit.assertFailure ("Compilation failed: " <> err) - Left err -> HUnit.assertFailure ("Parsing failed: " <> err) milestoneFixtures :: IO Tasty.TestTree milestoneFixtures = do files <- liftIO (listDirectory "semantic-python/test/fixtures") let pythons = sort (filter ("py" `isExtensionOf`) files) - pure $ Tasty.testGroup "Translation" (fmap assertTranslationSucceeds pythons) + pure $ Tasty.testGroup "Translation" (fmap fixtureTestTreeForFile pythons) main :: IO () main = do