Use Text for test names

This commit is contained in:
George Thomas 2026-01-07 00:43:51 +00:00
parent 3721c27c32
commit f634b9b42d
3 changed files with 8 additions and 8 deletions

View File

@ -30,7 +30,7 @@ tests :: TestTree IO ()
tests =
test "tests" pure $
enumerate <&> \isRealData@(bool "examples" "real" -> t) ->
test (mkTestName t) pure $
test (mkTestName $ T.pack t) pure $
[ Day1.puzzle
, Day2.puzzle
, Day3.puzzle
@ -44,7 +44,7 @@ tests =
]
<&> \Puzzle{number = show -> pt, parser, parts, extraTests} ->
testLazy
(mkTestName pt)
(mkTestName $ T.pack pt)
( \() -> do
let fp = "../inputs/" <> t <> "/" <> pt
input <-
@ -58,7 +58,7 @@ tests =
)
$ ( finites <&> \(n@(show . succ @Int . fromIntegral -> nt)) ->
test
(mkTestName nt)
(mkTestName $ T.pack nt)
(\(_, rs, _) -> golden ("../outputs/" <> t <> "/" <> pt <> "/" <> nt) $ rs n <> "\n")
[]
)

View File

@ -286,10 +286,10 @@ data TestFailure
| GoldenFailure {expected :: Text, actual :: Text}
deriving (Show)
newtype TestName = TestName String
newtype TestName = TestName Text
deriving newtype (IsString, Show)
mkTestName :: String -> TestName
mkTestName :: Text -> TestName
mkTestName = TestName
getTestTree :: TestTree m r -> Tree TestName
@ -319,7 +319,7 @@ displayTestResultsConsole terminalWidth testResult =
<> T.singleton icon
<> " "
<> setColour Dull White
<> T.pack name
<> name
<> maybe
mempty
( \_t@(showTime -> tt) ->
@ -327,7 +327,7 @@ displayTestResultsConsole terminalWidth testResult =
( fromIntegral $
maybe
3
(\n -> n - (2 * indent + length name + T.length tt + 2))
(\n -> n - (2 * indent + T.length name + T.length tt + 2))
terminalWidth
)
" "

View File

@ -41,7 +41,7 @@ puzzle =
in map
( \n ->
test
(mkTestName $ show n)
(mkTestName $ T.show n)
( \frames -> do
g <- lookupFrame n frames
golden (path <> "frames/" <> show n) $ drawGrid g