| 665 | } |
| 666 | |
| 667 | func TestCommitsHelperProcess(t *testing.T) { |
| 668 | if os.Getenv("GH_WANT_HELPER_PROCESS") != "1" { |
| 669 | return |
| 670 | } |
| 671 | |
| 672 | var td stubbedCommitsCommandData |
| 673 | _ = json.Unmarshal([]byte(os.Getenv("GH_COMMITS_TEST_DATA")), &td) |
| 674 | |
| 675 | if td.ErrMsg != "" { |
| 676 | fmt.Fprint(os.Stderr, td.ErrMsg) |
| 677 | } else { |
| 678 | var sb strings.Builder |
| 679 | for _, commit := range td.Commits { |
| 680 | sb.WriteString(commit.Sha) |
| 681 | sb.WriteString("\u0000") |
| 682 | sb.WriteString(commit.Title) |
| 683 | sb.WriteString("\u0000") |
| 684 | sb.WriteString(commit.Body) |
| 685 | sb.WriteString("\u0000") |
| 686 | sb.WriteString("\n") |
| 687 | } |
| 688 | fmt.Fprint(os.Stdout, sb.String()) |
| 689 | } |
| 690 | |
| 691 | os.Exit(td.ExitStatus) |
| 692 | } |
| 693 | |
| 694 | func createCommitsCommandContext(t *testing.T, testData stubbedCommitsCommandData) (*exec.Cmd, commandCtx) { |
| 695 | t.Helper() |