From cce391b663aa488b8b4f681616b52dc8f2e3d531 Mon Sep 17 00:00:00 2001 From: Seonghyun Hong Date: Thu, 18 Jun 2026 21:37:24 +0900 Subject: [PATCH 1/2] fix: show checks summary when all checks were cancelled printSummary gated the summary block on Failed+Passed+Skipping+Pending > 0, omitting Canceled. For a PR whose only checks were cancelled, the summary (and the 'Some checks were cancelled' message) was skipped, printing a blank line. Include Canceled in the guard. Signed-off-by: Seonghyun Hong --- pkg/cmd/pr/checks/output.go | 2 +- pkg/cmd/pr/checks/output_test.go | 56 ++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 pkg/cmd/pr/checks/output_test.go diff --git a/pkg/cmd/pr/checks/output.go b/pkg/cmd/pr/checks/output.go index 24105c3e226..581a8a88418 100644 --- a/pkg/cmd/pr/checks/output.go +++ b/pkg/cmd/pr/checks/output.go @@ -68,7 +68,7 @@ func addRow(tp *tableprinter.TablePrinter, io *iostreams.IOStreams, o check) { func printSummary(io *iostreams.IOStreams, counts checkCounts) { summary := "" - if counts.Failed+counts.Passed+counts.Skipping+counts.Pending > 0 { + if counts.Failed+counts.Passed+counts.Skipping+counts.Pending+counts.Canceled > 0 { if counts.Failed > 0 { summary = "Some checks were not successful" } else if counts.Pending > 0 { diff --git a/pkg/cmd/pr/checks/output_test.go b/pkg/cmd/pr/checks/output_test.go new file mode 100644 index 00000000000..06a91a4edf9 --- /dev/null +++ b/pkg/cmd/pr/checks/output_test.go @@ -0,0 +1,56 @@ +package checks + +import ( + "testing" + + "github.com/cli/cli/v2/pkg/iostreams" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestPrintSummary(t *testing.T) { + tests := []struct { + name string + counts checkCounts + want string + }{ + { + name: "no checks", + counts: checkCounts{}, + want: "\n\n", + }, + { + name: "only cancelled checks", + counts: checkCounts{Canceled: 2}, + want: "Some checks were cancelled\n2 cancelled, 0 failing, 0 successful, 0 skipped, and 0 pending checks\n\n", + }, + { + name: "cancelled and passing checks", + counts: checkCounts{Canceled: 1, Passed: 2}, + want: "Some checks were cancelled\n1 cancelled, 0 failing, 2 successful, 0 skipped, and 0 pending checks\n\n", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + ios, _, stdout, _ := iostreams.Test() + ios.SetStdoutTTY(true) + + printSummary(ios, tt.counts) + + require.Equal(t, tt.want, stdout.String()) + }) + } + + // Regression guard: a check set containing only cancelled checks must still + // produce a summary. Before the fix, the guard in printSummary omitted + // counts.Canceled, so a cancelled-only result printed an empty summary. + t.Run("cancelled-only is not silently empty", func(t *testing.T) { + ios, _, stdout, _ := iostreams.Test() + ios.SetStdoutTTY(true) + + printSummary(ios, checkCounts{Canceled: 1}) + + assert.Contains(t, stdout.String(), "Some checks were cancelled") + }) +} From 32db18657aa0705d936e21780f8b4cc02a6938d8 Mon Sep 17 00:00:00 2001 From: Seonghyun Hong Date: Fri, 19 Jun 2026 21:45:21 +0900 Subject: [PATCH 2/2] Cover all printSummary branches in a table test Address review: expand TestPrintSummary to exercise every summary path (no checks, all successful, failed, pending, cancelled) and drop the redundant separate regression case. Signed-off-by: Seonghyun Hong --- pkg/cmd/pr/checks/output_test.go | 37 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/pkg/cmd/pr/checks/output_test.go b/pkg/cmd/pr/checks/output_test.go index 06a91a4edf9..aa3eed04725 100644 --- a/pkg/cmd/pr/checks/output_test.go +++ b/pkg/cmd/pr/checks/output_test.go @@ -4,7 +4,6 @@ import ( "testing" "github.com/cli/cli/v2/pkg/iostreams" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -20,14 +19,26 @@ func TestPrintSummary(t *testing.T) { want: "\n\n", }, { - name: "only cancelled checks", - counts: checkCounts{Canceled: 2}, - want: "Some checks were cancelled\n2 cancelled, 0 failing, 0 successful, 0 skipped, and 0 pending checks\n\n", + name: "all successful", + counts: checkCounts{Passed: 3}, + want: "All checks were successful\n0 cancelled, 0 failing, 3 successful, 0 skipped, and 0 pending checks\n\n", + }, + { + name: "some failed", + counts: checkCounts{Failed: 1, Passed: 2}, + want: "Some checks were not successful\n0 cancelled, 1 failing, 2 successful, 0 skipped, and 0 pending checks\n\n", }, { - name: "cancelled and passing checks", - counts: checkCounts{Canceled: 1, Passed: 2}, - want: "Some checks were cancelled\n1 cancelled, 0 failing, 2 successful, 0 skipped, and 0 pending checks\n\n", + name: "some pending", + counts: checkCounts{Pending: 1, Passed: 2}, + want: "Some checks are still pending\n0 cancelled, 0 failing, 2 successful, 0 skipped, and 1 pending checks\n\n", + }, + { + // Regression: before the fix, the guard omitted counts.Canceled, so a + // cancelled-only result printed an empty summary. + name: "only cancelled", + counts: checkCounts{Canceled: 2}, + want: "Some checks were cancelled\n2 cancelled, 0 failing, 0 successful, 0 skipped, and 0 pending checks\n\n", }, } @@ -41,16 +52,4 @@ func TestPrintSummary(t *testing.T) { require.Equal(t, tt.want, stdout.String()) }) } - - // Regression guard: a check set containing only cancelled checks must still - // produce a summary. Before the fix, the guard in printSummary omitted - // counts.Canceled, so a cancelled-only result printed an empty summary. - t.Run("cancelled-only is not silently empty", func(t *testing.T) { - ios, _, stdout, _ := iostreams.Test() - ios.SetStdoutTTY(true) - - printSummary(ios, checkCounts{Canceled: 1}) - - assert.Contains(t, stdout.String(), "Some checks were cancelled") - }) }