setup CI
This commit is contained in:
parent
598c0f3ff1
commit
ab6ed0df62
8
.github/workflows/check.yaml
vendored
Normal file
8
.github/workflows/check.yaml
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- run: make ci-check
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
|
.bin
|
||||||
.coverprofile
|
.coverprofile
|
||||||
|
13
Makefile
13
Makefile
@ -3,10 +3,10 @@ SOURCES = $(shell find . -name "*.go")
|
|||||||
default: build
|
default: build
|
||||||
|
|
||||||
build:
|
build:
|
||||||
go build ./...
|
@go build ./...
|
||||||
|
|
||||||
check:
|
check:
|
||||||
go test -count 1 ./...
|
@go test -count 1 ./...
|
||||||
|
|
||||||
imports:
|
imports:
|
||||||
@goimports -w $(SOURCES)
|
@goimports -w $(SOURCES)
|
||||||
@ -15,10 +15,13 @@ fmt:
|
|||||||
@gofmt -w -s $(SOURCES)
|
@gofmt -w -s $(SOURCES)
|
||||||
|
|
||||||
.coverprofile: $(SOURCES)
|
.coverprofile: $(SOURCES)
|
||||||
go test -count 1 -coverprofile .coverprofile
|
@go test -count 1 -coverprofile .coverprofile
|
||||||
|
|
||||||
cover: .coverprofile
|
cover: .coverprofile
|
||||||
go tool cover -func .coverprofile
|
@go tool cover -func .coverprofile
|
||||||
|
|
||||||
showcover: .coverprofile
|
showcover: .coverprofile
|
||||||
go tool cover -html .coverprofile
|
@go tool cover -html .coverprofile
|
||||||
|
|
||||||
|
check-fmt:
|
||||||
|
@! ( gofmt -s -l . | grep . )
|
||||||
|
@ -65,6 +65,7 @@ func nodeLen(t int, n node) node {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// measure all parts:
|
||||||
for i := range n.parts {
|
for i := range n.parts {
|
||||||
switch pt := n.parts[i].(type) {
|
switch pt := n.parts[i].(type) {
|
||||||
case node:
|
case node:
|
||||||
@ -76,6 +77,7 @@ func nodeLen(t int, n node) node {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// measure the unwrapped length:
|
||||||
for _, p := range n.parts {
|
for _, p := range n.parts {
|
||||||
switch pt := p.(type) {
|
switch pt := p.(type) {
|
||||||
case node:
|
case node:
|
||||||
@ -94,6 +96,7 @@ func nodeLen(t int, n node) node {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// measure the wrapped and the fully wrapped length:
|
||||||
var w, f int
|
var w, f int
|
||||||
for _, p := range n.parts {
|
for _, p := range n.parts {
|
||||||
switch pt := p.(type) {
|
switch pt := p.(type) {
|
||||||
@ -192,6 +195,7 @@ func wrapNode(t, cf0, c0, c1 int, n node) node {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// otherwise, we need to wrap the node:
|
||||||
n.wrap = true
|
n.wrap = true
|
||||||
|
|
||||||
// We assume here that an str is always contained
|
// We assume here that an str is always contained
|
||||||
@ -203,6 +207,10 @@ func wrapNode(t, cf0, c0, c1 int, n node) node {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// before iterating over the parts, take a copy of
|
||||||
|
// the available column width and modify only the
|
||||||
|
// copy, to support trackback.
|
||||||
|
//
|
||||||
cc0, cc1 := c0, c1
|
cc0, cc1 := c0, c1
|
||||||
lastWrapperIndex := -1
|
lastWrapperIndex := -1
|
||||||
var trackBack bool
|
var trackBack bool
|
||||||
|
@ -1004,9 +1004,9 @@ func TestLongString(t *testing.T) {
|
|||||||
|
|
||||||
func TestCyclicReferences(t *testing.T) {
|
func TestCyclicReferences(t *testing.T) {
|
||||||
t.Run("slice", func(t *testing.T) {
|
t.Run("slice", func(t *testing.T) {
|
||||||
const expect = `r0=[]{r0}`
|
const expect = `r0=[]{"foo", r0}`
|
||||||
l := []interface{}{"foo"}
|
l := []interface{}{"foo", "bar"}
|
||||||
l[0] = l
|
l[1] = l
|
||||||
s := Sprint(l)
|
s := Sprint(l)
|
||||||
if s != expect {
|
if s != expect {
|
||||||
t.Fatalf("expected: %s, got: %s", expect, s)
|
t.Fatalf("expected: %s, got: %s", expect, s)
|
||||||
|
Loading…
Reference in New Issue
Block a user