cmd/internal/script: make TestInterruptCmd pass on plan9
This CL should have been part of CL 796480, but was mistakenly omitted.
Updates #77485.
diff --git a/src/cmd/internal/script/engine_test.go b/src/cmd/internal/script/engine_test.go
index 19d1836..479fa71 100644
--- a/src/cmd/internal/script/engine_test.go
+++ b/src/cmd/internal/script/engine_test.go
@@ -13,6 +13,7 @@
"os/exec"
"runtime"
"slices"
+ "strings"
"testing"
"time"
)
@@ -59,13 +60,7 @@
if err == nil {
t.Fatal("expected Wait failure")
} else if err, ok := err.(*exec.ExitError); ok {
- expectedError := "signal: interrupt"
- if runtime.GOOS == "windows" {
- expectedError = "exit status 1"
- }
- if err.Error() != expectedError {
- t.Fatalf("unexpected error while exiting executable: got=%q, want=%q", err.Error(), expectedError)
- }
+ checkInterruptCmdError(t, err)
} else {
t.Fatalf("unexpected error while running executable: %s\n%s", err, string(buf))
}
@@ -76,6 +71,30 @@
}
}
+// checkInterruptCmdError calls t.Fatal if err is interrupt cmd error.
+func checkInterruptCmdError(t *testing.T, err error) {
+ errstr := err.Error()
+ if runtime.GOOS == "plan9" {
+ expectedPrefixError := "exit status: "
+ if !strings.HasPrefix(errstr, expectedPrefixError) {
+ t.Fatalf("unexpected error prefix while exiting executable: got=%q, want=%q", errstr, expectedPrefixError)
+ }
+ expectedSuffixError := ": interrupt"
+ if !strings.HasSuffix(errstr, expectedSuffixError) {
+ t.Fatalf("unexpected error suffix while exiting executable: got=%q, want=%q", errstr, expectedSuffixError)
+ }
+ return
+ }
+
+ expectedError := "signal: interrupt"
+ if runtime.GOOS == "windows" {
+ expectedError = "exit status 1"
+ }
+ if errstr != expectedError {
+ t.Fatalf("unexpected error while exiting executable: got=%q, want=%q", errstr, expectedError)
+ }
+}
+
func FuzzQuoteArgs(f *testing.F) {
state, err := NewState(context.Background(), f.TempDir(), nil /* env */)
if err != nil {
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
cmd/internal/script: make TestInterruptCmd pass on plan9
This CL should have been part of CL 796480, but was mistakenly omitted.
Updates #77485.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
I did not notice plan9-arm failure before I submitted this CL. But looks unrelated
```
=== RUN TestArtifactDirectoryPaths
=== PAUSE TestArtifactDirectoryPaths
=== CONT TestArtifactDirectoryPaths
testing_test.go:1184: /home/swarming/swarming2/.swarming/w/ir/x/w/goroot/bin/go test -v -artifacts ./... failed: exit status: 'go 14681: 1'
testing: mkdir /tmp/TestArtifactDirectoryPaths3835853499/001/_artifacts: '/tmp/TestArtifactDirectoryPaths3835853499/001/_artifacts' permission denied
FAIL example.com/testmod 0.127s
=== RUN TestNiceName
=== ARTIFACTS TestNiceName /tmp/TestArtifactDirectoryPaths3835853499/001/_artifacts/deep/nested/pkg/TestNiceName/3631629024
--- PASS: TestNiceName (0.02s)
=== RUN TestParent
=== RUN TestParent/SubTest
=== ARTIFACTS TestParent/SubTest /tmp/TestArtifactDirectoryPaths3835853499/001/_artifacts/deep/nested/pkg/TestParent__SubTest/2390281044
--- PASS: TestParent (0.00s)
--- PASS: TestParent/SubTest (0.00s)
=== RUN TestVeryLongNameThatExceedsSixtyFourCharactersAndThereforeMustBeTruncatedAndHashed
=== ARTIFACTS TestVeryLongNameThatExceedsSixtyFourCharactersAndThereforeMustBeTruncatedAndHashed /tmp/TestArtifactDirectoryPaths3835853499/001/_artifacts/deep/nested/pkg/TestVeryLongNameThatExceedsSixtyFourCharactersAn7b94cc4fce19e465/1787645676
--- PASS: TestVeryLongNameThatExceedsSixtyFourCharactersAndThereforeMustBeTruncatedAndHashed (0.00s)
=== RUN TestInvalid_Chars_In_Name
=== ARTIFACTS TestInvalid_Chars_In_Name /tmp/TestArtifactDirectoryPaths3835853499/001/_artifacts/deep/nested/pkg/TestInvalid_Chars_In_Name/1388556014
--- PASS: TestInvalid_Chars_In_Name (0.01s)
PASS
ok example.com/testmod/deep/nested/pkg 0.169s
=== RUN TestInvalid_Chars_In_Name
=== RUN TestInvalid_Chars_In_Name/SubTest:with*stars
=== ARTIFACTS TestInvalid_Chars_In_Name/SubTest:with*stars /tmp/TestArtifactDirectoryPaths3835853499/001/_artifacts/deep/nested/pkg2/TestInvalid_Chars_In_Name__SubTestwithstars/2508828432
--- PASS: TestInvalid_Chars_In_Name (0.02s)
--- PASS: TestInvalid_Chars_In_Name/SubTest:with*stars (0.02s)
PASS
ok example.com/testmod/deep/nested/pkg2 0.185s
=== RUN TestSubNiceName
=== ARTIFACTS TestSubNiceName /tmp/TestArtifactDirectoryPaths3835853499/001/_artifacts/subpkg/TestSubNiceName/317987286
--- PASS: TestSubNiceName (0.00s)
PASS
ok example.com/testmod/subpkg 0.070s
FAIL
--- FAIL: TestArtifactDirectoryPaths (31.23s)
```
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |