]> Cypherpunks repositories - gostls13.git/commitdiff
os/user: don't skip TestLookupGroup if supported
authorKir Kolyshkin <kolyshkin@gmail.com>
Wed, 23 Jun 2021 03:26:31 +0000 (20:26 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 25 Aug 2021 03:07:54 +0000 (03:07 +0000)
CL 37664 implemented this functionality, yet the tests were skipped.

Introduce and use additional variable groupListImplemented to
distinguish between these cases and enable TestLookupGroup for
supported configurations (which looks like all but plan9).

Change-Id: Iabaa7f08b4551dc67e67bdb6e715f15bb20d6218
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/330751
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
src/os/user/lookup_plan9.go
src/os/user/lookup_stubs.go
src/os/user/lookup_unix.go
src/os/user/user.go
src/os/user/user_test.go

index 51caf55935e37eb6880521487f6ddf95695c5db3..07939363e739c69440db6a81da8cf2625b7b3c3a 100644 (file)
@@ -20,6 +20,7 @@ const (
 func init() {
        userImplemented = false
        groupImplemented = false
+       groupListImplemented = false
 }
 
 func current() (*User, error) {
index c975a11964c11c83d7e6b721bc16a62ac00f14bf..d8e3d4866a5eb0b4e1e3a01f8d1afaa19cc81707 100644 (file)
@@ -16,7 +16,7 @@ import (
 )
 
 func init() {
-       groupImplemented = false
+       groupListImplemented = false
 }
 
 func current() (*User, error) {
index 97c611fad42fdf264af9bbef9259d10b5c2662a0..dffea4a885410b93c84b5687daa39bbd44c52ce7 100644 (file)
@@ -18,13 +18,15 @@ import (
        "strings"
 )
 
-const groupFile = "/etc/group"
-const userFile = "/etc/passwd"
+const (
+       groupFile = "/etc/group"
+       userFile  = "/etc/passwd"
+)
 
 var colon = []byte{':'}
 
 func init() {
-       groupImplemented = false
+       groupListImplemented = false
 }
 
 // lineFunc returns a value, an error, or (nil, nil) to skip the row.
index c1b8101c8629cb889efa0ca9208b3fae647cf853..4e1b5b34070da9ae02f8050ddbaa55f7edea6244 100644 (file)
@@ -20,9 +20,12 @@ import (
        "strconv"
 )
 
+// These may be set to false in init() for a particular platform and/or
+// build flags to let the tests know to skip tests of some features.
 var (
-       userImplemented  = true // set to false by lookup_stubs.go's init
-       groupImplemented = true // set to false by lookup_stubs.go's init
+       userImplemented      = true
+       groupImplemented     = true
+       groupListImplemented = true
 )
 
 // User represents a user account.
index 1112c78c004f92816c13645f6637fa9e2e96d1a3..d8a465edac67a246b31a4e09dff06c09209ae2a6 100644 (file)
@@ -119,8 +119,15 @@ func TestLookupGroup(t *testing.T) {
        }
 }
 
+func checkGroupList(t *testing.T) {
+       t.Helper()
+       if !groupListImplemented {
+               t.Skip("user: group list not implemented; skipping test")
+       }
+}
+
 func TestGroupIds(t *testing.T) {
-       checkGroup(t)
+       checkGroupList(t)
        if runtime.GOOS == "aix" {
                t.Skip("skipping GroupIds, see golang.org/issue/30563")
        }