From 429d5de0a99643d237b7313f0fdb7348a77527a6 Mon Sep 17 00:00:00 2001 From: Matheus Degiovani Date: Wed, 16 Nov 2022 15:56:58 -0300 Subject: [PATCH] Add initial root module --- LICENSE | 17 +++++++++++++++++ README.md | 7 +++++++ dummy.go | 5 +++++ go.mod | 13 +++++++++++++ go.sum | 2 ++ run_tests.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 96 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 dummy.go create mode 100644 go.mod create mode 100644 go.sum create mode 100755 run_tests.sh diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d2d1dd9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,17 @@ +ISC License + +Copyright (c) 2013-2017 The btcsuite developers +Copyright (c) 2015-2020 The Decred developers +Copyright (c) 2017 The Lightning Network Developers + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..ec22da0 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# Decred Binary Test Modules + +This repository contains Go modules to write automated test scenarios involving +binaries for the [Decred](https://github.com/decred) project. + +This is a work in progress repository. + diff --git a/dummy.go b/dummy.go new file mode 100644 index 0000000..a1f340c --- /dev/null +++ b/dummy.go @@ -0,0 +1,5 @@ +package dcrtest + +import ( + _ "github.com/decred/dcrtest/dcrdtest" +) diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..ce48dcb --- /dev/null +++ b/go.mod @@ -0,0 +1,13 @@ +module github.com/decred/dcrtest + +go 1.18 + +require github.com/decred/dcrtest/dcrdtest v0.0.0-20221116180444-ea39cd8240db + +replace github.com/decred/dcrdtest => ./dcrdtest + +replace ( + github.com/decred/dcrd/blockchain/stake/v5 => github.com/decred/dcrd/blockchain/stake/v5 v5.0.0-20221022042529-0a0cc3b3bf92 + github.com/decred/dcrd/gcs/v4 => github.com/decred/dcrd/gcs/v4 v4.0.0-20221022042529-0a0cc3b3bf92 + github.com/decred/dcrd/rpc/jsonrpc/types/v4 => github.com/decred/dcrd/rpc/jsonrpc/types/v4 v4.0.0-20221022042529-0a0cc3b3bf92 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..ad17dd7 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/decred/dcrtest/dcrdtest v0.0.0-20221116180444-ea39cd8240db h1:cZvJgqcqYsaJSqlNqUOyzJ1wyNddeimkyIbStXUKQ4c= +github.com/decred/dcrtest/dcrdtest v0.0.0-20221116180444-ea39cd8240db/go.mod h1:PWuyQ4fjFmo23Eo37wZD5K1Ot6Dx+zacsp3K04tSa2Y= diff --git a/run_tests.sh b/run_tests.sh new file mode 100755 index 0000000..116bbf3 --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,52 @@ +#!/bin/sh + +set -e +#set -x + +# The script does automatic checking on a Go package and its sub-packages, +# including: +# 1. gofmt (https://golang.org/cmd/gofmt/) +# 2. gosimple (https://github.com/dominikh/go-simple) +# 3. unconvert (https://github.com/mdempsky/unconvert) +# 4. ineffassign (https://github.com/gordonklaus/ineffassign) +# 5. go vet (https://golang.org/cmd/vet) +# 6. misspell (https://github.com/client9/misspell) +# 7. unused (http://honnef.co/go/tools/unused) + +# golangci-lint (github.com/golangci/golangci-lint) is used to run each +# static checker. + +go version + +# run tests on all modules +ROOTPATH=$(go list -m) +ROOTPATHPATTERN=$(echo $ROOTPATH | sed 's/\\/\\\\/g' | sed 's/\//\\\//g') +MODPATHS=$(go list -m all | grep "^$ROOTPATHPATTERN" | sort | uniq | cut -d' ' -f1) +for module in $MODPATHS; do + # check linters + MODNAME=$(echo $module | sed -E -e "s/^$ROOTPATHPATTERN//" \ + -e 's,^/,,' -e 's,/v[0-9]+$,,') + if [ -z "$MODNAME" ]; then + MODNAME=. + fi + + # run commands in the module directory as a subshell + ( + cd $MODNAME + + go test ./... + + # run linters + golangci-lint run --build-tags=rpctest --disable-all --deadline=10m \ + --enable=gofmt \ + --enable=gosimple \ + --enable=unconvert \ + --enable=ineffassign \ + --enable=govet \ + --enable=misspell \ + --enable=unused \ + ) +done + +echo "------------------------------------------" +echo "Tests completed successfully!"