@@ -223,11 +223,24 @@ func TestGoexitDo(t *testing.T) {
223
223
}
224
224
}
225
225
226
- func TestPanicDoChan (t * testing.T ) {
227
- if runtime .GOOS == "js" {
228
- t .Skipf ("js does not support exec" )
226
+ func executable (t testing.TB ) string {
227
+ exe , err := os .Executable ()
228
+ if err != nil {
229
+ t .Skipf ("skipping: test executable not found" )
229
230
}
230
231
232
+ // Control case: check whether exec.Command works at all.
233
+ // (For example, it might fail with a permission error on iOS.)
234
+ cmd := exec .Command (exe , "-test.list=^$" )
235
+ cmd .Env = []string {}
236
+ if err := cmd .Run (); err != nil {
237
+ t .Skipf ("skipping: exec appears not to work on %s: %v" , runtime .GOOS , err )
238
+ }
239
+
240
+ return exe
241
+ }
242
+
243
+ func TestPanicDoChan (t * testing.T ) {
231
244
if os .Getenv ("TEST_PANIC_DOCHAN" ) != "" {
232
245
defer func () {
233
246
recover ()
@@ -243,7 +256,7 @@ func TestPanicDoChan(t *testing.T) {
243
256
244
257
t .Parallel ()
245
258
246
- cmd := exec .Command (os . Args [ 0 ] , "-test.run=" + t .Name (), "-test.v" )
259
+ cmd := exec .Command (executable ( t ) , "-test.run=" + t .Name (), "-test.v" )
247
260
cmd .Env = append (os .Environ (), "TEST_PANIC_DOCHAN=1" )
248
261
out := new (bytes.Buffer )
249
262
cmd .Stdout = out
@@ -266,10 +279,6 @@ func TestPanicDoChan(t *testing.T) {
266
279
}
267
280
268
281
func TestPanicDoSharedByDoChan (t * testing.T ) {
269
- if runtime .GOOS == "js" {
270
- t .Skipf ("js does not support exec" )
271
- }
272
-
273
282
if os .Getenv ("TEST_PANIC_DOCHAN" ) != "" {
274
283
blocked := make (chan struct {})
275
284
unblock := make (chan struct {})
@@ -297,7 +306,7 @@ func TestPanicDoSharedByDoChan(t *testing.T) {
297
306
298
307
t .Parallel ()
299
308
300
- cmd := exec .Command (os . Args [ 0 ] , "-test.run=" + t .Name (), "-test.v" )
309
+ cmd := exec .Command (executable ( t ) , "-test.run=" + t .Name (), "-test.v" )
301
310
cmd .Env = append (os .Environ (), "TEST_PANIC_DOCHAN=1" )
302
311
out := new (bytes.Buffer )
303
312
cmd .Stdout = out
0 commit comments