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

Function printResult

script/ghmock/report.go:60–115  ·  view source on GitHub ↗
(w io.Writer, command string, res runResult)

Source from the content-addressed store, hash-verified

58}
59
60func printResult(w io.Writer, command string, res runResult) {
61 if res.config != nil {
62 fmt.Fprintf(w, "Retained configuration: %s\n", res.config.Directory)
63 }
64 if res.git != nil {
65 fmt.Fprintf(w, "Git: %s\nRetained Git state: %s\n", res.git.Version, res.git.Directory)
66 }
67 fmt.Fprintln(w, command)
68 switch {
69 case res.timedOut:
70 fmt.Fprintln(w, "exit code: none, timed out")
71 default:
72 fmt.Fprintf(w, "exit code: %d\n", res.exitCode)
73 }
74 if res.terminal {
75 if res.terminalOutput != "" {
76 printOutput(w, "terminal output", res.terminalOutput)
77 }
78 for i, s := range res.steps {
79 printOutput(w, fmt.Sprintf("screen before --keys %d, %s", i+1, s.Keys), s.Screen)
80 }
81 printOutput(w, "final screen", res.stdout)
82 if res.unusedKeys > 0 {
83 fmt.Fprintf(w, "gh exited before ghmock typed the last %s.\n", plural(res.unusedKeys, "--keys entry"))
84 }
85 } else {
86 printOutput(w, "stdout", res.stdout)
87 printOutput(w, "stderr", res.stderr)
88 }
89
90 fmt.Fprintf(w, "--- requests (%d)\n", len(res.requests))
91 for _, e := range res.requests {
92 fmt.Fprintln(w, formatRequest(e))
93 }
94 if missing := missingNames(res.requests); len(missing) > 0 {
95 fmt.Fprintln(w, "--- no response for")
96 for _, name := range missing {
97 fmt.Fprintln(w, name)
98 }
99 }
100 if blocked := blockedNames(res.requests); len(blocked) > 0 {
101 fmt.Fprintln(w, "--- blocked, because with --localhost ghmock only serves github.localhost")
102 for _, name := range blocked {
103 fmt.Fprintln(w, name)
104 }
105 fmt.Fprintln(w, "If gh picked that host because of --hostname or a URL, leave out --hostname and use github.localhost in URLs.")
106 }
107 if failed := tlsFailures(res.requests); len(failed) > 0 {
108 fmt.Fprintln(w, "--- gh rejected ghmock's certificate")
109 for _, f := range failed {
110 fmt.Fprintln(w, f)
111 }
112 fmt.Fprintln(w, "gh must trust ghmock's certificate authority through SSL_CERT_FILE. Some builds ignore it, such as macOS builds made with older Go. Run those with --localhost.")
113 }
114 printProblems(w, res.requests)
115}
116
117// tlsFailures lists, once each and in order, the hosts whose TLS handshake

Callers 1

printReportFunction · 0.85

Calls 7

printOutputFunction · 0.85
pluralFunction · 0.85
formatRequestFunction · 0.85
missingNamesFunction · 0.85
blockedNamesFunction · 0.85
tlsFailuresFunction · 0.85
printProblemsFunction · 0.85

Tested by

no test coverage detected