From a4ed50ca85e670a5f0ff064e220915f310ddb553 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Mon, 8 Aug 2016 16:29:32 +0000 Subject: [PATCH] build, lib: Correct total test coverage calculation GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3483 --- build.sh | 7 ++++++- lib/connections/empty_test.go | 10 ++++++++++ lib/dialer/empty_test.go | 10 ++++++++++ lib/pmp/empty_test.go | 10 ++++++++++ lib/relay/client/empty_test.go | 10 ++++++++++ lib/relay/protocol/empty_test.go | 10 ++++++++++ lib/stats/empty_test.go | 10 ++++++++++ lib/symlinks/empty_test.go | 10 ++++++++++ lib/tlsutil/empty_test.go | 10 ++++++++++ 9 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 lib/connections/empty_test.go create mode 100644 lib/dialer/empty_test.go create mode 100644 lib/pmp/empty_test.go create mode 100644 lib/relay/client/empty_test.go create mode 100644 lib/relay/protocol/empty_test.go create mode 100644 lib/stats/empty_test.go create mode 100644 lib/symlinks/empty_test.go create mode 100644 lib/tlsutil/empty_test.go diff --git a/build.sh b/build.sh index 4a2d3e82e..822c67096 100755 --- a/build.sh +++ b/build.sh @@ -104,7 +104,7 @@ case "${1:-default}" in # For every package in the repo for dir in $(go list ./lib/... ./cmd/...) ; do # run the tests - GOPATH="$(pwd)/Godeps/_workspace:$GOPATH" go test -race -coverprofile=profile.out $dir + GOPATH="$(pwd)/Godeps/_workspace:$GOPATH" go test -coverprofile=profile.out $dir if [ -f profile.out ] ; then # and if there was test output, append it to coverage.out grep -v "mode: " profile.out >> coverage.out @@ -112,6 +112,11 @@ case "${1:-default}" in fi done + notCovered=$(egrep -c '\s0$' coverage.out) + total=$(wc -l coverage.out | awk '{print $1}') + coverPct=$(awk "BEGIN{print (1 - $notCovered / $total) * 100}") + echo "Total coverage is $coverPct%" + gocov convert coverage.out | gocov-xml > coverage.xml # This is usually run from within Jenkins. If it is, we need to diff --git a/lib/connections/empty_test.go b/lib/connections/empty_test.go new file mode 100644 index 000000000..68e801e30 --- /dev/null +++ b/lib/connections/empty_test.go @@ -0,0 +1,10 @@ +// Copyright (C) 2016 The Syncthing Authors. +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this file, +// You can obtain one at http://mozilla.org/MPL/2.0/. + +// The existence of this file means we get 0% test coverage rather than no +// test coverage at all. Remove when implementing an actual test. + +package connections diff --git a/lib/dialer/empty_test.go b/lib/dialer/empty_test.go new file mode 100644 index 000000000..6214d247b --- /dev/null +++ b/lib/dialer/empty_test.go @@ -0,0 +1,10 @@ +// Copyright (C) 2016 The Syncthing Authors. +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this file, +// You can obtain one at http://mozilla.org/MPL/2.0/. + +// The existence of this file means we get 0% test coverage rather than no +// test coverage at all. Remove when implementing an actual test. + +package dialer diff --git a/lib/pmp/empty_test.go b/lib/pmp/empty_test.go new file mode 100644 index 000000000..fde666169 --- /dev/null +++ b/lib/pmp/empty_test.go @@ -0,0 +1,10 @@ +// Copyright (C) 2016 The Syncthing Authors. +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this file, +// You can obtain one at http://mozilla.org/MPL/2.0/. + +// The existence of this file means we get 0% test coverage rather than no +// test coverage at all. Remove when implementing an actual test. + +package pmp diff --git a/lib/relay/client/empty_test.go b/lib/relay/client/empty_test.go new file mode 100644 index 000000000..8c75de4bb --- /dev/null +++ b/lib/relay/client/empty_test.go @@ -0,0 +1,10 @@ +// Copyright (C) 2016 The Syncthing Authors. +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this file, +// You can obtain one at http://mozilla.org/MPL/2.0/. + +// The existence of this file means we get 0% test coverage rather than no +// test coverage at all. Remove when implementing an actual test. + +package client diff --git a/lib/relay/protocol/empty_test.go b/lib/relay/protocol/empty_test.go new file mode 100644 index 000000000..7634e3f76 --- /dev/null +++ b/lib/relay/protocol/empty_test.go @@ -0,0 +1,10 @@ +// Copyright (C) 2016 The Syncthing Authors. +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this file, +// You can obtain one at http://mozilla.org/MPL/2.0/. + +// The existence of this file means we get 0% test coverage rather than no +// test coverage at all. Remove when implementing an actual test. + +package protocol diff --git a/lib/stats/empty_test.go b/lib/stats/empty_test.go new file mode 100644 index 000000000..b5e494dfd --- /dev/null +++ b/lib/stats/empty_test.go @@ -0,0 +1,10 @@ +// Copyright (C) 2016 The Syncthing Authors. +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this file, +// You can obtain one at http://mozilla.org/MPL/2.0/. + +// The existence of this file means we get 0% test coverage rather than no +// test coverage at all. Remove when implementing an actual test. + +package stats diff --git a/lib/symlinks/empty_test.go b/lib/symlinks/empty_test.go new file mode 100644 index 000000000..1ce3acc8f --- /dev/null +++ b/lib/symlinks/empty_test.go @@ -0,0 +1,10 @@ +// Copyright (C) 2016 The Syncthing Authors. +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this file, +// You can obtain one at http://mozilla.org/MPL/2.0/. + +// The existence of this file means we get 0% test coverage rather than no +// test coverage at all. Remove when implementing an actual test. + +package symlinks diff --git a/lib/tlsutil/empty_test.go b/lib/tlsutil/empty_test.go new file mode 100644 index 000000000..e166f558f --- /dev/null +++ b/lib/tlsutil/empty_test.go @@ -0,0 +1,10 @@ +// Copyright (C) 2016 The Syncthing Authors. +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this file, +// You can obtain one at http://mozilla.org/MPL/2.0/. + +// The existence of this file means we get 0% test coverage rather than no +// test coverage at all. Remove when implementing an actual test. + +package tlsutil