Skip to content
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

Add test case to gitparse that previously caused a panic #1571

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dustin-decker
Copy link
Contributor

@dustin-decker dustin-decker commented Jul 28, 2023

Adds a test case to gitparse that caused a panic which was fixed by #1570

@bill-rich
Copy link
Collaborator

Tested and the #1570 fix handles this. It looked to me like it shouldn't miss anything at first glance. If currentDiff is nil, then it shouldn't be able to exceed the max diff side, unless I'm overlooking something.

@dustin-decker dustin-decker changed the title Add panic test case to fix to gitparse Add test case to gitparse that previously caused a panic Jan 26, 2024
@dustin-decker dustin-decker marked this pull request as ready for review January 26, 2024 06:32
@dustin-decker dustin-decker requested a review from a team as a code owner January 26, 2024 06:32
Comment on lines +17 to +18
//go:embed testdata/panic_diff_1.txt
panicDiff1 []byte
Copy link
Collaborator

Choose a reason for hiding this comment

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

Cool, I didn't know you could do this!

Comment on lines +33 to +38
// setup logger
logger, sync := log.New("forager/scanner",
log.WithConsoleSink(os.Stderr),
)
defer func() { _ = sync() }()
context.SetDefaultLogger(logger)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This log setup can probably be removed - we now have a default global logger that will be used from context.Background().

ctx := context.Background()
parser := NewParser()
commitCh := make(chan Commit, 64)
parser.FromReader(ctx, io.NopCloser(bytes.NewReader(panicDiff1)), commitCh, false)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the idea of this test that this line won't panic? What do you think about using assert.NotPanics to make that explicit?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants