[go] os/exec_test: fix test on Plan 9

2 views
Skip to first unread message

Ori Bernstein (Gerrit)

unread,
Dec 27, 2025, 7:13:41 PM (17 hours ago) Dec 27
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Ori Bernstein has uploaded the change for review

Commit message

os/exec_test: fix test on Plan 9

Plan 9 error strings are different from Windows and Linux ones.
Match them in a way that will work across all of the various
Plan 9 distributions.
Change-Id: I6d220bc2d0289070f3441adb48983c13b2a3e597

Change diff

diff --git a/src/os/exec/exec_test.go b/src/os/exec/exec_test.go
index bf2f3da..149a802 100644
--- a/src/os/exec/exec_test.go
+++ b/src/os/exec/exec_test.go
@@ -1845,23 +1845,16 @@
testenv.MustHaveExec(t)

cmd := exec.Command("/bin/nonesuch")
- for i, want := range []string{
- cond(runtime.GOOS == "windows",
- `exec: "/bin/nonesuch": executable file not found in %PATH%`,
- "fork/exec /bin/nonesuch: no such file or directory"),
- "exec: already started",
- } {
+ msg := "fork/exec /bin/nonesuch: no such file or directory"
+ if runtime.GOOS == "windows" {
+ msg = `exec: "/bin/nonesuch": executable file not found in %PATH%`
+ } else if runtime.GOOS == "plan9" {
+ msg = "directory entry not found"
+ }
+ for i, want := range []string{msg, "exec: already started"} {
err := cmd.Start()
- if got := fmt.Sprint(err); got != want {
+ if got := fmt.Sprint(err); !strings.Contains(got, want) {
t.Errorf("Start call #%d return err %q, want %q", i+1, got, want)
}
}
}
-
-func cond[T any](cond bool, t, f T) T {
- if cond {
- return t
- } else {
- return f
- }
-}

Change information

Files:
  • M src/os/exec/exec_test.go
Change size: S
Delta: 1 file changed, 8 insertions(+), 15 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I6d220bc2d0289070f3441adb48983c13b2a3e597
Gerrit-Change-Number: 732940
Gerrit-PatchSet: 1
Gerrit-Owner: Ori Bernstein <o...@eigenstate.org>
unsatisfied_requirement
satisfied_requirement
open
diffy

Ian Lance Taylor (Gerrit)

unread,
Dec 27, 2025, 11:21:55 PM (12 hours ago) Dec 27
to Ori Bernstein, goph...@pubsubhelper.golang.org, Ian Lance Taylor, Richard Miller, Alan Donovan, golang-co...@googlegroups.com
Attention needed from Ori Bernstein

Ian Lance Taylor added 1 comment

File src/os/exec/exec_test.go
Line 1850, Patchset 1 (Latest): msg = `exec: "/bin/nonesuch": executable file not found in %PATH%`
Ian Lance Taylor . unresolved

I don't see any reason to check for specific error text at all. What matters is the "already started" error. The other error doesn't matter.

Open in Gerrit

Related details

Attention is currently required from:
  • Ori Bernstein
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I6d220bc2d0289070f3441adb48983c13b2a3e597
    Gerrit-Change-Number: 732940
    Gerrit-PatchSet: 1
    Gerrit-Owner: Ori Bernstein <o...@eigenstate.org>
    Gerrit-CC: Alan Donovan <adon...@google.com>
    Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
    Gerrit-CC: Richard Miller <millerr...@gmail.com>
    Gerrit-Attention: Ori Bernstein <o...@eigenstate.org>
    Gerrit-Comment-Date: Sun, 28 Dec 2025 04:21:49 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Richard Miller (Gerrit)

    unread,
    5:51 AM (6 hours ago) 5:51 AM
    to Ori Bernstein, goph...@pubsubhelper.golang.org, Ian Lance Taylor, Alan Donovan, golang-co...@googlegroups.com
    Attention needed from Ori Bernstein

    Richard Miller added 1 comment

    Patchset-level comments
    File-level comment, Patchset 1 (Latest):
    Richard Miller . unresolved

    This change wouldn't fix the failure in AIX reported as issue #76965 where the error message is different. It wouldn't even fix the failures on the plan9-arm builder (see https://luci-milo.appspot.com/ui/p/golang/builders/ci/gotip-plan9-arm/b8694296900071569313/overview) where the error message is "file does not exist" and not "directory entry not found". That builder currently mounts `/tmp` on the `ramfs` file server, which reports some errors with a different syntax.

    As @ia...@golang.org said (and as I had commented on #76965), what matters is just to check that the second iteration reports "already started" and the first iteration doesn't.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Ori Bernstein
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I6d220bc2d0289070f3441adb48983c13b2a3e597
    Gerrit-Change-Number: 732940
    Gerrit-PatchSet: 1
    Gerrit-Owner: Ori Bernstein <o...@eigenstate.org>
    Gerrit-CC: Alan Donovan <adon...@google.com>
    Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
    Gerrit-CC: Richard Miller <millerr...@gmail.com>
    Gerrit-Attention: Ori Bernstein <o...@eigenstate.org>
    Gerrit-Comment-Date: Sun, 28 Dec 2025 10:51:51 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Alan Donovan (Gerrit)

    unread,
    10:08 AM (2 hours ago) 10:08 AM
    to Ori Bernstein, goph...@pubsubhelper.golang.org, Ian Lance Taylor, Richard Miller, golang-co...@googlegroups.com
    Attention needed from Ori Bernstein

    Alan Donovan added 1 comment

    File src/os/exec/exec_test.go
    Line 1850, Patchset 1 (Latest): msg = `exec: "/bin/nonesuch": executable file not found in %PATH%`
    Ian Lance Taylor . unresolved

    I don't see any reason to check for specific error text at all. What matters is the "already started" error. The other error doesn't matter.

    Alan Donovan

    Good point. Let's unroll the loop and discard the result of the first Start call.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Ori Bernstein
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I6d220bc2d0289070f3441adb48983c13b2a3e597
    Gerrit-Change-Number: 732940
    Gerrit-PatchSet: 1
    Gerrit-Owner: Ori Bernstein <o...@eigenstate.org>
    Gerrit-CC: Alan Donovan <adon...@google.com>
    Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
    Gerrit-CC: Richard Miller <millerr...@gmail.com>
    Gerrit-Attention: Ori Bernstein <o...@eigenstate.org>
    Gerrit-Comment-Date: Sun, 28 Dec 2025 15:08:50 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Ian Lance Taylor <ia...@golang.org>
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages