MCPcopy Create free account
hub / github.com/cli/cli / writeFakeGH

Function writeFakeGH

script/ghmock/run_test.go:269–279  ·  view source on GitHub ↗

writeFakeGH writes a wrapper that runs the test binary as gh.

(t *testing.T, variant string)

Source from the content-addressed store, hash-verified

267
268// writeFakeGH writes a wrapper that runs the test binary as gh.
269func 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
281func TestParseRunArgs(t *testing.T) {
282 tests := []struct {

Callers 1

TestRunAllFunction · 0.85

Calls 4

JoinMethod · 0.80
WriteFileMethod · 0.80
HelperMethod · 0.65
ExecutableMethod · 0.65

Tested by

no test coverage detected