Skip to content

Commit

Permalink
Merge pull request #31 from fjl/test-comments
Browse files Browse the repository at this point in the history
add test description and speconly flag as comments
  • Loading branch information
lightclient authored Jan 30, 2024
2 parents 2693616 + 3569a46 commit fb24222
Show file tree
Hide file tree
Showing 3 changed files with 304 additions and 280 deletions.
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

0 comments on commit fb24222

Please sign in to comment.