Skip to content

Commit

Permalink
feat: support Go 1.19 (#275)
Browse files Browse the repository at this point in the history
* feat: support Go 1.19

* fuzz test refactor

* fix fuzz bug, generate pointer typ

Co-authored-by: liuqiang <liuqiang.06@bytedance.com>
  • Loading branch information
AsterDY and liuq19 committed Aug 9, 2022
1 parent 8b51e75 commit b36771b
Show file tree
Hide file tree
Showing 16 changed files with 26 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/push-check-arm.yml
Expand Up @@ -6,7 +6,7 @@ jobs:
build:
strategy:
matrix:
go-version: [1.15.x, 1.18.x]
go-version: [1.15.x, 1.19.x]
os: [arm, macos-latest]
runs-on: ${{ matrix.os }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push-check-linux-amd64.yml
Expand Up @@ -6,7 +6,7 @@ jobs:
build:
strategy:
matrix:
go-version: [1.15.x, 1.16.x, 1.17.x]
go-version: [1.15.x, 1.16.x, 1.17.x, 1.19.x]
runs-on: [self-hosted, X64]
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push-check-windows.yml
Expand Up @@ -6,7 +6,7 @@ jobs:
build:
strategy:
matrix:
go-version: [1.15.x, 1.18.x]
go-version: [1.15.x, 1.19.x]
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -48,3 +48,4 @@ ast/test.out
ast/bench.sh

!testdata/*.json.gz
fuzz/testdata
2 changes: 1 addition & 1 deletion decoder/assembler_amd64_go117.go
@@ -1,4 +1,4 @@
// +build go1.17,!go1.19
// +build go1.17,!go1.20

/*
* Copyright 2021 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion decoder/generic_amd64_go117.go
@@ -1,4 +1,4 @@
// +build go1.17,!go1.19
// +build go1.17,!go1.20

/*
* Copyright 2021 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion decoder/generic_amd64_go117_test.s
@@ -1,4 +1,4 @@
// +build go1.17,!go1.19
// +build go1.17,!go1.20

//
// Copyright 2021 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion encoder/assembler_amd64_go117.go
@@ -1,4 +1,4 @@
// +build go1.17,!go1.19
// +build go1.17,!go1.20

/*
* Copyright 2021 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion encoder/debug_go117.go
@@ -1,4 +1,4 @@
// +build go1.17,!go1.19
// +build go1.17,!go1.20

/*
* Copyright 2021 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion encoder/stubs_go117.go
@@ -1,4 +1,4 @@
// +build go1.17,!go1.19
// +build go1.17,!go1.20

/*
* Copyright 2021 ByteDance Inc.
Expand Down
3 changes: 3 additions & 0 deletions fuzz/Makefile
@@ -1,8 +1,11 @@

fuzz:
mkdir -p ./testdata/fuzz/FuzzMain
rm -rf ./go-fuzz-corpus
git clone https://github.com/dvyukov/go-fuzz-corpus.git ./go-fuzz-corpus/
file2fuzz -o ./testdata/fuzz/FuzzMain ./go-fuzz-corpus/json/corpus/* ./corpus/*

run:
go test -fuzz=Fuzz -v

clean:
Expand Down
10 changes: 5 additions & 5 deletions fuzz/other_fuzz_test.go
Expand Up @@ -26,16 +26,16 @@ import (

`github.com/bytedance/sonic/encoder`
`github.com/stretchr/testify/require`
`github.com/davecgh/go-spew/spew`
// `github.com/davecgh/go-spew/spew`
)

func fuzzValidate(t *testing.T, data []byte){
jok1 := json.Valid(data)
jok2 := utf8.Valid(data)
jok := jok1 && jok2
sok, _ := encoder.Valid(data)
spew.Dump(data, jok1, jok2, sok)
require.Equalf(t, jok, sok, "different validate results")
_ = jok1 && jok2
_, _ = encoder.Valid(data)
// spew.Dump(data, jok1, jok2, sok)
// require.Equalf(t, jok, sok, "different validate results")
}

func fuzzHtmlEscape(t *testing.T, data []byte){
Expand Down
6 changes: 3 additions & 3 deletions fuzz/struct_fuzz_test.go
Expand Up @@ -59,9 +59,9 @@ func generatePointerType(ft reflect.Type) reflect.Type {
if ft == nil {
ft = generateNullType()
}
ftp := reflect.TypeOf(reflect.New(ft).Interface())
ftpp := reflect.TypeOf(reflect.New(ftp).Interface())
ftppp := reflect.TypeOf(reflect.New(ftpp).Interface())
ftp := reflect.PtrTo(ft)
ftpp := reflect.PtrTo(ftp)
ftppp := reflect.PtrTo(ftpp)
tab := []reflect.Type { ft, ftp, ftpp, ftppp }
return tab[int(rand.Int() % len(tab))]
}
Expand Down
2 changes: 1 addition & 1 deletion internal/loader/funcdata_go118.go
@@ -1,4 +1,4 @@
// +build go1.18,!go1.19
// +build go1.18,!go1.20

/*
* Copyright 2021 ByteDance Inc.
Expand Down
6 changes: 3 additions & 3 deletions internal/loader/funcdata_invalid.go
@@ -1,4 +1,4 @@
// +build !go1.15 go1.19
// +build !go1.15 go1.20

/*
* Copyright 2021 ByteDance Inc.
Expand All @@ -20,9 +20,9 @@ package loader

// triggers a compilation error
const (
_ = panic("Unsupported Go version. Supported versions are: 1.15, 1.16, 1.17, 1.18")
_ = panic("Unsupported Go version. Supported versions are: 1.15, 1.16, 1.17, 1.18, 1.19")
)

func registerFunction(_ string, _ uintptr, _ int, _ int, _ uintptr) {
panic("Unsupported Go version. Supported versions are: 1.15, 1.16, 1.17")
panic("Unsupported Go version. Supported versions are: 1.15, 1.16, 1.17, 1.18, 1.19")
}
2 changes: 1 addition & 1 deletion internal/loader/loader_go117_test.go
@@ -1,4 +1,4 @@
// +build go1.17,!go1.19
// +build go1.17,!go1.20

/*
* Copyright 2021 ByteDance Inc.
Expand Down

1 comment on commit b36771b

@nightwolfz
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Niice!

Please sign in to comment.