From a5d9367906a46feaea90c6e8e13e834f69172e89 Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Fri, 20 Sep 2019 11:52:39 -0400 Subject: [PATCH] :sparkles: parseFilePath. --- test/Integration/Spec.hs | 2 +- test/SpecHelpers.hs | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/test/Integration/Spec.hs b/test/Integration/Spec.hs index bff7c5558..956cf9231 100644 --- a/test/Integration/Spec.hs +++ b/test/Integration/Spec.hs @@ -45,7 +45,7 @@ testForExample = \case ("parses " <> Path.toString parseOutput) (\ref new -> ["git", "diff", ref, new]) (Path.toString parseOutput) - (parseFilePath ?session (Path.toString file) >>= either throw (pure . BL.fromStrict)) + (parseFilePath ?session file >>= either throw (pure . BL.fromStrict)) -- | Return all the examples from the given directory. Examples are expected to diff --git a/test/SpecHelpers.hs b/test/SpecHelpers.hs index ab123ba69..2bfe4c5a0 100644 --- a/test/SpecHelpers.hs +++ b/test/SpecHelpers.hs @@ -76,7 +76,6 @@ import Semantic.Api hiding (File, Blob, BlobPair) import System.Exit (die) import Control.Exception (displayException) import qualified System.Path as Path -import qualified System.Path.PartClass as Part runBuilder :: Builder -> ByteString runBuilder = toStrict . toLazyByteString @@ -90,10 +89,10 @@ instance IsString Name where diffFilePaths :: TaskSession -> Both FilePath -> IO ByteString diffFilePaths session paths = readFilePathPair paths >>= runTask session . parseDiffBuilder @[] DiffSExpression . pure >>= either (die . displayException) (pure . runBuilder) --- | Returns an s-expression parse tree for the specified FilePath. -parseFilePath :: TaskSession -> FilePath -> IO (Either SomeException ByteString) +-- | Returns an s-expression parse tree for the specified path. +parseFilePath :: TaskSession -> Path.RelFile -> IO (Either SomeException ByteString) parseFilePath session path = do - blob <- readBlobFromFile (fileForPath path) + blob <- readBlobFromFile (fileForPath (Path.toString path)) res <- runTask session $ parseTermBuilder TermSExpression (toList blob) pure (runBuilder <$> res) @@ -102,7 +101,7 @@ readFilePathPair :: Both FilePath -> IO BlobPair readFilePathPair paths = let paths' = fmap fileForPath paths in runBothWith readFilePair paths' -parseTestFile :: Part.AbsRel ar => Parser term -> Path.File ar -> IO (Blob, term) +parseTestFile :: Parser term -> Path.RelFile -> IO (Blob, term) parseTestFile parser path = runTaskOrDie $ do blob <- readBlob (fileForPath (Path.toString path)) term <- parse parser blob