writeFakeGH writes a wrapper that runs the test binary as gh.
(t *testing.T, variant string)
| 267 | |
| 268 | // writeFakeGH writes a wrapper that runs the test binary as gh. |
| 269 | func writeFakeGH(t *testing.T, variant string) string { |
| 270 | t.Helper() |
| 271 | exe, err := os.Executable() |
| 272 | require.NoError(t, err) |
| 273 | path := filepath.Join(t.TempDir(), "gh-"+variant) |
| 274 | // Race-enabled binaries sleep a second before exiting by default, which |
| 275 | // would look like gh waiting for input to a terminal run. |
| 276 | script := fmt.Sprintf("#!/bin/sh\nGHMOCK_FAKE_GH=1 GHMOCK_FAKE_VARIANT=%q GORACE=atexit_sleep_ms=0 exec %q \"$@\"\n", variant, exe) |
| 277 | require.NoError(t, os.WriteFile(path, []byte(script), 0o755)) |
| 278 | return path |
| 279 | } |
| 280 | |
| 281 | func TestParseRunArgs(t *testing.T) { |
| 282 | tests := []struct { |
no test coverage detected