-
Notifications
You must be signed in to change notification settings - Fork 30
feat: Coverage-Based Deduplication Support via runtime/coverage Package #202
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
Changes from 10 commits
72a98a3
82ad3f8
97c399b
bb44533
70ce9c9
f127770
6c9c869
2b0838a
7535b0d
0f4aa64
bf077d9
507a7ae
0e5164e
e336519
02871c3
1361064
016e97a
b1f7d07
fb5e49c
87a23a7
b4c5457
bc82e36
3243cb1
99c1c6a
67dc6bf
7673905
333499d
108b37c
6c6c3f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,22 +1,254 @@ | ||||||||||||||||||||||||||
| // To activate, simply import this package for its side effects: | ||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||
| // import _ "github.com/keploy/go-sdk/v2/keploy" | ||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||
| // Then, build your application with atomic coverage instrumentation: | ||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||
| // go build -cover -covermode=atomic -o your-app . (cover flag is required https://pkg.go.dev/runtime/coverage@go1.25rc2#WriteCounters) | ||||||||||||||||||||||||||
| package keploy | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| import ( | ||||||||||||||||||||||||||
| "bufio" | ||||||||||||||||||||||||||
| "bytes" | ||||||||||||||||||||||||||
| "encoding/json" | ||||||||||||||||||||||||||
| "fmt" | ||||||||||||||||||||||||||
| "log" | ||||||||||||||||||||||||||
| "net" | ||||||||||||||||||||||||||
| "os" | ||||||||||||||||||||||||||
| "os/signal" | ||||||||||||||||||||||||||
| "syscall" | ||||||||||||||||||||||||||
| "os/exec" | ||||||||||||||||||||||||||
| "path/filepath" | ||||||||||||||||||||||||||
| "runtime/coverage" | ||||||||||||||||||||||||||
| "sort" | ||||||||||||||||||||||||||
| "strings" | ||||||||||||||||||||||||||
| "sync" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| "golang.org/x/tools/cover" | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const ( | ||||||||||||||||||||||||||
| // controlSocketPath is used by Keploy to send commands (START/END) to the app. | ||||||||||||||||||||||||||
| controlSocketPath = "/tmp/coverage_control.sock" | ||||||||||||||||||||||||||
| // dataSocketPath is used by the app to send coverage data back to Keploy. | ||||||||||||||||||||||||||
| dataSocketPath = "/tmp/keploy-coverage.sock" | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| const ( | |
| // controlSocketPath is used by Keploy to send commands (START/END) to the app. | |
| controlSocketPath = "/tmp/coverage_control.sock" | |
| // dataSocketPath is used by the app to send coverage data back to Keploy. | |
| dataSocketPath = "/tmp/keploy-coverage.sock" | |
| var ( | |
| // controlSocketPath is used by Keploy to send commands (START/END) to the app. | |
| controlSocketPath string | |
| // dataSocketPath is used by the app to send coverage data back to Keploy. | |
| dataSocketPath string | |
| // tempDir is the temporary directory for socket files. | |
| tempDir string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were we really getting this error here? "use of closed network connection", Because here you have just accepted the connection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no i did not get this error. this error can only happen when it gets closed manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use early return here. And then there is no need of else block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@officialasishkumar please address this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Copilot
AI
Jul 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On receiving an END command with a mismatched test ID, the code logs a warning but still proceeds to report coverage for the provided ID; you may want to skip reporting in this case to avoid inconsistent state.
| } | |
| err := reportCoverage(id); | |
| // Reset the currentTestID to an empty string to indicate that no test is currently being recorded. | |
| currentTestID = "" | |
| return | |
| } | |
| err := reportCoverage(id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can name the temp folder as keploy-coverage-<testID>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@officialasishkumar please address this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can write this condition like
if block.Count<=0{
continue
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add /v3 here as well