-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: improve expectFailForPaths (#46)
* Move `expectFailForPaths` from Test/Parsing.hs to Test/Util.hs * Move `parseAndCheck` from Test/Util.hs to Test/Checking.hs * expectFailForPaths now checks that paths actually exist... * ...so remove a couple that didn't!
- Loading branch information
Showing
6 changed files
with
36 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,31 @@ | ||
module Test.Checking (getCheckingTests, expectedCheckingFails) where | ||
module Test.Checking (parseAndCheck, getCheckingTests, expectedCheckingFails) where | ||
|
||
import Test.Parsing (expectedParsingFails, expectFailForPaths) | ||
import Test.Util (parseAndCheck) | ||
import Brat.Load | ||
import Brat.Naming (root) | ||
import Test.Parsing (expectedParsingFails) | ||
import Test.Util (expectFailForPaths) | ||
|
||
import Control.Monad.Except | ||
import System.FilePath | ||
import Test.Tasty | ||
import Test.Tasty.HUnit | ||
import Test.Tasty.Silver | ||
|
||
expectedCheckingFails = map ("examples" </>) ["nested-abstractors.brat" | ||
,"karlheinz_alias.brat" | ||
,"hea.brat" | ||
] | ||
|
||
parseAndCheckXF :: FilePath -> TestTree | ||
parseAndCheckXF :: [FilePath] -> [TestTree] | ||
parseAndCheckXF = expectFailForPaths (expectedParsingFails ++ expectedCheckingFails) (parseAndCheck []) | ||
|
||
getCheckingTests :: IO TestTree | ||
getCheckingTests = testGroup "checking" . fmap parseAndCheckXF <$> findByExtension [".brat"] "examples" | ||
getCheckingTests = testGroup "checking" . parseAndCheckXF <$> findByExtension [".brat"] "examples" | ||
|
||
parseAndCheck :: [FilePath] -> FilePath -> TestTree | ||
parseAndCheck libDirs file = testCase (show file) $ do | ||
env <- runExceptT $ loadFilename root libDirs file | ||
case env of | ||
Left err -> assertFailure (show err) | ||
Right (venv, nouns, holes, _, _) -> | ||
((length venv) + (length nouns) + (length holes) > 0) @? "Should produce something" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module Test.Libs where | ||
|
||
import Test.Util | ||
import Test.Checking (parseAndCheck) | ||
|
||
import Test.Tasty | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters