extractTimeout returns args with any -timeout / -test.timeout flags stripped, and the smaller of cap and the user-supplied timeout (if any). This lets retries use the testwrapper-computed per-attempt timeout, but never exceed an explicit -timeout the user passed on the command line.
(args []string, cap time.Duration)
| 537 | // This lets retries use the testwrapper-computed per-attempt timeout, but |
| 538 | // never exceed an explicit -timeout the user passed on the command line. |
| 539 | func extractTimeout(args []string, cap time.Duration) (stripped []string, t time.Duration) { |
| 540 | t = cap |
| 541 | stripped = make([]string, 0, len(args)) |
| 542 | for i := 0; i < len(args); i++ { |
| 543 | a := args[i] |
| 544 | bare := strings.TrimLeft(a, "-") |
| 545 | name, val, hasEq := strings.Cut(bare, "=") |
| 546 | if name == "timeout" || name == "test.timeout" { |
| 547 | var raw string |
| 548 | if hasEq { |
| 549 | raw = val |
| 550 | } else if i+1 < len(args) { |
| 551 | raw = args[i+1] |
| 552 | i++ |
| 553 | } |
| 554 | if d, err := time.ParseDuration(raw); err == nil && d < t { |
| 555 | t = d |
| 556 | } |
| 557 | continue |
| 558 | } |
| 559 | stripped = append(stripped, a) |
| 560 | } |
| 561 | return stripped, t |
| 562 | } |
| 563 | |
| 564 | // computePerAttemptTimeout returns the -timeout we use for each retry attempt |
| 565 | // of a test that first failed in firstFail. |
no outgoing calls
no test coverage detected
searching dependent graphs…