From 37ce0bab8c7afe5133b33bb44cff06fe965cf109 Mon Sep 17 00:00:00 2001 From: Daniel Swarbrick Date: Tue, 15 Aug 2023 11:38:13 +0200 Subject: [PATCH] Sync build tags in *_test.go (#2767) Ensure that unwanted tests are correctly excluded when various build tags are specified, i.e. when the code that they test would be excluded from compilation. Signed-off-by: Daniel Swarbrick --- collector/bonding_linux_test.go | 3 +++ collector/diskstats_linux_test.go | 3 +++ collector/ethtool_linux_test.go | 3 +++ collector/filefd_linux_test.go | 3 +++ collector/filesystem_linux_test.go | 5 ++++- collector/interrupts_linux_test.go | 3 +++ collector/ipvs_linux_test.go | 3 +++ collector/loadavg_linux_test.go | 3 +++ collector/logind_linux_test.go | 3 +++ collector/meminfo_linux_test.go | 3 +++ collector/meminfo_numa_linux_test.go | 3 +++ collector/netdev_linux_test.go | 3 +++ collector/netstat_linux_test.go | 3 +++ collector/perf_linux_test.go | 5 ++--- collector/systemd_linux_test.go | 3 +++ collector/tcpstat_linux_test.go | 3 +++ collector/textfile_test.go | 3 +++ 17 files changed, 51 insertions(+), 4 deletions(-) diff --git a/collector/bonding_linux_test.go b/collector/bonding_linux_test.go index 564cf01e25..98af73fad8 100644 --- a/collector/bonding_linux_test.go +++ b/collector/bonding_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nobonding +// +build !nobonding + package collector import ( diff --git a/collector/diskstats_linux_test.go b/collector/diskstats_linux_test.go index 526b25d69e..f0d7499be0 100644 --- a/collector/diskstats_linux_test.go +++ b/collector/diskstats_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nodiskstats +// +build !nodiskstats + package collector import ( diff --git a/collector/ethtool_linux_test.go b/collector/ethtool_linux_test.go index 761351c6e9..cf55c6b1f5 100644 --- a/collector/ethtool_linux_test.go +++ b/collector/ethtool_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !noethtool +// +build !noethtool + package collector import ( diff --git a/collector/filefd_linux_test.go b/collector/filefd_linux_test.go index 37e16a4e09..f31a5c2c5e 100644 --- a/collector/filefd_linux_test.go +++ b/collector/filefd_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nofilefd +// +build !nofilefd + package collector import "testing" diff --git a/collector/filesystem_linux_test.go b/collector/filesystem_linux_test.go index 4705630d8a..325ffc87b2 100644 --- a/collector/filesystem_linux_test.go +++ b/collector/filesystem_linux_test.go @@ -11,14 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nofilesystem +// +build !nofilesystem + package collector import ( - "github.com/go-kit/log" "strings" "testing" "github.com/alecthomas/kingpin/v2" + "github.com/go-kit/log" ) func Test_parseFilesystemLabelsError(t *testing.T) { diff --git a/collector/interrupts_linux_test.go b/collector/interrupts_linux_test.go index 018983689f..82e536e4e9 100644 --- a/collector/interrupts_linux_test.go +++ b/collector/interrupts_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nointerrupts +// +build !nointerrupts + package collector import ( diff --git a/collector/ipvs_linux_test.go b/collector/ipvs_linux_test.go index 8c43ad8b8c..6ee41b299b 100644 --- a/collector/ipvs_linux_test.go +++ b/collector/ipvs_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !noipvs +// +build !noipvs + package collector import ( diff --git a/collector/loadavg_linux_test.go b/collector/loadavg_linux_test.go index e8e5a0ce3f..2d56317dc5 100644 --- a/collector/loadavg_linux_test.go +++ b/collector/loadavg_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !noloadavg +// +build !noloadavg + package collector import "testing" diff --git a/collector/logind_linux_test.go b/collector/logind_linux_test.go index e8d9cb02f1..5cfedff4db 100644 --- a/collector/logind_linux_test.go +++ b/collector/logind_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nologind +// +build !nologind + package collector import ( diff --git a/collector/meminfo_linux_test.go b/collector/meminfo_linux_test.go index dc0aff58d7..a000bea53c 100644 --- a/collector/meminfo_linux_test.go +++ b/collector/meminfo_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nomeminfo +// +build !nomeminfo + package collector import ( diff --git a/collector/meminfo_numa_linux_test.go b/collector/meminfo_numa_linux_test.go index a17714e8df..33bc362e39 100644 --- a/collector/meminfo_numa_linux_test.go +++ b/collector/meminfo_numa_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nomeminfo_numa +// +build !nomeminfo_numa + package collector import ( diff --git a/collector/netdev_linux_test.go b/collector/netdev_linux_test.go index ff5e1c22bf..7909d01821 100644 --- a/collector/netdev_linux_test.go +++ b/collector/netdev_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nonetdev +// +build !nonetdev + package collector import ( diff --git a/collector/netstat_linux_test.go b/collector/netstat_linux_test.go index a27382b416..ec430bc3e3 100644 --- a/collector/netstat_linux_test.go +++ b/collector/netstat_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nonetstat +// +build !nonetstat + package collector import ( diff --git a/collector/perf_linux_test.go b/collector/perf_linux_test.go index c4990d7711..fc557ffd32 100644 --- a/collector/perf_linux_test.go +++ b/collector/perf_linux_test.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build !noprocesses -// +build !noprocesses +//go:build !noperf +// +build !noperf package collector @@ -24,7 +24,6 @@ import ( "testing" "github.com/go-kit/log" - "github.com/prometheus/client_golang/prometheus" ) diff --git a/collector/systemd_linux_test.go b/collector/systemd_linux_test.go index 86573d2ac6..d4e300d1d2 100644 --- a/collector/systemd_linux_test.go +++ b/collector/systemd_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nosystemd +// +build !nosystemd + package collector import ( diff --git a/collector/tcpstat_linux_test.go b/collector/tcpstat_linux_test.go index 693f04fec5..e1bd090a79 100644 --- a/collector/tcpstat_linux_test.go +++ b/collector/tcpstat_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !notcpstat +// +build !notcpstat + package collector import ( diff --git a/collector/textfile_test.go b/collector/textfile_test.go index d759dfaf95..95e5966f3e 100644 --- a/collector/textfile_test.go +++ b/collector/textfile_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !notextfile +// +build !notextfile + package collector import (