Unverified Commit e4964a7e authored by Jonathan Davies's avatar Jonathan Davies
Browse files

prometheus: Include TestFsType patch

The upstream test TestFsType used a regexp to match filesystem magic
constant names (e.g. EXT4_SUPER_MAGIC) against the string returned by
FsType(). This fails in Nix sandbox builds where the filesystem type
does not match that naming pattern.

The patch (prometheus/prometheus#18519) relaxes the assertion to simply
require a non-zero value for a valid path.
parent 3304685a
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -92,6 +92,10 @@ buildGoModule (finalAttrs: {

  proxyVendor = true;

  patches = [
    ./prometheus-pr18519-fix-TestFsType.patch
  ];

  outputs = [
    "out"
    "doc"
+25 −0
Original line number Diff line number Diff line
--- a/util/runtime/statfs_unix_test.go
+++ b/util/runtime/statfs_unix_test.go
@@ -19,20 +19,18 @@ import (
 	"os"
 	"testing"

-	"github.com/grafana/regexp"
 	"github.com/stretchr/testify/require"
 )

-var regexpFsType = regexp.MustCompile("^[A-Z][A-Z0-9_]*_MAGIC$")
-
 func TestFsType(t *testing.T) {
 	var fsType string

 	path, err := os.Getwd()
 	require.NoError(t, err)

+	// A real path must yield a non-zero filesystem type.
 	fsType = FsType(path)
-	require.Regexp(t, regexpFsType, fsType)
+	require.NotEqual(t, "0", fsType)

 	fsType = FsType("/no/where/to/be/found")
 	require.Equal(t, "0", fsType)