Skip to content

Commit 85cdda7

Browse files
committed
test: Fail immediately on ErrorResponse
If the server replies with success: false, fail with the error message rather than hanging blocked waiting for some message to arrive (which it never will) Now, the linux failure of RunInTerminal, instead of a hang, looks like: ``` (default): FAIL (2.58s) test/haskell/Test/DAP/Init.hs:163: Aborted debugger thread: GHCi.Message.readPipe: end of file While handling GHCi.Message.readPipe: end of file IPE backtrace: GHC.Debugger.Monad. (:) GHC.Debugger.Run.debugExecution (haskell-debugger/GHC/Debugger/Run.hs:87:28-35) GHC.Debugger.fmap (haskell-debugger/GHC/Debugger/Monad.hs:98:14-20) Development.Debug.Adapter.Init.fmap (haskell-debugger/GHC/Debugger/Monad.hs:98:14-20) Development.Debug.Adapter.Init.catch (haskell-debugger/GHC/Debugger/Monad.hs:99:26-35) Development.Debug.Adapter.Init.debuggerThread (hdb/Development/Debug/Adapter/Init.hs:310:5-8) annotateCallStackIO, called at haskell-debugger/GHC/Debugger/Monad.hs:219:104 in haskell-debugger-0.12.3.0-inplace:GHC.Debugger.Monad DAP.Adaptor.registerNewDebugSession (src/DAP/Adaptor.hs:181:28-66) HasCallStack backtrace: collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:170:37 in ghc-internal:GHC.Internal.Exception toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:90:42 in ghc-internal:GHC.Internal.Exception throw, called at compiler/GHC/Runtime/Interpreter/Process.hs:133:7 in ghc-9.14.1-8674:GHC.Runtime.Interpreter.Process Use -p '/runInTerminal/&&/(default)/' to rerun this test only. (--internal-interpreter): OK (0.70s) --- SERVER OUTPUT --- See: /tmp/nix-shell-90645-1510503319/nix-shell-212288-2997796286/hdb-test-c88ed77b842c68ec/T44 Might need: KEEP_TEMP_DIRS=True --------------------- ``` Where the server output comes from the previous commits which now log the server stdout/stderr to persistent files if KEEP_TEMP_DIRS=True
1 parent 3c1acf3 commit 85cdda7

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

test/haskell/Test/DAP/Init.hs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,12 @@ handleServerTestDAP = do
156156
case mtxt of
157157
Just txt -> modifyTVar' clientFullOutput (txt:)
158158
Nothing -> pure ()
159-
Just "response" -> atomically $ writeTChan clientResponses payload
159+
Just "response" ->
160+
-- Fail immediately if the server reports failure, even if the test
161+
-- is blocked waiting for some other specific message.
162+
case parseMaybe parseSuccess payload of
163+
Just errMsg -> assertFailure errMsg
164+
Nothing -> atomically $ writeTChan clientResponses payload
160165
Just "request" -> atomically $ do writeTChan clientReverseRequests payload
161166
Just ty -> assertFailure $ "handleServerTestDAP: Unsupported message type: " ++ show ty
162167
Nothing -> assertFailure $ "Received message without type: " ++ show payload
@@ -171,3 +176,12 @@ handleServerTestDAP = do
171176
parseType = withObject "message" $ \o -> do
172177
typ <- o .: "type"
173178
pure ((typ :: String))
179+
180+
-- Returns an error message when success is False, Nothing when success is True.
181+
parseSuccess = withObject "response" $ \o -> do
182+
success <- o .: "success"
183+
if success
184+
then fail "success"
185+
else do
186+
msg <- o .:? "message" .!= "DAP response had success: false (no message)"
187+
pure (msg :: String)

0 commit comments

Comments
 (0)