Skip to content

Commit c63c0f7

Browse files
authored
Merge pull request #5890 from unisonweb/runarorama/debugtests
2 parents a330f60 + 3e11561 commit c63c0f7

File tree

2 files changed

+12
-2
lines changed
  • lib/unison-prelude/src/Unison
  • unison-cli/src/Unison/Codebase/Editor/HandleInput

2 files changed

+12
-2
lines changed

lib/unison-prelude/src/Unison/Debug.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ data DebugFlag
4646
| PatternCoverageConstraintSolver
4747
| KindInference
4848
| Update
49+
| Tests
4950
deriving (Eq, Ord, Show, Bounded, Enum)
5051

5152
debugFlags :: Set DebugFlag
@@ -74,6 +75,7 @@ debugFlags = case (unsafePerformIO (lookupEnv "UNISON_DEBUG")) of
7475
"PATTERN_COVERAGE_CONSTRAINT_SOLVER" -> pure PatternCoverageConstraintSolver
7576
"KIND_INFERENCE" -> pure KindInference
7677
"UPDATE" -> pure Update
78+
"TESTS" -> pure Tests
7779
_ -> empty
7880
{-# NOINLINE debugFlags #-}
7981

@@ -145,6 +147,10 @@ debugPatternCoverageConstraintSolver :: Bool
145147
debugPatternCoverageConstraintSolver = PatternCoverageConstraintSolver `Set.member` debugFlags
146148
{-# NOINLINE debugPatternCoverageConstraintSolver #-}
147149

150+
debugTests :: Bool
151+
debugTests = Tests `Set.member` debugFlags
152+
{-# NOINLINE debugTests #-}
153+
148154
-- | Use for trace-style selective debugging.
149155
-- E.g. 1 + (debug Sync "The second number" 2)
150156
--
@@ -201,3 +207,4 @@ shouldDebug = \case
201207
PatternCoverageConstraintSolver -> debugPatternCoverageConstraintSolver
202208
KindInference -> debugKindInference
203209
Update -> debugUpdate
210+
Tests -> debugTests

unison-cli/src/Unison/Codebase/Editor/HandleInput/Tests.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import Unison.Codebase.Path qualified as Path
3232
import Unison.Codebase.Runtime qualified as Runtime
3333
import Unison.Codebase.Runtime.Profile (ProfileSpec (NoProf))
3434
import Unison.ConstructorReference (GConstructorReference (..))
35+
import Unison.Debug qualified as Debug
3536
import Unison.HashQualified qualified as HQ
3637
import Unison.Name (Name)
3738
import Unison.Names (Names)
@@ -114,13 +115,15 @@ handleTest TestInput {includeLibNamespace, path, showFailures, showSuccesses} =
114115
Cli.respond (TermNotFound' . SH.shortenTo hqLength . Reference.toShortHash $ Reference.DerivedId r)
115116
pure []
116117
Just tm -> do
118+
let testName = Cli.prettyTermName fqnPPE (Referent.fromTermReferenceId r)
119+
Debug.whenDebug Debug.Tests $
120+
liftIO (putStrLn $ "\nAbout to run test:" <> ("\n" <> P.toPlain 80 testName))
117121
Cli.respond $ TestIncrementalOutputStart fqnPPE (n, total) r
118122
-- v don't cache; test cache populated below
119-
tm' <- RuntimeUtils.evalPureUnison fqnPPE False tm
123+
tm' <- Cli.time ("\n" <> P.toPlain 80 testName) $ RuntimeUtils.evalPureUnison fqnPPE False tm
120124
case tm' of
121125
Left e -> do
122126
Cli.respond $ TestIncrementalOutputEnd fqnPPE (n, total) r False
123-
let testName = (Cli.prettyTermName fqnPPE (Referent.fromTermReferenceId r))
124127
Cli.returnEarly $ EvaluationFailure (P.callout ("Error while evaluating test " <> P.backticked testName <> ":") . P.indentN 2) e
125128
Right tm' -> do
126129
-- After evaluation, cache the result of the test

0 commit comments

Comments
 (0)