Skip to content

Commit

Permalink
src: check remained lines after all test cases (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
Defined2014 authored Sep 4, 2024
1 parent 7750e72 commit 314107b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,12 @@ func (t *tester) Run() error {
}
}

// check do we have remained lines in result file
buf := make([]byte, 32)
if n, _ := t.resultFD.ReadAt(buf, int64(t.buf.Len())); n != 0 {
return errors.Trace(errors.Errorf("There is extra data at the end of the result file: %s", buf))
}

fmt.Printf("%s: ok! %d test cases passed, take time %v s\n", t.testFileName(), testCnt, time.Since(startTime).Seconds())

if xmlPath != "" {
Expand Down Expand Up @@ -784,13 +790,10 @@ func (t *tester) execute(query query) error {
if err != nil {
return errors.Trace(errors.Errorf("run \"%v\" at line %d err %v", query.Query, query.Line, err))
}

// clear expected errors after we execute the first query
t.expectedErrs = nil

if err != nil {
return errors.Trace(errors.Errorf("run \"%v\" at line %d err %v", query.Query, query.Line, err))
}

if !record {
// check test result now
gotBuf := t.buf.Bytes()[offset:]
Expand Down

0 comments on commit 314107b

Please sign in to comment.