Skip to content

feat: log clock calls, traps, time advancement #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2025

Conversation

spikecurtis
Copy link
Collaborator

@spikecurtis spikecurtis commented May 23, 2025

fixes #13

Adds logging of traps, calls, and advancing the clock like:

=== CONT  Test_MultipleTraps
    mock.go:438: Mock Clock - Trap Now(..., [0])
    mock.go:438: Mock Clock - Trap Now(..., [1])
    mock.go:200: Mock Clock - Now([0 1]) call, matched 2 traps
    mock_test.go:340: Mock Clock - Advance(1s)
    mock_test.go:350: Mock Clock - Advance(1s)
    mock.go:200: Mock Clock - Now([end]) call, matched 0 traps

This should make it easier to debug a variety of issues, including not setting the trap before the call happens.

Copy link
Collaborator Author

spikecurtis commented May 23, 2025

@spikecurtis spikecurtis requested a review from mafredri May 23, 2025 11:03
@spikecurtis spikecurtis self-assigned this May 23, 2025
@spikecurtis spikecurtis marked this pull request as ready for review May 23, 2025 11:03
Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, thanks!

case clockFunctionUntil:
return fmt.Sprintf("Until(%s, %v)", a.Time, a.Tags)
default:
return "?????"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return "?????"
return fmt.Sprintf("Unknown apiCall(fn=%d)", a.fn)

case clockFunctionUntil:
return "Until"
default:
return "?????"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return "?????"
return fmt.Sprintf("Unknown clockFunction(%d)", c)

@spikecurtis spikecurtis force-pushed the spike/13-log-mock-calls branch from 76e0ead to 872f6cb Compare May 23, 2025 11:32
@spikecurtis spikecurtis changed the base branch from spike/fail-unreleased-calls to graphite-base/16 May 23, 2025 11:33
@spikecurtis spikecurtis force-pushed the spike/13-log-mock-calls branch from 872f6cb to 8c9d9c1 Compare May 23, 2025 11:34
@graphite-app graphite-app bot changed the base branch from graphite-base/16 to main May 23, 2025 11:34
@spikecurtis spikecurtis force-pushed the spike/13-log-mock-calls branch from 8c9d9c1 to 0e4c880 Compare May 23, 2025 11:34
@spikecurtis spikecurtis merged commit 49f235b into main May 23, 2025
Copy link
Collaborator Author

Merge activity

@spikecurtis spikecurtis deleted the spike/13-log-mock-calls branch June 3, 2025 05:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Protect against common errors when using Trap
2 participants