Skip to content

Commit

Permalink
Add an :incorrect transcript tag
Browse files Browse the repository at this point in the history
This is basically the opposite of `:failure` – it indicates that a
successful result is incorrect. The correct result may either be an
error (which will be caught by the transcript runner) or a different
result then what is currently expected (which won’t be caught by the
runner, but the appearance of `:incorrect` conveys to the programmer
that the output.md diff may be an improvement from the previous state).
  • Loading branch information
sellout committed Oct 7, 2024
1 parent dc2db62 commit 728c2a3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion unison-cli/src/Unison/Codebase/Transcript.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Unison.Core.Project (ProjectBranchName, ProjectName)
import Unison.Prelude
import Unison.Project (ProjectAndBranch)

data Result = Success | Error | Failure
data Result = Success | Incorrect | Error | Failure

type ScratchFileName = Text

Expand Down
1 change: 1 addition & 0 deletions unison-cli/src/Unison/Codebase/Transcript/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ expectingError :: P Result
expectingError =
(Error <$ word ":error")
<|> (Failure <$ word ":failure")
<|> (Incorrect <$ word ":incorrect")
<|> pure Success

untilSpace1 :: P Text
Expand Down
10 changes: 10 additions & 0 deletions unison-cli/src/Unison/Codebase/Transcript/Runner.hs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,14 @@ run isTest verbosity dir stanzas codebase runtime sbRuntime nRuntime ucmVersion
liftIO $ writeIORef hasErrors True
liftIO (readIORef allowErrors) >>= \case
Success -> liftIO . dieWithMsg $ Pretty.toPlain terminalWidth msg
Incorrect ->
liftIO . dieWithMsg . Pretty.toPlain terminalWidth $
"The stanza above previously had an incorrect successful result, but now fails with"
<> "\n"
<> Pretty.border 2 msg
<> "\n"
<> "if this is the expected result, replace `:incorrect` with `:error`, otherwise "
<> "change `:incorrect` to `:failure`."
_ -> do
liftIO . output . Pretty.toPlain terminalWidth $ "\n" <> msg <> "\n"
awaitInput
Expand Down Expand Up @@ -366,6 +374,7 @@ run isTest verbosity dir stanzas codebase runtime sbRuntime nRuntime ucmVersion
output rendered
when (Output.isFailure o) case errOk of
Success -> dieWithMsg rendered
Incorrect -> dieWithMsg rendered
_ -> writeIORef hasErrors True

printNumbered :: Output.NumberedOutput -> IO Output.NumberedArgs
Expand All @@ -376,6 +385,7 @@ run isTest verbosity dir stanzas codebase runtime sbRuntime nRuntime ucmVersion
output rendered
when (Output.isNumberedFailure o) case errOk of
Success -> dieWithMsg rendered
Incorrect -> dieWithMsg rendered
_ -> writeIORef hasErrors True
pure numberedArgs

Expand Down

0 comments on commit 728c2a3

Please sign in to comment.