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