From aae4480d35116455d7115e71120566e8be55b4a4 Mon Sep 17 00:00:00 2001 From: Onsi Fakhouri Date: Thu, 31 Mar 2022 12:18:09 -0600 Subject: [PATCH] Inoke reporting nodes during dry-run (fixes #956 and #935) --- .../internal_integration/config_dry_run_test.go | 13 ++++++++++--- internal/report_entry_test.go | 6 ++++-- internal/suite.go | 9 --------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/internal/internal_integration/config_dry_run_test.go b/internal/internal_integration/config_dry_run_test.go index 5a9bd5b7b..6019791cc 100644 --- a/internal/internal_integration/config_dry_run_test.go +++ b/internal/internal_integration/config_dry_run_test.go @@ -20,7 +20,7 @@ var _ = Describe("when config.DryRun is enabled", func() { It("B", rt.T("B", func() { F() })) PIt("C", rt.T("C", func() { F() })) It("D", rt.T("D")) - It("E", rt.T("D")) + It("E", rt.T("E")) }) AfterEach(rt.T("aft")) AfterSuite(rt.T("after-suite")) @@ -29,8 +29,15 @@ var _ = Describe("when config.DryRun is enabled", func() { }) }) - It("does not run any tests", func() { - Ω(rt).Should(HaveTrackedNothing()) + It("does not run any tests but does invoke reporters", func() { + Ω(rt).Should(HaveTracked( + "report-before-each", "report-after-each", //A + "report-before-each", "report-after-each", //B + "report-before-each", "report-after-each", //C + "report-before-each", "report-after-each", //D + "report-before-each", "report-after-each", //E + "report-after-suite", //AfterSuite + )) }) It("reports on the tests (both that they will run and that they did run) and honors skip state", func() { diff --git a/internal/report_entry_test.go b/internal/report_entry_test.go index 1244ddb6b..1a0aa8d80 100644 --- a/internal/report_entry_test.go +++ b/internal/report_entry_test.go @@ -266,7 +266,8 @@ var _ = Describe("ReportEntry and ReportEntries", func() { }) ReportAfterEach(func(report SpecReport) { - if report.State.Is(types.SpecStatePassed) { + config, _ := GinkgoConfiguration() + if !config.DryRun && report.State.Is(types.SpecStatePassed) { Ω(report.ReportEntries[0].StringRepresentation()).Should(Equal("{{red}}bob {{green}}17{{/}}")) } }) @@ -289,7 +290,8 @@ var _ = Describe("ReportEntry and ReportEntries", func() { }) ReportAfterEach(func(report SpecReport) { - if report.State.Is(types.SpecStatePassed) { + config, _ := GinkgoConfiguration() + if !config.DryRun && report.State.Is(types.SpecStatePassed) { Ω(report.ReportEntries[0].StringRepresentation()).Should(Equal("{{red}}alice {{green}}42{{/}}")) } }) diff --git a/internal/suite.go b/internal/suite.go index 8797895b7..a521ccbd9 100644 --- a/internal/suite.go +++ b/internal/suite.go @@ -393,10 +393,6 @@ func (suite *Suite) runReportAfterSuite() { } func (suite *Suite) reportEach(spec Spec, nodeType types.NodeType) { - if suite.config.DryRun { - return - } - nodes := spec.Nodes.WithType(nodeType) if nodeType == types.NodeTypeReportAfterEach { nodes = nodes.SortedByDescendingNestingLevel() @@ -525,11 +521,6 @@ func (suite *Suite) runSuiteNode(node Node, interruptChannel chan interface{}) { } func (suite *Suite) runReportAfterSuiteNode(node Node, report types.Report) { - if suite.config.DryRun { - suite.currentSpecReport.State = types.SpecStatePassed - return - } - suite.writer.Truncate() suite.outputInterceptor.StartInterceptingOutput() suite.currentSpecReport.StartTime = time.Now()