MCPcopy Index your code
hub / github.com/foxcpp/maddy / buildCmd

Method buildCmd

tests/t.go:210–251  ·  view source on GitHub ↗
(additionalArgs ...string)

Source from the content-addressed store, hash-verified

208}
209
210func (t *T) buildCmd(additionalArgs ...string) *exec.Cmd {
211 // Assigning 0 by default will make outbound SMTP unusable.
212 remoteSmtp := "0"
213 if port := t.ports["remote_smtp"]; port != 0 {
214 remoteSmtp = strconv.Itoa(int(port))
215 }
216
217 args := []string{"-config", filepath.Join(t.testDir, "maddy.conf"),
218 "-debug.smtpport", remoteSmtp,
219 "-debug.dnsoverride", t.dnsServ.LocalAddr().String(),
220 }
221
222 if CoverageOut != "" {
223 args = append(args, "-test.coverprofile", CoverageOut+"."+strconv.FormatInt(time.Now().UnixNano(), 16))
224 }
225 if DebugLog {
226 args = append(args, "-debug")
227 }
228
229 args = append(args, additionalArgs...)
230
231 cmd := exec.Command(TestBinary, args...)
232
233 pwd, err := os.Getwd()
234 if err != nil {
235 t.Fatal("Test configuration failed:", err)
236 }
237
238 // Set environment variables.
239 cmd.Env = os.Environ()
240 cmd.Env = append(cmd.Env,
241 "TEST_PWD="+pwd,
242 "TEST_STATE_DIR="+filepath.Join(t.testDir, "statedir"),
243 "TEST_RUNTIME_DIR="+filepath.Join(t.testDir, "runtimedir"),
244 )
245 for name, port := range t.ports {
246 cmd.Env = append(cmd.Env, fmt.Sprintf("TEST_PORT_%s=%d", name, port))
247 }
248 cmd.Env = append(cmd.Env, t.env...)
249
250 return cmd
251}
252
253func (t *T) MustRunCLIGroup(args ...[]string) {
254 t.ensureCanRun()

Callers 2

RunCLIMethod · 0.95
RunMethod · 0.95

Calls 2

LocalAddrMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected