Skip to content

Commit 537e386

Browse files
authored
all: support go 1.13 change to testing/flag packages (ethersphere#1710)
1 parent fe24d12 commit 537e386

37 files changed

+225
-285
lines changed

.travis.yml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,25 @@ jobs:
1515
- stage: lint
1616
os: linux
1717
dist: trusty
18-
go: 1.12.x
18+
go: 1.13.x
1919
env:
2020
- lint
2121
script:
2222
- go run build/ci.go lint
2323

24+
# Go 1.12.x is needed because of the Ubuntu PPA builds
25+
- stage: build
26+
os: linux
27+
dist: trusty
28+
sudo: required
29+
go: 1.12.x
30+
script:
31+
- sudo modprobe fuse
32+
- sudo chmod 666 /dev/fuse
33+
- sudo chown root:$USER /etc/fuse.conf
34+
- go run build/ci.go install
35+
- go run build/ci.go test -coverage $TEST_PACKAGES
36+
2437
# Go 1.11.x is needed because of the Ubuntu PPA builds
2538
- stage: build
2639
os: linux
@@ -39,7 +52,7 @@ jobs:
3952
os: linux
4053
dist: trusty
4154
sudo: required
42-
go: 1.12.x
55+
go: 1.13.x
4356
script:
4457
- sudo modprobe fuse
4558
- sudo chmod 666 /dev/fuse
@@ -49,7 +62,7 @@ jobs:
4962

5063
- stage: build
5164
os: osx
52-
go: 1.12.x
65+
go: 1.13.x
5366
script:
5467
- echo "Increase the maximum number of open file descriptors on macOS"
5568
- NOFILE=20480
@@ -68,7 +81,7 @@ jobs:
6881
if: type = push
6982
os: linux
7083
dist: trusty
71-
go: 1.12.x
84+
go: 1.13.x
7285
env:
7386
- ubuntu-ppa
7487
addons:
@@ -90,7 +103,7 @@ jobs:
90103
os: linux
91104
dist: trusty
92105
sudo: required
93-
go: 1.12.x
106+
go: 1.13.x
94107
env:
95108
- azure-linux
96109
addons:
@@ -124,7 +137,7 @@ jobs:
124137
dist: trusty
125138
services:
126139
- docker
127-
go: 1.12.x
140+
go: 1.13.x
128141
env:
129142
- azure-linux-mips
130143
script:
@@ -148,7 +161,7 @@ jobs:
148161
- stage: deploy
149162
if: type = push
150163
os: osx
151-
go: 1.12.x
164+
go: 1.13.x
152165
env:
153166
- azure-osx
154167
script:
@@ -161,7 +174,7 @@ jobs:
161174
if: type = cron
162175
os: linux
163176
dist: trusty
164-
go: 1.12.x
177+
go: 1.13.x
165178
env:
166179
- azure-purge
167180
script:

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.12-alpine as builder
1+
FROM golang:1.13-alpine as builder
22
RUN apk add --no-cache make gcc musl-dev linux-headers git
33
ADD . /swarm
44
WORKDIR /swarm

Dockerfile.alltools

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.12-alpine as builder
1+
FROM golang:1.13-alpine as builder
22
RUN apk add --no-cache make gcc musl-dev linux-headers git
33
ADD . /swarm
44
WORKDIR /swarm

api/api_test.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"context"
2222
crand "crypto/rand"
2323
"errors"
24-
"flag"
2524
"fmt"
2625
"io"
2726
"io/ioutil"
@@ -34,15 +33,14 @@ import (
3433
"github.com/ethereum/go-ethereum/core/types"
3534
"github.com/ethereum/go-ethereum/log"
3635
"github.com/ethersphere/swarm/chunk"
36+
chunktesting "github.com/ethersphere/swarm/chunk/testing"
3737
"github.com/ethersphere/swarm/sctx"
3838
"github.com/ethersphere/swarm/storage"
3939
"github.com/ethersphere/swarm/testutil"
4040
)
4141

4242
func init() {
43-
loglevel := flag.Int("loglevel", 2, "loglevel")
44-
flag.Parse()
45-
log.Root().SetHandler(log.CallerFileHandler(log.LvlFilterHandler(log.Lvl(*loglevel), log.StreamHandler(os.Stderr, log.TerminalFormat(true)))))
43+
testutil.Init()
4644
}
4745

4846
func testAPI(t *testing.T, f func(*API, *chunk.Tags, bool)) {
@@ -143,7 +141,7 @@ func TestApiPut(t *testing.T) {
143141
resp := testGet(t, api, addr.Hex(), "")
144142
checkResponse(t, resp, exp)
145143
tag := tags.All()[0]
146-
testutil.CheckTag(t, tag, 2, 2, 0, 2) //1 chunk data, 1 chunk manifest
144+
chunktesting.CheckTag(t, tag, 2, 2, 0, 2) //1 chunk data, 1 chunk manifest
147145
})
148146
}
149147

@@ -170,11 +168,11 @@ func TestApiTagLarge(t *testing.T) {
170168
if toEncrypt {
171169
tag := tags.All()[0]
172170
expect := int64(4095 + 64 + 1)
173-
testutil.CheckTag(t, tag, expect, expect, 0, expect)
171+
chunktesting.CheckTag(t, tag, expect, expect, 0, expect)
174172
} else {
175173
tag := tags.All()[0]
176174
expect := int64(4095 + 32 + 1)
177-
testutil.CheckTag(t, tag, expect, expect, 0, expect)
175+
chunktesting.CheckTag(t, tag, expect, expect, 0, expect)
178176
}
179177
})
180178
}

api/client/client_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/ethereum/go-ethereum/crypto"
3030
"github.com/ethersphere/swarm/api"
3131
swarmhttp "github.com/ethersphere/swarm/api/http"
32+
chunktesting "github.com/ethersphere/swarm/chunk/testing"
3233
"github.com/ethersphere/swarm/storage"
3334
"github.com/ethersphere/swarm/storage/feed"
3435
"github.com/ethersphere/swarm/storage/feed/lookup"
@@ -50,7 +51,7 @@ func TestClientUploadDownloadRaw(t *testing.T) {
5051

5152
// check the tag was created successfully
5253
tag := srv.Tags.All()[0]
53-
testutil.CheckTag(t, tag, 1, 1, 0, 1)
54+
chunktesting.CheckTag(t, tag, 1, 1, 0, 1)
5455
}
5556

5657
func TestClientUploadDownloadRawEncrypted(t *testing.T) {
@@ -68,7 +69,7 @@ func TestClientUploadDownloadRawEncrypted(t *testing.T) {
6869

6970
// check the tag was created successfully
7071
tag := srv.Tags.All()[0]
71-
testutil.CheckTag(t, tag, 1, 1, 0, 1)
72+
chunktesting.CheckTag(t, tag, 1, 1, 0, 1)
7273
}
7374

7475
func testClientUploadDownloadRaw(srv *swarmhttp.TestSwarmServer, toEncrypt bool, t *testing.T, data []byte, toPin bool) string {
@@ -227,7 +228,7 @@ func TestClientUploadDownloadDirectory(t *testing.T) {
227228

228229
// check the tag was created successfully
229230
tag := srv.Tags.All()[0]
230-
testutil.CheckTag(t, tag, 9, 9, 0, 9)
231+
chunktesting.CheckTag(t, tag, 9, 9, 0, 9)
231232

232233
// check we can download the individual files
233234
checkDownloadFile := func(path string, expected []byte) {
@@ -371,7 +372,7 @@ func TestClientMultipartUpload(t *testing.T) {
371372

372373
// check the tag was created successfully
373374
tag := srv.Tags.All()[0]
374-
testutil.CheckTag(t, tag, 9, 9, 0, 9)
375+
chunktesting.CheckTag(t, tag, 9, 9, 0, 9)
375376

376377
// check we can download the individual files
377378
checkDownloadFile := func(path string) {

api/http/server_test.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"encoding/hex"
2424
"encoding/json"
2525
"errors"
26-
"flag"
2726
"fmt"
2827
"io"
2928
"io/ioutil"
@@ -44,6 +43,7 @@ import (
4443
"github.com/ethereum/go-ethereum/log"
4544
"github.com/ethersphere/swarm/api"
4645
"github.com/ethersphere/swarm/chunk"
46+
chunktesting "github.com/ethersphere/swarm/chunk/testing"
4747
"github.com/ethersphere/swarm/storage"
4848
"github.com/ethersphere/swarm/storage/feed"
4949
"github.com/ethersphere/swarm/storage/feed/lookup"
@@ -52,9 +52,7 @@ import (
5252
)
5353

5454
func init() {
55-
loglevel := flag.Int("loglevel", 2, "loglevel")
56-
flag.Parse()
57-
log.Root().SetHandler(log.CallerFileHandler(log.LvlFilterHandler(log.Lvl(*loglevel), log.StreamHandler(os.Stderr, log.TerminalFormat(true)))))
55+
testutil.Init()
5856
}
5957

6058
func serverFunc(api *api.API, pinAPI *pin.API) TestServer {
@@ -947,7 +945,7 @@ func testBzzTar(encrypted bool, t *testing.T) {
947945

948946
// check that the tag was written correctly
949947
tag := srv.Tags.All()[0]
950-
testutil.CheckTag(t, tag, 4, 4, 0, 4)
948+
chunktesting.CheckTag(t, tag, 4, 4, 0, 4)
951949

952950
swarmHash, err := ioutil.ReadAll(resp2.Body)
953951
resp2.Body.Close()
@@ -1083,7 +1081,7 @@ func TestBzzCorrectTagEstimate(t *testing.T) {
10831081
<-time.After(10 * time.Millisecond)
10841082
case 1:
10851083
tag := srv.Tags.All()[0]
1086-
testutil.CheckTag(t, tag, 0, 0, 0, v.expChunks)
1084+
chunktesting.CheckTag(t, tag, 0, 0, 0, v.expChunks)
10871085
srv.Tags.Delete(tag.Uid)
10881086
done = true
10891087
}

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ environment:
2727
install:
2828
- git submodule update --init
2929
- rmdir C:\go /s /q
30-
- appveyor DownloadFile https://dl.google.com/go/go1.12.windows-%APP_ARCH%.zip
31-
- 7z x go1.12.windows-%APP_ARCH%.zip -y -oC:\ > NUL
30+
- appveyor DownloadFile https://dl.google.com/go/go1.13.windows-%APP_ARCH%.zip
31+
- 7z x go1.13.windows-%APP_ARCH%.zip -y -oC:\ > NUL
3232
- go version
3333
- gcc --version
3434

bzzeth/bzzeth_test.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,17 @@ package bzzeth
1818

1919
import (
2020
"errors"
21-
"flag"
22-
"os"
2321
"testing"
2422
"time"
2523

2624
"github.com/ethereum/go-ethereum/crypto"
27-
"github.com/ethereum/go-ethereum/log"
2825
"github.com/ethereum/go-ethereum/p2p/enode"
2926
p2ptest "github.com/ethersphere/swarm/p2p/testing"
30-
)
31-
32-
var (
33-
loglevel = flag.Int("loglevel", 0, "verbosity of logs")
27+
"github.com/ethersphere/swarm/testutil"
3428
)
3529

3630
func init() {
37-
flag.Parse()
38-
39-
log.PrintOrigins(true)
40-
log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(*loglevel), log.StreamHandler(os.Stderr, log.TerminalFormat(false))))
31+
testutil.Init()
4132
}
4233

4334
func newBzzEthTester() (*p2ptest.ProtocolTester, *BzzEth, func(), error) {

testutil/tag.go renamed to chunk/testing/tag.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
// Copyright 2019 The go-ethereum Authors
2-
// This file is part of the go-ethereum library.
1+
// Copyright 2019 The Swarm Authors
2+
// This file is part of the Swarm library.
33
//
4-
// The go-ethereum library is free software: you can redistribute it and/or modify
4+
// The Swarm library is free software: you can redistribute it and/or modify
55
// it under the terms of the GNU Lesser General Public License as published by
66
// the Free Software Foundation, either version 3 of the License, or
77
// (at your option) any later version.
88
//
9-
// The go-ethereum library is distributed in the hope that it will be useful,
9+
// The Swarm library is distributed in the hope that it will be useful,
1010
// but WITHOUT ANY WARRANTY; without even the implied warranty of
1111
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212
// GNU Lesser General Public License for more details.
1313
//
1414
// You should have received a copy of the GNU Lesser General Public License
15-
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
15+
// along with the Swarm library. If not, see <http://www.gnu.org/licenses/>.
1616

17-
package testutil
17+
package testing
1818

1919
import (
2020
"testing"

cmd/swarm/run_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package main
1919
import (
2020
"context"
2121
"crypto/ecdsa"
22-
"flag"
2322
"fmt"
2423
"io/ioutil"
2524
"net"
@@ -43,10 +42,9 @@ import (
4342
swarmhttp "github.com/ethersphere/swarm/api/http"
4443
"github.com/ethersphere/swarm/internal/cmdtest"
4544
"github.com/ethersphere/swarm/storage/pin"
45+
"github.com/ethersphere/swarm/testutil"
4646
)
4747

48-
var loglevel = flag.Int("loglevel", 3, "verbosity of logs")
49-
5048
func init() {
5149
// Run the app if we've been exec'd as "swarm-test" in runSwarm.
5250
reexec.Register("swarm-test", func() {
@@ -68,6 +66,7 @@ func TestMain(m *testing.M) {
6866
if reexec.Init() {
6967
return
7068
}
69+
testutil.Init()
7170
os.Exit(m.Run())
7271
}
7372

@@ -282,7 +281,7 @@ func existingTestNode(t *testing.T, dir string, bzzaccount string) *testNode {
282281
"--bzzaccount", bzzaccount,
283282
"--bzznetworkid", "321",
284283
"--bzzport", httpPort,
285-
"--verbosity", fmt.Sprint(*loglevel),
284+
"--verbosity", fmt.Sprint(*testutil.Loglevel),
286285
)
287286
node.Cmd.InputLine(testPassphrase)
288287
defer func() {
@@ -360,7 +359,7 @@ func newTestNode(t *testing.T, dir string) *testNode {
360359
"--bzzaccount", account.Address.String(),
361360
"--bzznetworkid", "321",
362361
"--bzzport", httpPort,
363-
"--verbosity", fmt.Sprint(*loglevel),
362+
"--verbosity", fmt.Sprint(*testutil.Loglevel),
364363
)
365364
node.Cmd.InputLine(testPassphrase)
366365
defer func() {

0 commit comments

Comments
 (0)