Skip to content

Commit

Permalink
Merge branch 'master' into fix-xunit-result-xml-file
Browse files Browse the repository at this point in the history
  • Loading branch information
wuhuizuo authored Feb 18, 2024
2 parents 1d8edfb + aa83826 commit 03bb96f
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 12 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "CI"
on:
push:
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup go
uses: actions/setup-go@v4
with:
go-version: 1.21
- name: vet
run: go vet ./...
- name: build
run: make build
- name: test
run: make test
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
.PHONY: all build test tidy clean

GO := go

default: build

build:
go build -o mysql-tester ./src
$(GO) build -o mysql-tester ./src

debug:
go build -gcflags="all=-N -l" -o mysql-tester ./src
$(GO) build -gcflags="all=-N -l" -o mysql-tester ./src

test: build
go test -cover ./...
$(GO) test -cover ./...
#./mysql-tester -check-error

tidy:
go mod tidy
$(GO) mod tidy

clean:
go clean -i ./...
$(GO) clean -i ./...
rm -rf mysql-tester

gen_perror: generate_perror/main.go
go build -o gen_perror ./generate_perror
$(GO) build -o gen_perror ./generate_perror
11 changes: 7 additions & 4 deletions generate_perror/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func scanErrCodeFile(fileName string, nameToNum map[string]int) {
r := regexp.MustCompile(`^\s+(\w+)*\s+=\s+(\d+)$`)
for s.Scan() {
m := r.FindStringSubmatch(s.Text())
if m != nil && len(m) == 3 && m[1] != "" && m[2] != "" {
if len(m) == 3 && m[1] != "" && m[2] != "" {
i, err := strconv.Atoi(m[2])
if err != nil {
log.Fatal(err)
Expand Down Expand Up @@ -134,7 +134,7 @@ func main() {
r := regexp.MustCompile(`^MySQL error code MY-0*(\d+) \((\w+)\)`)
for s.Scan() {
m := r.FindStringSubmatch(s.Text())
if m != nil && len(m) == 3 && m[1] != "" && m[2] != "" {
if len(m) == 3 && m[1] != "" && m[2] != "" {
c, err := strconv.Atoi(m[1])
if err != nil {
log.Fatal(err)
Expand All @@ -145,7 +145,10 @@ func main() {
checkNewErr(m[2], i, NameToNum)
}
}
cmd.Wait()
err = cmd.Wait()
if err != nil {
log.Fatal(err)
}
}
if maxError >= 1000 {
fmt.Printf("\r")
Expand All @@ -170,7 +173,7 @@ func main() {
sort.Slice(codes, func(i, j int) bool {
return codes[i].Code < codes[j].Code || codes[i].Code == codes[j].Code && codes[i].Name < codes[j].Name
})
for i, _ := range codes {
for i := range codes {
_, err = w.WriteString("\t\"" + codes[i].Name + `": ` + strconv.Itoa(codes[i].Code) + ",\n")
if err != nil {
log.Fatal(err)
Expand Down
10 changes: 8 additions & 2 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,10 @@ func (t *tester) preProcess() {

func (t *tester) postProcess() {
if !reserveSchema {
t.mdb.Exec(fmt.Sprintf("drop database `%s`", strings.ReplaceAll(t.name, "/", "__")))
_, err := t.mdb.Exec(fmt.Sprintf("drop database `%s`", strings.ReplaceAll(t.name, "/", "__")))
if err != nil {
log.Errorf("failed to drop database: %s", err.Error())
}
}
for _, v := range t.conn {
v.conn.Close()
Expand Down Expand Up @@ -918,13 +921,16 @@ func (t *tester) executeStmt(query string) error {
}

if t.enableInfo {
t.curr.conn.Raw(func(driverConn any) error {
err = t.curr.conn.Raw(func(driverConn any) error {
rowsAffected := driverConn.(*mysql.MysqlConn).RowsAffected()
lastMessage := driverConn.(*mysql.MysqlConn).LastMessage()
t.buf.WriteString(fmt.Sprintf("affected rows: %d\n", rowsAffected))
t.buf.WriteString(fmt.Sprintf("info: %s\n", lastMessage))
return nil
})
if err != nil {
log.Errorf("failed to get info: %s", err.Error())
}
}

if t.enableWarning {
Expand Down

0 comments on commit 03bb96f

Please sign in to comment.