@@ -921,7 +921,10 @@ func TestResetIgnore(t *testing.T) {
921
921
if err != nil {
922
922
t .Fatalf ("failed to parse signal: %v" , err )
923
923
}
924
- resetIgnoreTestProgram (syscall .Signal (s ))
924
+ if Ignored (syscall .Signal (s )) {
925
+ os .Exit (1 )
926
+ }
927
+ os .Exit (0 )
925
928
}
926
929
927
930
sigs := []syscall.Signal {
@@ -937,7 +940,7 @@ func TestResetIgnore(t *testing.T) {
937
940
for _ , sig := range sigs {
938
941
t .Run (fmt .Sprintf ("%s[notify=%t]" , sig , notify ), func (t * testing.T ) {
939
942
if Ignored (sig ) {
940
- t .Fatalf ("expected %q to not be ignored initially" , sig )
943
+ t .Skipf ("expected %q to not be ignored initially" , sig )
941
944
}
942
945
943
946
Ignore (sig )
@@ -957,23 +960,14 @@ func TestResetIgnore(t *testing.T) {
957
960
cmd := testenv .Command (t , testenv .Executable (t ), "-test.run=^TestResetIgnore$" )
958
961
cmd .Env = append (os .Environ (), "GO_TEST_RESET_IGNORE=" + strconv .Itoa (int (sig )))
959
962
err := cmd .Run ()
960
- if _ , ok := err .(* exec.ExitError ); ok {
961
- t .Fatalf ("expected %q to not be ignored in child process" , sig )
962
- } else if err != nil {
963
- t .Fatalf ("child process failed to launch: %v" , err )
963
+ if err != nil {
964
+ t .Fatalf ("expected %q to not be ignored in child process: %v" , sig , err )
964
965
}
965
966
})
966
967
}
967
968
}
968
969
}
969
970
970
- func resetIgnoreTestProgram (sig os.Signal ) {
971
- if Ignored (sig ) {
972
- os .Exit (1 )
973
- }
974
- os .Exit (0 )
975
- }
976
-
977
971
// #46321 test Reset correctly undoes the effect of Ignore when the child
978
972
// process is started with a signal ignored.
979
973
func TestInitiallyIgnoredResetIgnore (t * testing.T ) {
@@ -1000,10 +994,8 @@ func TestInitiallyIgnoredResetIgnore(t *testing.T) {
1000
994
cmd := testenv .Command (t , testenv .Executable (t ), "-test.run=^TestInitiallyIgnoredResetIgnore$" )
1001
995
cmd .Env = append (os .Environ (), "GO_TEST_INITIALLY_IGNORED_RESET_IGNORE=" + strconv .Itoa (int (sig )))
1002
996
err := cmd .Run ()
1003
- if _ , ok := err .(* exec.ExitError ); ok {
1004
- t .Fatalf ("expected %q to be ignored in child process" , sig )
1005
- } else if err != nil {
1006
- t .Fatalf ("child process failed to launch: %v" , err )
997
+ if err != nil {
998
+ t .Fatalf ("expected %q to be ignored in child process: %v" , sig , err )
1007
999
}
1008
1000
})
1009
1001
}
0 commit comments