mirror of
https://github.com/github/semantic.git
synced 2024-11-29 02:44:36 +03:00
Avoid 'head', which is partial.
This commit is contained in:
parent
1731df8bd8
commit
18a1a0d8b7
@ -77,8 +77,10 @@ assertJQExpressionSucceeds directive tree core = do
|
|||||||
|
|
||||||
fixtureTestTreeForFile :: HasCallStack => Path.RelFile -> Tasty.TestTree
|
fixtureTestTreeForFile :: HasCallStack => Path.RelFile -> Tasty.TestTree
|
||||||
fixtureTestTreeForFile fp = HUnit.testCaseSteps (Path.toString fp) $ \step -> withFrozenCallStack $ do
|
fixtureTestTreeForFile fp = HUnit.testCaseSteps (Path.toString fp) $ \step -> withFrozenCallStack $ do
|
||||||
let fullPath = Path.relDir "semantic-python/test/fixtures" </> fp
|
let fullPath = Path.relDir "semantic-python/test/fixtures" </> fp
|
||||||
perish s = liftIO (HUnit.assertFailure ("Directive parsing error: " <> s))
|
perish s = liftIO (HUnit.assertFailure ("Directive parsing error: " <> s))
|
||||||
|
isComment = (== Just '#') . fmap fst . ByteString.uncons
|
||||||
|
|
||||||
|
|
||||||
-- Slurp the input file, taking lines from the beginning until we
|
-- Slurp the input file, taking lines from the beginning until we
|
||||||
-- encounter a line that doesn't have a '#'. For each line, parse
|
-- encounter a line that doesn't have a '#'. For each line, parse
|
||||||
@ -87,9 +89,8 @@ fixtureTestTreeForFile fp = HUnit.testCaseSteps (Path.toString fp) $ \step -> wi
|
|||||||
runResourceT
|
runResourceT
|
||||||
. Stream.toList_
|
. Stream.toList_
|
||||||
. Stream.mapM (either perish pure . Directive.parseDirective)
|
. Stream.mapM (either perish pure . Directive.parseDirective)
|
||||||
. Stream.takeWhile ((== '#') . ByteString.head)
|
. Stream.takeWhile isComment
|
||||||
. Stream.mapped ByteStream.toStrict
|
. Stream.mapped ByteStream.toStrict
|
||||||
. ByteStream.denull
|
|
||||||
. ByteStream.lines
|
. ByteStream.lines
|
||||||
. ByteStream.readFile @(ResourceT IO)
|
. ByteStream.readFile @(ResourceT IO)
|
||||||
$ Path.toString fullPath
|
$ Path.toString fullPath
|
||||||
|
Loading…
Reference in New Issue
Block a user