-
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.
Implement new --command-log-read-strategy option
- Loading branch information
Showing
26 changed files
with
1,181 additions
and
334 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
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[2024-06-01 08:57:15][Command][cabal test f...] Starting... | ||
[2024-06-01 08:57:16][Command][cabal test f...] Build profile: -w ghc-9.8.2 -O2 | ||
[2024-06-01 08:57:16][Command][cabal test f...] In order, the following will be built (use -v for more details): | ||
[2024-06-01 08:57:16][Command][cabal test f...] - shrun-0.9 (test:functional) (file /home/tommy/Dev/tommy/github/shrun/dist-newstyle/build/x86_64-linux/ghc-9.8.2/shrun-0.9/opt/cache/build changed) |
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
48 changes: 48 additions & 0 deletions
48
src/Shrun/Configuration/Data/CommandLogging/ReadStrategy.hs
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{-# LANGUAGE UndecidableInstances #-} | ||
|
||
module Shrun.Configuration.Data.CommandLogging.ReadStrategy | ||
( ReadStrategy (..), | ||
parseReadStrategy, | ||
readStrategyStr, | ||
) | ||
where | ||
|
||
import Data.String (IsString) | ||
import Shrun.Configuration.Default (Default (def)) | ||
import Shrun.Prelude | ||
|
||
-- | Different read strategies for simplicity vs. potential prettier | ||
-- formatting. | ||
data ReadStrategy | ||
= -- | Default strategy. Reads N bytes at a time. | ||
ReadBlock | ||
| -- | Reads N bytes at a time but attempts to distinguish "complete" (newline | ||
-- terminated) vs. "partial" (anything else) reads. We do this to make | ||
-- the file log output prettier. | ||
ReadBlockBufferLine | ||
deriving stock (Eq, Show) | ||
|
||
instance Default ReadStrategy where | ||
def = ReadBlock | ||
|
||
instance DecodeTOML ReadStrategy where | ||
tomlDecoder = parseReadStrategy tomlDecoder | ||
|
||
-- | Parses 'ReadStrategy'. | ||
parseReadStrategy :: (MonadFail m) => m Text -> m ReadStrategy | ||
parseReadStrategy getTxt = | ||
getTxt >>= \case | ||
"block" -> pure ReadBlock | ||
"block-buffer-line" -> pure ReadBlockBufferLine | ||
other -> | ||
fail | ||
$ mconcat | ||
[ "Unrecognized read strategy: '", | ||
unpack other, | ||
"'. Expected one of ", | ||
readStrategyStr | ||
] | ||
|
||
-- | Available 'ReadStrategy' strings. | ||
readStrategyStr :: (IsString a) => a | ||
readStrategyStr = "(block |block-buffer-line)" |
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
Oops, something went wrong.