Drop go 1.17 support

This commit is contained in:
yuin 2022-08-06 19:59:30 +09:00
parent d77f38c53d
commit 175c5ecd0c
5 changed files with 39 additions and 80 deletions

View file

@ -5,7 +5,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
go-version: [1.17.x, 1.18.x] go-version: [1.18.x, 1.19.x]
platform: [ubuntu-latest, macos-latest, windows-latest] platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }} runs-on: ${{ matrix.platform }}
steps: steps:

View file

@ -7,10 +7,4 @@ cov: test
go tool cover -html=profile.out go tool cover -html=profile.out
fuzz: fuzz:
which go-fuzz > /dev/null 2>&1 || (GO111MODULE=off go get -u github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build; GO111MODULE=off go get -d github.com/dvyukov/go-fuzz-corpus; true) cd ./fuzz && go test -fuzz=Fuzz
rm -rf ./fuzz/corpus
rm -rf ./fuzz/crashers
rm -rf ./fuzz/suppressions
rm -f ./fuzz/fuzz-fuzz.zip
cd ./fuzz && GO111MODULE=off go-fuzz-build
cd ./fuzz && go-fuzz

View file

@ -46,7 +46,7 @@ Features
renderers. renderers.
- **Performance.** goldmark's performance is on par with that of cmark, - **Performance.** goldmark's performance is on par with that of cmark,
the CommonMark reference implementation written in C. the CommonMark reference implementation written in C.
- **Robust.** goldmark is tested with [go-fuzz](https://github.com/dvyukov/go-fuzz), a fuzz testing tool. - **Robust.** goldmark is tested with `go test --fuzz`.
- **Built-in extensions.** goldmark ships with common extensions like tables, strikethrough, - **Built-in extensions.** goldmark ships with common extensions like tables, strikethrough,
task lists, and definition lists. task lists, and definition lists.
- **Depends only on standard libraries.** - **Depends only on standard libraries.**

View file

@ -1,39 +0,0 @@
package fuzz
import (
"bytes"
"github.com/yuin/goldmark"
"github.com/yuin/goldmark/extension"
"github.com/yuin/goldmark/parser"
"github.com/yuin/goldmark/renderer/html"
)
// Fuzz runs automated fuzzing against goldmark.
func Fuzz(data []byte) int {
markdown := goldmark.New(
goldmark.WithParserOptions(
parser.WithAutoHeadingID(),
parser.WithAttribute(),
),
goldmark.WithRendererOptions(
html.WithUnsafe(),
html.WithXHTML(),
),
goldmark.WithExtensions(
extension.DefinitionList,
extension.Footnote,
extension.GFM,
extension.Linkify,
extension.Table,
extension.TaskList,
extension.Typographer,
),
)
var b bytes.Buffer
if err := markdown.Convert(data, &b); err != nil {
return 0
}
return 1
}

View file

@ -2,7 +2,7 @@ package fuzz
import ( import (
"bytes" "bytes"
"fmt" "encoding/json"
"io/ioutil" "io/ioutil"
"testing" "testing"
@ -13,16 +13,20 @@ import (
"github.com/yuin/goldmark/util" "github.com/yuin/goldmark/util"
) )
var _ = fmt.Printf func Fuzz(f *testing.F) {
bs, err := ioutil.ReadFile("../_test/spec.json")
func TestFuzz(t *testing.T) {
crasher := "6dff3d03167cb144d4e2891edac76ee740a77bc7"
data, err := ioutil.ReadFile("crashers/" + crasher)
if err != nil { if err != nil {
return panic(err)
} }
fmt.Printf("%s\n", util.VisualizeSpaces(data)) var testCases []map[string]interface{}
fmt.Println("||||||||||||||||||||||") if err := json.Unmarshal(bs, &testCases); err != nil {
panic(err)
}
for _, c := range testCases {
f.Add(c["markdown"])
}
f.Fuzz(func(t *testing.T, orig string) {
markdown := goldmark.New( markdown := goldmark.New(
goldmark.WithParserOptions( goldmark.WithParserOptions(
parser.WithAutoHeadingID(), parser.WithAutoHeadingID(),
@ -43,8 +47,8 @@ func TestFuzz(t *testing.T) {
), ),
) )
var b bytes.Buffer var b bytes.Buffer
if err := markdown.Convert(data, &b); err != nil { if err := markdown.Convert(util.StringToReadOnlyBytes(orig), &b); err != nil {
panic(err) panic(err)
} }
fmt.Println(b.String()) })
} }