Skip to content

Refactor transport tests to better report pattern match failures#484

Merged
LaurentRDC merged 1 commit intomasterfrom
test-debugging
Apr 21, 2026
Merged

Refactor transport tests to better report pattern match failures#484
LaurentRDC merged 1 commit intomasterfrom
test-debugging

Conversation

@LaurentRDC
Copy link
Copy Markdown
Member

@LaurentRDC LaurentRDC commented Apr 21, 2026

Many tests from network-transport-tests use partial pattern matches to test expectations. Unfortunately, this leads to hard-to-debug problems.

This PR adds functionality to network-transport-tests to express expectations in a way that makes it easier to report problems. See below for an example.

Before:

$ cabal test network-transport-quic
network-transport-quic
...
    closeEndPoint:                   FAIL (0.55s)
      Exception: user error (Pattern match failure in 'do' block at src/Network/Transport/Tests.hs:677:7-28)
      Trace:
      0 ErrorEvent (TransportError (EventConnectionLost 127.0.0.1:50190:3) "Connection reset")
      1 Received 12884901888 ["ping"]
      2 ConnectionOpened 12884901888 ReliableOrdered 127.0.0.1:50190:3
      3 "127.0.0.1:50190:3"
       [3 retries, 0 μs delay]
      Use -p '/closeEndPoint/' to rerun this test only.
...

Now:

$ cabal test network-transport-quic
network-transport-quic
...
    closeEndPoint:                   FAIL (0.53s)
      Exception: user error (testCloseEndPoint (server, 2): ConnectionClosed: expected ConnectionClosed 12884901888, got ErrorEvent (TransportError (EventConnectionLost 127.0.0.1:58512:3) "Connection reset")
      CallStack (from HasCallStack):
        expectEq, called at src/Network/Transport/Tests.hs:712:7 in network-transport-tests-0.3.4-inplace:Network.Transport.Tests)
      Trace:
      0 ErrorEvent (TransportError (EventConnectionLost 127.0.0.1:58512:3) "Connection reset")
      1 Received 12884901888 ["ping"]
      2 (12884901888,ReliableOrdered,"127.0.0.1:58512:3")
      3 "127.0.0.1:58512:3"
       [3 retries, 0 μs delay]
      Use -p '/closeEndPoint/' to rerun this test only.
...

@LaurentRDC LaurentRDC marked this pull request as ready for review April 21, 2026 00:37
@LaurentRDC
Copy link
Copy Markdown
Member Author

I think I have a fix for the QUIC flaky tests, but this is going to be in a separate PR

@LaurentRDC LaurentRDC merged commit e5e68c8 into master Apr 21, 2026
26 of 36 checks passed
@LaurentRDC LaurentRDC deleted the test-debugging branch April 21, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant