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 description and speconly flag as comments #31

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ethclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"net/http"
"os"
"strings"

"github.com/ethereum/go-ethereum/rpc"
)
Expand Down Expand Up @@ -49,6 +50,14 @@ func (l *ethclientHandler) RotateLog(filename string) error {
return nil
}

// WriteComment adds the given text as a comment to the current log file.
func (l *ethclientHandler) WriteComment(text string) error {
text = strings.TrimSpace(text)
text = "// " + strings.Replace(text, "\n", "\n// ", -1) + "\n"
_, err := io.WriteString(l.logFile, text)
return err
}

func (l *ethclientHandler) Close() {
if l.logFile != nil {
l.logFile.Close()
Expand Down
9 changes: 9 additions & 0 deletions generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ func runGenerator(ctx context.Context) error {

// Write the exchange for each test in a separte file.
handler.RotateLog(filename)
if test.About != "" {
handler.WriteComment(test.About)
}
if test.SpecOnly {
if test.About != "" {
handler.WriteComment("")
}
handler.WriteComment("speconly: client response is only checked for schema validity.")
}

// Fail test fill if request exceeds timeout.
ctx, cancel := context.WithTimeout(ctx, 3*time.Second)
Expand Down
Loading
Loading