From e6e3b989075c2a9e645402aee442976a327e0397 Mon Sep 17 00:00:00 2001 From: Danny Baez Date: Thu, 5 Jan 2023 11:40:31 -0500 Subject: [PATCH] Support for labels and pending decorator in ginkgo outline output (#1113) * ginkgo outline will now display a Labels column/field with labels assigned to nodes * proper support for the pending decorator assigned to nodes * documentation update * update to outline tests --- docs/index.md | 17 ++-- ginkgo/outline/_testdata/alias_test.go.csv | 32 +++---- ginkgo/outline/_testdata/alias_test.go.json | 2 +- ginkgo/outline/_testdata/dsl_core_test.go.csv | 12 +-- .../outline/_testdata/dsl_core_test.go.json | 2 +- ginkgo/outline/_testdata/focused_test.go.csv | 32 +++---- ginkgo/outline/_testdata/focused_test.go.json | 2 +- ginkgo/outline/_testdata/labels_test.go | 44 +++++++++ ginkgo/outline/_testdata/labels_test.go.csv | 16 ++++ ginkgo/outline/_testdata/labels_test.go.json | 1 + ginkgo/outline/_testdata/mixed_test.go.csv | 36 ++++---- ginkgo/outline/_testdata/mixed_test.go.json | 2 +- .../_testdata/nestedfocused_test.go.csv | 30 +++---- .../_testdata/nestedfocused_test.go.json | 2 +- ginkgo/outline/_testdata/nodot_test.go.csv | 2 +- ginkgo/outline/_testdata/normal_test.go.csv | 32 +++---- ginkgo/outline/_testdata/normal_test.go.json | 2 +- .../_testdata/pending_decorator_test.go | 44 +++++++++ .../_testdata/pending_decorator_test.go.csv | 16 ++++ .../_testdata/pending_decorator_test.go.json | 1 + ginkgo/outline/_testdata/pending_test.go.csv | 32 +++---- ginkgo/outline/_testdata/pending_test.go.json | 2 +- ginkgo/outline/_testdata/position_test.go.csv | 6 +- .../outline/_testdata/position_test.go.json | 2 +- ginkgo/outline/_testdata/suite_test.go.csv | 2 +- ginkgo/outline/ginkgo.go | 90 ++++++++++++++++++- ginkgo/outline/outline.go | 11 ++- ginkgo/outline/outline_test.go | 2 + 28 files changed, 345 insertions(+), 129 deletions(-) create mode 100644 ginkgo/outline/_testdata/labels_test.go create mode 100644 ginkgo/outline/_testdata/labels_test.go.csv create mode 100644 ginkgo/outline/_testdata/labels_test.go.json create mode 100644 ginkgo/outline/_testdata/pending_decorator_test.go create mode 100644 ginkgo/outline/_testdata/pending_decorator_test.go.csv create mode 100644 ginkgo/outline/_testdata/pending_decorator_test.go.json diff --git a/docs/index.md b/docs/index.md index 57d46a1a7..3b090a6f5 100644 --- a/docs/index.md +++ b/docs/index.md @@ -5093,14 +5093,14 @@ ginkgo outline book_test.go This generates an outline in a comma-separated-values (CSV) format. Column headers are on the first line, followed by Ginkgo containers, specs, and other identifiers, in the order they appear in the file: - Name,Text,Start,End,Spec,Focused,Pending - Describe,Book,124,973,false,false,false - BeforeEach,,217,507,false,false,false - Describe,Categorizing book length,513,970,false,false,false - Context,With more than 300 pages,567,753,false,false,false - It,should be a novel,624,742,true,false,false - Context,With fewer than 300 pages,763,963,false,false,false - It,should be a short story,821,952,true,false,false + Name,Text,Start,End,Spec,Focused,Pending,Labels + Describe,Book,124,973,false,false,false,"" + BeforeEach,,217,507,false,false,false,"" + Describe,Categorizing book length,513,970,false,false,false,"" + Context,With more than 300 pages,567,753,false,false,false,"" + It,should be a novel,624,742,true,false,false,"" + Context,With fewer than 300 pages,763,963,false,false,false,"" + It,should be a short story,821,952,true,false,false,"" The columns are: @@ -5111,6 +5111,7 @@ The columns are: - Spec (bool): True, if the identifier is a spec. - Focused (bool): True, if focused. (Conforms to the rules in [Focused Specs](#focused-specs).) - Pending (bool): True, if pending. (Conforms to the rules in [Pending Specs](#pending-specs).) +- Labels (string): If labels are assigned to nodes then will be shown as double quoted comma separated values. (Conforms to the rules in [Spec Labels](#spec-labels).) You can set a different output format with the `-format` flag. Accepted formats are `csv`, `indent`, and `json`. The `ident` format is like `csv`, but uses indentation to show the nesting of containers and specs. Both the `csv` and `json` formats can be read by another program, e.g., an editor plugin that displays a tree view of Ginkgo tests in a file, or presents a menu for the user to quickly navigate to a container or spec. diff --git a/ginkgo/outline/_testdata/alias_test.go.csv b/ginkgo/outline/_testdata/alias_test.go.csv index 2edfa512e..4e1fa3dbd 100644 --- a/ginkgo/outline/_testdata/alias_test.go.csv +++ b/ginkgo/outline/_testdata/alias_test.go.csv @@ -1,16 +1,16 @@ -Name,Text,Start,End,Spec,Focused,Pending -Describe,NodotFixture,81,670,false,false,false -Describe,normal,126,259,false,false,false -It,normal,166,255,true,false,false -By,normal,201,223,false,false,false -By,normal,227,249,false,false,false -Context,normal,262,342,false,false,false -It,normal,301,338,true,false,false -When,normal,345,422,false,false,false -It,normal,381,418,true,false,false -It,normal,425,461,true,false,false -Specify,normal,464,505,true,false,false -DescribeTable,normal,508,586,false,false,false -Entry,normal,557,582,true,false,false -DescribeTable,normal,589,667,false,false,false -Entry,normal,638,663,true,false,false +Name,Text,Start,End,Spec,Focused,Pending,Labels +Describe,NodotFixture,81,670,false,false,false,"" +Describe,normal,126,259,false,false,false,"" +It,normal,166,255,true,false,false,"" +By,normal,201,223,false,false,false,"" +By,normal,227,249,false,false,false,"" +Context,normal,262,342,false,false,false,"" +It,normal,301,338,true,false,false,"" +When,normal,345,422,false,false,false,"" +It,normal,381,418,true,false,false,"" +It,normal,425,461,true,false,false,"" +Specify,normal,464,505,true,false,false,"" +DescribeTable,normal,508,586,false,false,false,"" +Entry,normal,557,582,true,false,false,"" +DescribeTable,normal,589,667,false,false,false,"" +Entry,normal,638,663,true,false,false,"" diff --git a/ginkgo/outline/_testdata/alias_test.go.json b/ginkgo/outline/_testdata/alias_test.go.json index b19367599..5e30f741d 100644 --- a/ginkgo/outline/_testdata/alias_test.go.json +++ b/ginkgo/outline/_testdata/alias_test.go.json @@ -1 +1 @@ -[{"name":"Describe","text":"NodotFixture","start":81,"end":670,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"Describe","text":"normal","start":126,"end":259,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"It","text":"normal","start":166,"end":255,"spec":true,"focused":false,"pending":false,"nodes":[{"name":"By","text":"normal","start":201,"end":223,"spec":false,"focused":false,"pending":false,"nodes":[]},{"name":"By","text":"normal","start":227,"end":249,"spec":false,"focused":false,"pending":false,"nodes":[]}]}]},{"name":"Context","text":"normal","start":262,"end":342,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"It","text":"normal","start":301,"end":338,"spec":true,"focused":false,"pending":false,"nodes":[]}]},{"name":"When","text":"normal","start":345,"end":422,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"It","text":"normal","start":381,"end":418,"spec":true,"focused":false,"pending":false,"nodes":[]}]},{"name":"It","text":"normal","start":425,"end":461,"spec":true,"focused":false,"pending":false,"nodes":[]},{"name":"Specify","text":"normal","start":464,"end":505,"spec":true,"focused":false,"pending":false,"nodes":[]},{"name":"DescribeTable","text":"normal","start":508,"end":586,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"Entry","text":"normal","start":557,"end":582,"spec":true,"focused":false,"pending":false,"nodes":[]}]},{"name":"DescribeTable","text":"normal","start":589,"end":667,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"Entry","text":"normal","start":638,"end":663,"spec":true,"focused":false,"pending":false,"nodes":[]}]}]}] +[{"name":"Describe","text":"NodotFixture","start":81,"end":670,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"Describe","text":"normal","start":126,"end":259,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"It","text":"normal","start":166,"end":255,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"By","text":"normal","start":201,"end":223,"spec":false,"focused":false,"pending":false,"labels":null,"nodes":[]},{"name":"By","text":"normal","start":227,"end":249,"spec":false,"focused":false,"pending":false,"labels":null,"nodes":[]}]}]},{"name":"Context","text":"normal","start":262,"end":342,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"It","text":"normal","start":301,"end":338,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]}]},{"name":"When","text":"normal","start":345,"end":422,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"It","text":"normal","start":381,"end":418,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]}]},{"name":"It","text":"normal","start":425,"end":461,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]},{"name":"Specify","text":"normal","start":464,"end":505,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]},{"name":"DescribeTable","text":"normal","start":508,"end":586,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"Entry","text":"normal","start":557,"end":582,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]}]},{"name":"DescribeTable","text":"normal","start":589,"end":667,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"Entry","text":"normal","start":638,"end":663,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]}]}]}] diff --git a/ginkgo/outline/_testdata/dsl_core_test.go.csv b/ginkgo/outline/_testdata/dsl_core_test.go.csv index addc675cf..6b3db3a7c 100644 --- a/ginkgo/outline/_testdata/dsl_core_test.go.csv +++ b/ginkgo/outline/_testdata/dsl_core_test.go.csv @@ -1,6 +1,6 @@ -Name,Text,Start,End,Spec,Focused,Pending -Describe,DslCoreFixture,82,216,false,false,false -Describe,dslcore,119,213,false,false,false -It,dslcore,150,209,true,false,false -By,step 1,176,188,false,false,false -By,step 2,192,204,false,false,false +Name,Text,Start,End,Spec,Focused,Pending,Labels +Describe,DslCoreFixture,82,216,false,false,false,"" +Describe,dslcore,119,213,false,false,false,"" +It,dslcore,150,209,true,false,false,"" +By,step 1,176,188,false,false,false,"" +By,step 2,192,204,false,false,false,"" diff --git a/ginkgo/outline/_testdata/dsl_core_test.go.json b/ginkgo/outline/_testdata/dsl_core_test.go.json index 245a877d6..71a5f074f 100644 --- a/ginkgo/outline/_testdata/dsl_core_test.go.json +++ b/ginkgo/outline/_testdata/dsl_core_test.go.json @@ -1 +1 @@ -[{"name":"Describe","text":"DslCoreFixture","start":82,"end":216,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"Describe","text":"dslcore","start":119,"end":213,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"It","text":"dslcore","start":150,"end":209,"spec":true,"focused":false,"pending":false,"nodes":[{"name":"By","text":"step 1","start":176,"end":188,"spec":false,"focused":false,"pending":false,"nodes":[]},{"name":"By","text":"step 2","start":192,"end":204,"spec":false,"focused":false,"pending":false,"nodes":[]}]}]}]}] +[{"name":"Describe","text":"DslCoreFixture","start":82,"end":216,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"Describe","text":"dslcore","start":119,"end":213,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"It","text":"dslcore","start":150,"end":209,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"By","text":"step 1","start":176,"end":188,"spec":false,"focused":false,"pending":false,"labels":null,"nodes":[]},{"name":"By","text":"step 2","start":192,"end":204,"spec":false,"focused":false,"pending":false,"labels":null,"nodes":[]}]}]}]}] diff --git a/ginkgo/outline/_testdata/focused_test.go.csv b/ginkgo/outline/_testdata/focused_test.go.csv index b36af6127..95d3e7f89 100644 --- a/ginkgo/outline/_testdata/focused_test.go.csv +++ b/ginkgo/outline/_testdata/focused_test.go.csv @@ -1,16 +1,16 @@ -Name,Text,Start,End,Spec,Focused,Pending -Describe,unfocused,73,529,false,false,false -FDescribe,focused,105,202,false,true,false -It,focused,137,198,true,true,false -By,focused,163,176,false,true,false -By,focused,180,193,false,true,false -FContext,focused,205,268,false,true,false -It,focused,236,264,true,true,false -FWhen,focused,271,331,false,true,false -It,focused,299,327,true,true,false -FIt,focused,334,362,true,true,false -FSpecify,focused,365,398,true,true,false -FDescribeTable,focused,401,462,false,true,false -Entry,focused,442,458,true,true,false -DescribeTable,focused,465,526,false,false,false -FEntry,focused,505,522,true,true,false +Name,Text,Start,End,Spec,Focused,Pending,Labels +Describe,unfocused,73,529,false,false,false,"" +FDescribe,focused,105,202,false,true,false,"" +It,focused,137,198,true,true,false,"" +By,focused,163,176,false,true,false,"" +By,focused,180,193,false,true,false,"" +FContext,focused,205,268,false,true,false,"" +It,focused,236,264,true,true,false,"" +FWhen,focused,271,331,false,true,false,"" +It,focused,299,327,true,true,false,"" +FIt,focused,334,362,true,true,false,"" +FSpecify,focused,365,398,true,true,false,"" +FDescribeTable,focused,401,462,false,true,false,"" +Entry,focused,442,458,true,true,false,"" +DescribeTable,focused,465,526,false,false,false,"" +FEntry,focused,505,522,true,true,false,"" diff --git a/ginkgo/outline/_testdata/focused_test.go.json b/ginkgo/outline/_testdata/focused_test.go.json index 8b258b83a..0fa5a7250 100644 --- a/ginkgo/outline/_testdata/focused_test.go.json +++ b/ginkgo/outline/_testdata/focused_test.go.json @@ -1 +1 @@ -[{"name":"Describe","text":"unfocused","start":73,"end":529,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"FDescribe","text":"focused","start":105,"end":202,"spec":false,"focused":true,"pending":false,"nodes":[{"name":"It","text":"focused","start":137,"end":198,"spec":true,"focused":true,"pending":false,"nodes":[{"name":"By","text":"focused","start":163,"end":176,"spec":false,"focused":true,"pending":false,"nodes":[]},{"name":"By","text":"focused","start":180,"end":193,"spec":false,"focused":true,"pending":false,"nodes":[]}]}]},{"name":"FContext","text":"focused","start":205,"end":268,"spec":false,"focused":true,"pending":false,"nodes":[{"name":"It","text":"focused","start":236,"end":264,"spec":true,"focused":true,"pending":false,"nodes":[]}]},{"name":"FWhen","text":"focused","start":271,"end":331,"spec":false,"focused":true,"pending":false,"nodes":[{"name":"It","text":"focused","start":299,"end":327,"spec":true,"focused":true,"pending":false,"nodes":[]}]},{"name":"FIt","text":"focused","start":334,"end":362,"spec":true,"focused":true,"pending":false,"nodes":[]},{"name":"FSpecify","text":"focused","start":365,"end":398,"spec":true,"focused":true,"pending":false,"nodes":[]},{"name":"FDescribeTable","text":"focused","start":401,"end":462,"spec":false,"focused":true,"pending":false,"nodes":[{"name":"Entry","text":"focused","start":442,"end":458,"spec":true,"focused":true,"pending":false,"nodes":[]}]},{"name":"DescribeTable","text":"focused","start":465,"end":526,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"FEntry","text":"focused","start":505,"end":522,"spec":true,"focused":true,"pending":false,"nodes":[]}]}]}] +[{"name":"Describe","text":"unfocused","start":73,"end":529,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"FDescribe","text":"focused","start":105,"end":202,"spec":false,"focused":true,"pending":false,"labels":[],"nodes":[{"name":"It","text":"focused","start":137,"end":198,"spec":true,"focused":true,"pending":false,"labels":[],"nodes":[{"name":"By","text":"focused","start":163,"end":176,"spec":false,"focused":true,"pending":false,"labels":null,"nodes":[]},{"name":"By","text":"focused","start":180,"end":193,"spec":false,"focused":true,"pending":false,"labels":null,"nodes":[]}]}]},{"name":"FContext","text":"focused","start":205,"end":268,"spec":false,"focused":true,"pending":false,"labels":[],"nodes":[{"name":"It","text":"focused","start":236,"end":264,"spec":true,"focused":true,"pending":false,"labels":[],"nodes":[]}]},{"name":"FWhen","text":"focused","start":271,"end":331,"spec":false,"focused":true,"pending":false,"labels":[],"nodes":[{"name":"It","text":"focused","start":299,"end":327,"spec":true,"focused":true,"pending":false,"labels":[],"nodes":[]}]},{"name":"FIt","text":"focused","start":334,"end":362,"spec":true,"focused":true,"pending":false,"labels":[],"nodes":[]},{"name":"FSpecify","text":"focused","start":365,"end":398,"spec":true,"focused":true,"pending":false,"labels":[],"nodes":[]},{"name":"FDescribeTable","text":"focused","start":401,"end":462,"spec":false,"focused":true,"pending":false,"labels":[],"nodes":[{"name":"Entry","text":"focused","start":442,"end":458,"spec":true,"focused":true,"pending":false,"labels":[],"nodes":[]}]},{"name":"DescribeTable","text":"focused","start":465,"end":526,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"FEntry","text":"focused","start":505,"end":522,"spec":true,"focused":true,"pending":false,"labels":[],"nodes":[]}]}]}] diff --git a/ginkgo/outline/_testdata/labels_test.go b/ginkgo/outline/_testdata/labels_test.go new file mode 100644 index 000000000..96aaea6e3 --- /dev/null +++ b/ginkgo/outline/_testdata/labels_test.go @@ -0,0 +1,44 @@ +package example_test + +import ( + . "github.com/onsi/ginkgo/v2" +) + +var _ = Describe("NormalFixture", func() { + Describe("normal", Label("normal", "serial"), func() { + It("normal", func() { + By("step 1") + By("step 2") + }) + }) + + Context("normal", func() { + It("normal", Label("medium"), Label("slow"), func() { + + }) + }) + + When("normal", func() { + It("normal", func() { + + }) + }) + + It("normal", func() { + + }) + + Specify("normal", func() { + + }) + + DescribeTable("normal", + func() {}, + Entry("normal"), + ) + + DescribeTable("normal", + func() {}, + Entry("normal"), + ) +}) diff --git a/ginkgo/outline/_testdata/labels_test.go.csv b/ginkgo/outline/_testdata/labels_test.go.csv new file mode 100644 index 000000000..0cb124ab1 --- /dev/null +++ b/ginkgo/outline/_testdata/labels_test.go.csv @@ -0,0 +1,16 @@ +Name,Text,Start,End,Spec,Focused,Pending,Labels +Describe,NormalFixture,73,571,false,false,false,"" +Describe,normal,109,228,false,false,false,"normal, serial" +It,normal,166,224,true,false,false,"" +By,step 1,191,203,false,false,false,"" +By,step 2,207,219,false,false,false,"" +Context,normal,231,323,false,false,false,"" +It,normal,260,319,true,false,false,"medium, slow" +When,normal,326,383,false,false,false,"" +It,normal,352,379,true,false,false,"" +It,normal,386,412,true,false,false,"" +Specify,normal,415,446,true,false,false,"" +DescribeTable,normal,449,507,false,false,false,"" +Entry,normal,488,503,true,false,false,"" +DescribeTable,normal,510,568,false,false,false,"" +Entry,normal,549,564,true,false,false,"" diff --git a/ginkgo/outline/_testdata/labels_test.go.json b/ginkgo/outline/_testdata/labels_test.go.json new file mode 100644 index 000000000..3ede7b94b --- /dev/null +++ b/ginkgo/outline/_testdata/labels_test.go.json @@ -0,0 +1 @@ +[{"name":"Describe","text":"NormalFixture","start":73,"end":571,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"Describe","text":"normal","start":109,"end":228,"spec":false,"focused":false,"pending":false,"labels":["normal","serial"],"nodes":[{"name":"It","text":"normal","start":166,"end":224,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"By","text":"step 1","start":191,"end":203,"spec":false,"focused":false,"pending":false,"labels":null,"nodes":[]},{"name":"By","text":"step 2","start":207,"end":219,"spec":false,"focused":false,"pending":false,"labels":null,"nodes":[]}]}]},{"name":"Context","text":"normal","start":231,"end":323,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"It","text":"normal","start":260,"end":319,"spec":true,"focused":false,"pending":false,"labels":["medium","slow"],"nodes":[]}]},{"name":"When","text":"normal","start":326,"end":383,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"It","text":"normal","start":352,"end":379,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]}]},{"name":"It","text":"normal","start":386,"end":412,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]},{"name":"Specify","text":"normal","start":415,"end":446,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]},{"name":"DescribeTable","text":"normal","start":449,"end":507,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"Entry","text":"normal","start":488,"end":503,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]}]},{"name":"DescribeTable","text":"normal","start":510,"end":568,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"Entry","text":"normal","start":549,"end":564,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]}]}]}] diff --git a/ginkgo/outline/_testdata/mixed_test.go.csv b/ginkgo/outline/_testdata/mixed_test.go.csv index 6819c1ba9..d97f70682 100644 --- a/ginkgo/outline/_testdata/mixed_test.go.csv +++ b/ginkgo/outline/_testdata/mixed_test.go.csv @@ -1,18 +1,18 @@ -Name,Text,Start,End,Spec,Focused,Pending -FDescribe,unfocused,73,584,false,false,false -FContext,unfocused,106,205,false,false,false -It,unfocused,139,169,true,false,false -FIt,focused,172,201,true,true,false -Context,unfocused,208,306,false,false,false -FIt,focused,240,269,true,true,false -It,unfocused,272,302,true,false,false -FContext,focused,309,403,false,true,false -It,focused,340,368,true,true,false -It,focused,371,399,true,true,false -PContext,unfocused,406,581,false,false,true -FIt,unfocused,439,507,true,false,true -By,unfocused,468,483,false,false,true -By,unfocused,487,502,false,false,true -It,unfocused,510,577,true,false,true -By,unfocused,538,553,false,false,true -By,unfocused,557,572,false,false,true +Name,Text,Start,End,Spec,Focused,Pending,Labels +FDescribe,unfocused,73,584,false,false,false,"" +FContext,unfocused,106,205,false,false,false,"" +It,unfocused,139,169,true,false,false,"" +FIt,focused,172,201,true,true,false,"" +Context,unfocused,208,306,false,false,false,"" +FIt,focused,240,269,true,true,false,"" +It,unfocused,272,302,true,false,false,"" +FContext,focused,309,403,false,true,false,"" +It,focused,340,368,true,true,false,"" +It,focused,371,399,true,true,false,"" +PContext,unfocused,406,581,false,false,true,"" +FIt,unfocused,439,507,true,false,true,"" +By,unfocused,468,483,false,false,true,"" +By,unfocused,487,502,false,false,true,"" +It,unfocused,510,577,true,false,true,"" +By,unfocused,538,553,false,false,true,"" +By,unfocused,557,572,false,false,true,"" diff --git a/ginkgo/outline/_testdata/mixed_test.go.json b/ginkgo/outline/_testdata/mixed_test.go.json index 4f78555ac..bfb174f12 100644 --- a/ginkgo/outline/_testdata/mixed_test.go.json +++ b/ginkgo/outline/_testdata/mixed_test.go.json @@ -1 +1 @@ -[{"name":"FDescribe","text":"unfocused","start":73,"end":584,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"FContext","text":"unfocused","start":106,"end":205,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"It","text":"unfocused","start":139,"end":169,"spec":true,"focused":false,"pending":false,"nodes":[]},{"name":"FIt","text":"focused","start":172,"end":201,"spec":true,"focused":true,"pending":false,"nodes":[]}]},{"name":"Context","text":"unfocused","start":208,"end":306,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"FIt","text":"focused","start":240,"end":269,"spec":true,"focused":true,"pending":false,"nodes":[]},{"name":"It","text":"unfocused","start":272,"end":302,"spec":true,"focused":false,"pending":false,"nodes":[]}]},{"name":"FContext","text":"focused","start":309,"end":403,"spec":false,"focused":true,"pending":false,"nodes":[{"name":"It","text":"focused","start":340,"end":368,"spec":true,"focused":true,"pending":false,"nodes":[]},{"name":"It","text":"focused","start":371,"end":399,"spec":true,"focused":true,"pending":false,"nodes":[]}]},{"name":"PContext","text":"unfocused","start":406,"end":581,"spec":false,"focused":false,"pending":true,"nodes":[{"name":"FIt","text":"unfocused","start":439,"end":507,"spec":true,"focused":false,"pending":true,"nodes":[{"name":"By","text":"unfocused","start":468,"end":483,"spec":false,"focused":false,"pending":true,"nodes":[]},{"name":"By","text":"unfocused","start":487,"end":502,"spec":false,"focused":false,"pending":true,"nodes":[]}]},{"name":"It","text":"unfocused","start":510,"end":577,"spec":true,"focused":false,"pending":true,"nodes":[{"name":"By","text":"unfocused","start":538,"end":553,"spec":false,"focused":false,"pending":true,"nodes":[]},{"name":"By","text":"unfocused","start":557,"end":572,"spec":false,"focused":false,"pending":true,"nodes":[]}]}]}]}] +[{"name":"FDescribe","text":"unfocused","start":73,"end":584,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"FContext","text":"unfocused","start":106,"end":205,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"It","text":"unfocused","start":139,"end":169,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]},{"name":"FIt","text":"focused","start":172,"end":201,"spec":true,"focused":true,"pending":false,"labels":[],"nodes":[]}]},{"name":"Context","text":"unfocused","start":208,"end":306,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"FIt","text":"focused","start":240,"end":269,"spec":true,"focused":true,"pending":false,"labels":[],"nodes":[]},{"name":"It","text":"unfocused","start":272,"end":302,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]}]},{"name":"FContext","text":"focused","start":309,"end":403,"spec":false,"focused":true,"pending":false,"labels":[],"nodes":[{"name":"It","text":"focused","start":340,"end":368,"spec":true,"focused":true,"pending":false,"labels":[],"nodes":[]},{"name":"It","text":"focused","start":371,"end":399,"spec":true,"focused":true,"pending":false,"labels":[],"nodes":[]}]},{"name":"PContext","text":"unfocused","start":406,"end":581,"spec":false,"focused":false,"pending":true,"labels":[],"nodes":[{"name":"FIt","text":"unfocused","start":439,"end":507,"spec":true,"focused":false,"pending":true,"labels":[],"nodes":[{"name":"By","text":"unfocused","start":468,"end":483,"spec":false,"focused":false,"pending":true,"labels":null,"nodes":[]},{"name":"By","text":"unfocused","start":487,"end":502,"spec":false,"focused":false,"pending":true,"labels":null,"nodes":[]}]},{"name":"It","text":"unfocused","start":510,"end":577,"spec":true,"focused":false,"pending":true,"labels":[],"nodes":[{"name":"By","text":"unfocused","start":538,"end":553,"spec":false,"focused":false,"pending":true,"labels":null,"nodes":[]},{"name":"By","text":"unfocused","start":557,"end":572,"spec":false,"focused":false,"pending":true,"labels":null,"nodes":[]}]}]}]}] diff --git a/ginkgo/outline/_testdata/nestedfocused_test.go.csv b/ginkgo/outline/_testdata/nestedfocused_test.go.csv index 5a24f6211..ec952319b 100644 --- a/ginkgo/outline/_testdata/nestedfocused_test.go.csv +++ b/ginkgo/outline/_testdata/nestedfocused_test.go.csv @@ -1,15 +1,15 @@ -Name,Text,Start,End,Spec,Focused,Pending -FDescribe,unfocused,73,476,false,false,false -FContext,unfocused,106,275,false,false,false -It,unfocused,139,206,true,false,false -By,unfocused,167,182,false,false,false -By,unfocused,186,201,false,false,false -FIt,focused,209,271,true,true,false -By,focused,236,249,false,true,false -By,focused,253,266,false,true,false -Context,unfocused,278,376,false,false,false -FIt,focused,310,339,true,true,false -It,unfocused,342,372,true,false,false -FContext,focused,379,473,false,true,false -It,focused,410,438,true,true,false -It,focused,441,469,true,true,false +Name,Text,Start,End,Spec,Focused,Pending,Labels +FDescribe,unfocused,73,476,false,false,false,"" +FContext,unfocused,106,275,false,false,false,"" +It,unfocused,139,206,true,false,false,"" +By,unfocused,167,182,false,false,false,"" +By,unfocused,186,201,false,false,false,"" +FIt,focused,209,271,true,true,false,"" +By,focused,236,249,false,true,false,"" +By,focused,253,266,false,true,false,"" +Context,unfocused,278,376,false,false,false,"" +FIt,focused,310,339,true,true,false,"" +It,unfocused,342,372,true,false,false,"" +FContext,focused,379,473,false,true,false,"" +It,focused,410,438,true,true,false,"" +It,focused,441,469,true,true,false,"" diff --git a/ginkgo/outline/_testdata/nestedfocused_test.go.json b/ginkgo/outline/_testdata/nestedfocused_test.go.json index 6f794a0bb..8d8693df1 100644 --- a/ginkgo/outline/_testdata/nestedfocused_test.go.json +++ b/ginkgo/outline/_testdata/nestedfocused_test.go.json @@ -1 +1 @@ -[{"name":"FDescribe","text":"unfocused","start":73,"end":476,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"FContext","text":"unfocused","start":106,"end":275,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"It","text":"unfocused","start":139,"end":206,"spec":true,"focused":false,"pending":false,"nodes":[{"name":"By","text":"unfocused","start":167,"end":182,"spec":false,"focused":false,"pending":false,"nodes":[]},{"name":"By","text":"unfocused","start":186,"end":201,"spec":false,"focused":false,"pending":false,"nodes":[]}]},{"name":"FIt","text":"focused","start":209,"end":271,"spec":true,"focused":true,"pending":false,"nodes":[{"name":"By","text":"focused","start":236,"end":249,"spec":false,"focused":true,"pending":false,"nodes":[]},{"name":"By","text":"focused","start":253,"end":266,"spec":false,"focused":true,"pending":false,"nodes":[]}]}]},{"name":"Context","text":"unfocused","start":278,"end":376,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"FIt","text":"focused","start":310,"end":339,"spec":true,"focused":true,"pending":false,"nodes":[]},{"name":"It","text":"unfocused","start":342,"end":372,"spec":true,"focused":false,"pending":false,"nodes":[]}]},{"name":"FContext","text":"focused","start":379,"end":473,"spec":false,"focused":true,"pending":false,"nodes":[{"name":"It","text":"focused","start":410,"end":438,"spec":true,"focused":true,"pending":false,"nodes":[]},{"name":"It","text":"focused","start":441,"end":469,"spec":true,"focused":true,"pending":false,"nodes":[]}]}]}] +[{"name":"FDescribe","text":"unfocused","start":73,"end":476,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"FContext","text":"unfocused","start":106,"end":275,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"It","text":"unfocused","start":139,"end":206,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"By","text":"unfocused","start":167,"end":182,"spec":false,"focused":false,"pending":false,"labels":null,"nodes":[]},{"name":"By","text":"unfocused","start":186,"end":201,"spec":false,"focused":false,"pending":false,"labels":null,"nodes":[]}]},{"name":"FIt","text":"focused","start":209,"end":271,"spec":true,"focused":true,"pending":false,"labels":[],"nodes":[{"name":"By","text":"focused","start":236,"end":249,"spec":false,"focused":true,"pending":false,"labels":null,"nodes":[]},{"name":"By","text":"focused","start":253,"end":266,"spec":false,"focused":true,"pending":false,"labels":null,"nodes":[]}]}]},{"name":"Context","text":"unfocused","start":278,"end":376,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"FIt","text":"focused","start":310,"end":339,"spec":true,"focused":true,"pending":false,"labels":[],"nodes":[]},{"name":"It","text":"unfocused","start":342,"end":372,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]}]},{"name":"FContext","text":"focused","start":379,"end":473,"spec":false,"focused":true,"pending":false,"labels":[],"nodes":[{"name":"It","text":"focused","start":410,"end":438,"spec":true,"focused":true,"pending":false,"labels":[],"nodes":[]},{"name":"It","text":"focused","start":441,"end":469,"spec":true,"focused":true,"pending":false,"labels":[],"nodes":[]}]}]}] diff --git a/ginkgo/outline/_testdata/nodot_test.go.csv b/ginkgo/outline/_testdata/nodot_test.go.csv index c85a82705..fe810ce3c 100644 --- a/ginkgo/outline/_testdata/nodot_test.go.csv +++ b/ginkgo/outline/_testdata/nodot_test.go.csv @@ -1 +1 @@ -Name,Text,Start,End,Spec,Focused,Pending +Name,Text,Start,End,Spec,Focused,Pending,Labels diff --git a/ginkgo/outline/_testdata/normal_test.go.csv b/ginkgo/outline/_testdata/normal_test.go.csv index 3c8fae074..0e5878a57 100644 --- a/ginkgo/outline/_testdata/normal_test.go.csv +++ b/ginkgo/outline/_testdata/normal_test.go.csv @@ -1,16 +1,16 @@ -Name,Text,Start,End,Spec,Focused,Pending -Describe,NormalFixture,73,512,false,false,false -Describe,normal,109,201,false,false,false -It,normal,139,197,true,false,false -By,step 1,164,176,false,false,false -By,step 2,180,192,false,false,false -Context,normal,204,264,false,false,false -It,normal,233,260,true,false,false -When,normal,267,324,false,false,false -It,normal,293,320,true,false,false -It,normal,327,353,true,false,false -Specify,normal,356,387,true,false,false -DescribeTable,normal,390,448,false,false,false -Entry,normal,429,444,true,false,false -DescribeTable,normal,451,509,false,false,false -Entry,normal,490,505,true,false,false +Name,Text,Start,End,Spec,Focused,Pending,Labels +Describe,NormalFixture,73,512,false,false,false,"" +Describe,normal,109,201,false,false,false,"" +It,normal,139,197,true,false,false,"" +By,step 1,164,176,false,false,false,"" +By,step 2,180,192,false,false,false,"" +Context,normal,204,264,false,false,false,"" +It,normal,233,260,true,false,false,"" +When,normal,267,324,false,false,false,"" +It,normal,293,320,true,false,false,"" +It,normal,327,353,true,false,false,"" +Specify,normal,356,387,true,false,false,"" +DescribeTable,normal,390,448,false,false,false,"" +Entry,normal,429,444,true,false,false,"" +DescribeTable,normal,451,509,false,false,false,"" +Entry,normal,490,505,true,false,false,"" diff --git a/ginkgo/outline/_testdata/normal_test.go.json b/ginkgo/outline/_testdata/normal_test.go.json index 73cec0a26..4e2830aaf 100644 --- a/ginkgo/outline/_testdata/normal_test.go.json +++ b/ginkgo/outline/_testdata/normal_test.go.json @@ -1 +1 @@ -[{"name":"Describe","text":"NormalFixture","start":73,"end":512,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"Describe","text":"normal","start":109,"end":201,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"It","text":"normal","start":139,"end":197,"spec":true,"focused":false,"pending":false,"nodes":[{"name":"By","text":"step 1","start":164,"end":176,"spec":false,"focused":false,"pending":false,"nodes":[]},{"name":"By","text":"step 2","start":180,"end":192,"spec":false,"focused":false,"pending":false,"nodes":[]}]}]},{"name":"Context","text":"normal","start":204,"end":264,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"It","text":"normal","start":233,"end":260,"spec":true,"focused":false,"pending":false,"nodes":[]}]},{"name":"When","text":"normal","start":267,"end":324,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"It","text":"normal","start":293,"end":320,"spec":true,"focused":false,"pending":false,"nodes":[]}]},{"name":"It","text":"normal","start":327,"end":353,"spec":true,"focused":false,"pending":false,"nodes":[]},{"name":"Specify","text":"normal","start":356,"end":387,"spec":true,"focused":false,"pending":false,"nodes":[]},{"name":"DescribeTable","text":"normal","start":390,"end":448,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"Entry","text":"normal","start":429,"end":444,"spec":true,"focused":false,"pending":false,"nodes":[]}]},{"name":"DescribeTable","text":"normal","start":451,"end":509,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"Entry","text":"normal","start":490,"end":505,"spec":true,"focused":false,"pending":false,"nodes":[]}]}]}] +[{"name":"Describe","text":"NormalFixture","start":73,"end":512,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"Describe","text":"normal","start":109,"end":201,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"It","text":"normal","start":139,"end":197,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"By","text":"step 1","start":164,"end":176,"spec":false,"focused":false,"pending":false,"labels":null,"nodes":[]},{"name":"By","text":"step 2","start":180,"end":192,"spec":false,"focused":false,"pending":false,"labels":null,"nodes":[]}]}]},{"name":"Context","text":"normal","start":204,"end":264,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"It","text":"normal","start":233,"end":260,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]}]},{"name":"When","text":"normal","start":267,"end":324,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"It","text":"normal","start":293,"end":320,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]}]},{"name":"It","text":"normal","start":327,"end":353,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]},{"name":"Specify","text":"normal","start":356,"end":387,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]},{"name":"DescribeTable","text":"normal","start":390,"end":448,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"Entry","text":"normal","start":429,"end":444,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]}]},{"name":"DescribeTable","text":"normal","start":451,"end":509,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"Entry","text":"normal","start":490,"end":505,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]}]}]}] diff --git a/ginkgo/outline/_testdata/pending_decorator_test.go b/ginkgo/outline/_testdata/pending_decorator_test.go new file mode 100644 index 000000000..aaed36d72 --- /dev/null +++ b/ginkgo/outline/_testdata/pending_decorator_test.go @@ -0,0 +1,44 @@ +package example_test + +import ( + . "github.com/onsi/ginkgo/v2" +) + +var _ = Describe("NormalFixture", func() { + Describe("normal", Label("normal", "serial"), Pending, func() { + It("normal", func() { + By("step 1") + By("step 2") + }) + }) + + Context("normal", func() { + It("normal", Label("medium"), Label("slow"), func() { + + }) + }) + + When("normal", func() { + It("normal", func() { + + }) + }) + + It("normal", Pending(), func() { + + }) + + Specify("normal", func() { + + }) + + DescribeTable("normal", + func() {}, + Entry("normal"), + ) + + DescribeTable("normal", + func() {}, + Entry("normal"), + ) +}) diff --git a/ginkgo/outline/_testdata/pending_decorator_test.go.csv b/ginkgo/outline/_testdata/pending_decorator_test.go.csv new file mode 100644 index 000000000..5fafb67fe --- /dev/null +++ b/ginkgo/outline/_testdata/pending_decorator_test.go.csv @@ -0,0 +1,16 @@ +Name,Text,Start,End,Spec,Focused,Pending,Labels +Describe,NormalFixture,73,591,false,false,false,"" +Describe,normal,109,237,false,false,true,"normal, serial" +It,normal,175,233,true,false,true,"" +By,step 1,200,212,false,false,true,"" +By,step 2,216,228,false,false,true,"" +Context,normal,240,332,false,false,false,"" +It,normal,269,328,true,false,false,"medium, slow" +When,normal,335,392,false,false,false,"" +It,normal,361,388,true,false,false,"" +It,normal,395,432,true,false,true,"" +Specify,normal,435,466,true,false,false,"" +DescribeTable,normal,469,527,false,false,false,"" +Entry,normal,508,523,true,false,false,"" +DescribeTable,normal,530,588,false,false,false,"" +Entry,normal,569,584,true,false,false,"" diff --git a/ginkgo/outline/_testdata/pending_decorator_test.go.json b/ginkgo/outline/_testdata/pending_decorator_test.go.json new file mode 100644 index 000000000..e9aa598df --- /dev/null +++ b/ginkgo/outline/_testdata/pending_decorator_test.go.json @@ -0,0 +1 @@ +[{"name":"Describe","text":"NormalFixture","start":73,"end":591,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"Describe","text":"normal","start":109,"end":237,"spec":false,"focused":false,"pending":true,"labels":["normal","serial"],"nodes":[{"name":"It","text":"normal","start":175,"end":233,"spec":true,"focused":false,"pending":true,"labels":[],"nodes":[{"name":"By","text":"step 1","start":200,"end":212,"spec":false,"focused":false,"pending":true,"labels":null,"nodes":[]},{"name":"By","text":"step 2","start":216,"end":228,"spec":false,"focused":false,"pending":true,"labels":null,"nodes":[]}]}]},{"name":"Context","text":"normal","start":240,"end":332,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"It","text":"normal","start":269,"end":328,"spec":true,"focused":false,"pending":false,"labels":["medium","slow"],"nodes":[]}]},{"name":"When","text":"normal","start":335,"end":392,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"It","text":"normal","start":361,"end":388,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]}]},{"name":"It","text":"normal","start":395,"end":432,"spec":true,"focused":false,"pending":true,"labels":[],"nodes":[]},{"name":"Specify","text":"normal","start":435,"end":466,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]},{"name":"DescribeTable","text":"normal","start":469,"end":527,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"Entry","text":"normal","start":508,"end":523,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]}]},{"name":"DescribeTable","text":"normal","start":530,"end":588,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"Entry","text":"normal","start":569,"end":584,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]}]}]}] diff --git a/ginkgo/outline/_testdata/pending_test.go.csv b/ginkgo/outline/_testdata/pending_test.go.csv index 9b5b3fdb5..5991ed493 100644 --- a/ginkgo/outline/_testdata/pending_test.go.csv +++ b/ginkgo/outline/_testdata/pending_test.go.csv @@ -1,16 +1,16 @@ -Name,Text,Start,End,Spec,Focused,Pending -Describe,PendingFixture,73,534,false,false,false -PDescribe,pending,110,207,false,false,true -It,pending,142,203,true,false,true -By,pending,168,181,false,false,true -By,pending,185,198,false,false,true -PContext,pending,210,273,false,false,true -It,pending,241,269,true,false,true -PWhen,pending,276,336,false,false,true -It,pending,304,332,true,false,true -PIt,pending,339,367,true,false,true -PSpecify,pending,370,403,true,false,true -PDescribeTable,pending,406,467,false,false,true -Entry,pending,447,463,true,false,true -DescribeTable,pending,470,531,false,false,false -PEntry,pending,510,527,true,false,true +Name,Text,Start,End,Spec,Focused,Pending,Labels +Describe,PendingFixture,73,534,false,false,false,"" +PDescribe,pending,110,207,false,false,true,"" +It,pending,142,203,true,false,true,"" +By,pending,168,181,false,false,true,"" +By,pending,185,198,false,false,true,"" +PContext,pending,210,273,false,false,true,"" +It,pending,241,269,true,false,true,"" +PWhen,pending,276,336,false,false,true,"" +It,pending,304,332,true,false,true,"" +PIt,pending,339,367,true,false,true,"" +PSpecify,pending,370,403,true,false,true,"" +PDescribeTable,pending,406,467,false,false,true,"" +Entry,pending,447,463,true,false,true,"" +DescribeTable,pending,470,531,false,false,false,"" +PEntry,pending,510,527,true,false,true,"" diff --git a/ginkgo/outline/_testdata/pending_test.go.json b/ginkgo/outline/_testdata/pending_test.go.json index ed6a92e9c..f2ce132b4 100644 --- a/ginkgo/outline/_testdata/pending_test.go.json +++ b/ginkgo/outline/_testdata/pending_test.go.json @@ -1 +1 @@ -[{"name":"Describe","text":"PendingFixture","start":73,"end":534,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"PDescribe","text":"pending","start":110,"end":207,"spec":false,"focused":false,"pending":true,"nodes":[{"name":"It","text":"pending","start":142,"end":203,"spec":true,"focused":false,"pending":true,"nodes":[{"name":"By","text":"pending","start":168,"end":181,"spec":false,"focused":false,"pending":true,"nodes":[]},{"name":"By","text":"pending","start":185,"end":198,"spec":false,"focused":false,"pending":true,"nodes":[]}]}]},{"name":"PContext","text":"pending","start":210,"end":273,"spec":false,"focused":false,"pending":true,"nodes":[{"name":"It","text":"pending","start":241,"end":269,"spec":true,"focused":false,"pending":true,"nodes":[]}]},{"name":"PWhen","text":"pending","start":276,"end":336,"spec":false,"focused":false,"pending":true,"nodes":[{"name":"It","text":"pending","start":304,"end":332,"spec":true,"focused":false,"pending":true,"nodes":[]}]},{"name":"PIt","text":"pending","start":339,"end":367,"spec":true,"focused":false,"pending":true,"nodes":[]},{"name":"PSpecify","text":"pending","start":370,"end":403,"spec":true,"focused":false,"pending":true,"nodes":[]},{"name":"PDescribeTable","text":"pending","start":406,"end":467,"spec":false,"focused":false,"pending":true,"nodes":[{"name":"Entry","text":"pending","start":447,"end":463,"spec":true,"focused":false,"pending":true,"nodes":[]}]},{"name":"DescribeTable","text":"pending","start":470,"end":531,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"PEntry","text":"pending","start":510,"end":527,"spec":true,"focused":false,"pending":true,"nodes":[]}]}]}] +[{"name":"Describe","text":"PendingFixture","start":73,"end":534,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"PDescribe","text":"pending","start":110,"end":207,"spec":false,"focused":false,"pending":true,"labels":[],"nodes":[{"name":"It","text":"pending","start":142,"end":203,"spec":true,"focused":false,"pending":true,"labels":[],"nodes":[{"name":"By","text":"pending","start":168,"end":181,"spec":false,"focused":false,"pending":true,"labels":null,"nodes":[]},{"name":"By","text":"pending","start":185,"end":198,"spec":false,"focused":false,"pending":true,"labels":null,"nodes":[]}]}]},{"name":"PContext","text":"pending","start":210,"end":273,"spec":false,"focused":false,"pending":true,"labels":[],"nodes":[{"name":"It","text":"pending","start":241,"end":269,"spec":true,"focused":false,"pending":true,"labels":[],"nodes":[]}]},{"name":"PWhen","text":"pending","start":276,"end":336,"spec":false,"focused":false,"pending":true,"labels":[],"nodes":[{"name":"It","text":"pending","start":304,"end":332,"spec":true,"focused":false,"pending":true,"labels":[],"nodes":[]}]},{"name":"PIt","text":"pending","start":339,"end":367,"spec":true,"focused":false,"pending":true,"labels":[],"nodes":[]},{"name":"PSpecify","text":"pending","start":370,"end":403,"spec":true,"focused":false,"pending":true,"labels":[],"nodes":[]},{"name":"PDescribeTable","text":"pending","start":406,"end":467,"spec":false,"focused":false,"pending":true,"labels":[],"nodes":[{"name":"Entry","text":"pending","start":447,"end":463,"spec":true,"focused":false,"pending":true,"labels":[],"nodes":[]}]},{"name":"DescribeTable","text":"pending","start":470,"end":531,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"PEntry","text":"pending","start":510,"end":527,"spec":true,"focused":false,"pending":true,"labels":[],"nodes":[]}]}]}] diff --git a/ginkgo/outline/_testdata/position_test.go.csv b/ginkgo/outline/_testdata/position_test.go.csv index 25c4e5549..1255bbefa 100644 --- a/ginkgo/outline/_testdata/position_test.go.csv +++ b/ginkgo/outline/_testdata/position_test.go.csv @@ -1,3 +1,3 @@ -Name,Text,Start,End,Spec,Focused,Pending -Describe,104,240,104,240,false,false,false -It,209,236,209,236,true,false,false +Name,Text,Start,End,Spec,Focused,Pending,Labels +Describe,104,240,104,240,false,false,false,"" +It,209,236,209,236,true,false,false,"" diff --git a/ginkgo/outline/_testdata/position_test.go.json b/ginkgo/outline/_testdata/position_test.go.json index a2fd587c5..06e06846a 100644 --- a/ginkgo/outline/_testdata/position_test.go.json +++ b/ginkgo/outline/_testdata/position_test.go.json @@ -1 +1 @@ -[{"name":"Describe","text":"104,240","start":104,"end":240,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"It","text":"209,236","start":209,"end":236,"spec":true,"focused":false,"pending":false,"nodes":[]}]}] +[{"name":"Describe","text":"104,240","start":104,"end":240,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"It","text":"209,236","start":209,"end":236,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[]}]}] diff --git a/ginkgo/outline/_testdata/suite_test.go.csv b/ginkgo/outline/_testdata/suite_test.go.csv index c85a82705..fe810ce3c 100644 --- a/ginkgo/outline/_testdata/suite_test.go.csv +++ b/ginkgo/outline/_testdata/suite_test.go.csv @@ -1 +1 @@ -Name,Text,Start,End,Spec,Focused,Pending +Name,Text,Start,End,Spec,Focused,Pending,Labels diff --git a/ginkgo/outline/ginkgo.go b/ginkgo/outline/ginkgo.go index c197bb686..0b9b19fe7 100644 --- a/ginkgo/outline/ginkgo.go +++ b/ginkgo/outline/ginkgo.go @@ -1,6 +1,7 @@ package outline import ( + "github.com/onsi/ginkgo/v2/types" "go/ast" "go/token" "strconv" @@ -25,9 +26,10 @@ type ginkgoMetadata struct { // End is the position of first character immediately after the spec or container block End int `json:"end"` - Spec bool `json:"spec"` - Focused bool `json:"focused"` - Pending bool `json:"pending"` + Spec bool `json:"spec"` + Focused bool `json:"focused"` + Pending bool `json:"pending"` + Labels []string `json:"labels"` } // ginkgoNode is used to construct the outline as a tree @@ -145,27 +147,35 @@ func ginkgoNodeFromCallExpr(fset *token.FileSet, ce *ast.CallExpr, ginkgoPackage case "It", "Specify", "Entry": n.Spec = true n.Text = textOrAltFromCallExpr(ce, undefinedTextAlt) + n.Labels = labelFromCallExpr(ce) + n.Pending = pendingFromCallExpr(ce) return &n, ginkgoPackageName != nil && *ginkgoPackageName == packageName case "FIt", "FSpecify", "FEntry": n.Spec = true n.Focused = true n.Text = textOrAltFromCallExpr(ce, undefinedTextAlt) + n.Labels = labelFromCallExpr(ce) return &n, ginkgoPackageName != nil && *ginkgoPackageName == packageName case "PIt", "PSpecify", "XIt", "XSpecify", "PEntry", "XEntry": n.Spec = true n.Pending = true n.Text = textOrAltFromCallExpr(ce, undefinedTextAlt) + n.Labels = labelFromCallExpr(ce) return &n, ginkgoPackageName != nil && *ginkgoPackageName == packageName case "Context", "Describe", "When", "DescribeTable": n.Text = textOrAltFromCallExpr(ce, undefinedTextAlt) + n.Labels = labelFromCallExpr(ce) + n.Pending = pendingFromCallExpr(ce) return &n, ginkgoPackageName != nil && *ginkgoPackageName == packageName case "FContext", "FDescribe", "FWhen", "FDescribeTable": n.Focused = true n.Text = textOrAltFromCallExpr(ce, undefinedTextAlt) + n.Labels = labelFromCallExpr(ce) return &n, ginkgoPackageName != nil && *ginkgoPackageName == packageName case "PContext", "PDescribe", "PWhen", "XContext", "XDescribe", "XWhen", "PDescribeTable", "XDescribeTable": n.Pending = true n.Text = textOrAltFromCallExpr(ce, undefinedTextAlt) + n.Labels = labelFromCallExpr(ce) return &n, ginkgoPackageName != nil && *ginkgoPackageName == packageName case "By": n.Text = textOrAltFromCallExpr(ce, undefinedTextAlt) @@ -216,3 +226,77 @@ func textFromCallExpr(ce *ast.CallExpr) (string, bool) { return text.Value, true } } + +func labelFromCallExpr(ce *ast.CallExpr) []string { + + labels := []string{} + if len(ce.Args) < 2 { + return labels + } + + for _, arg := range ce.Args[1:] { + switch expr := arg.(type) { + case *ast.CallExpr: + id, ok := expr.Fun.(*ast.Ident) + if !ok { + // to skip over cases where the expr.Fun. is actually *ast.SelectorExpr + continue + } + if id.Name == "Label" { + ls := extractLabels(expr) + for _, label := range ls { + labels = append(labels, label) + } + } + } + } + return labels +} + +func extractLabels(expr *ast.CallExpr) []string { + out := []string{} + for _, arg := range expr.Args { + switch expr := arg.(type) { + case *ast.BasicLit: + if expr.Kind == token.STRING { + unquoted, err := strconv.Unquote(expr.Value) + if err != nil { + unquoted = expr.Value + } + validated, err := types.ValidateAndCleanupLabel(unquoted, types.CodeLocation{}) + if err == nil { + out = append(out, validated) + } + } + } + } + + return out +} + +func pendingFromCallExpr(ce *ast.CallExpr) bool { + + pending := false + if len(ce.Args) < 2 { + return pending + } + + for _, arg := range ce.Args[1:] { + switch expr := arg.(type) { + case *ast.CallExpr: + id, ok := expr.Fun.(*ast.Ident) + if !ok { + // to skip over cases where the expr.Fun. is actually *ast.SelectorExpr + continue + } + if id.Name == "Pending" { + pending = true + } + case *ast.Ident: + if expr.Name == "Pending" { + pending = true + } + } + } + return pending +} diff --git a/ginkgo/outline/outline.go b/ginkgo/outline/outline.go index 4b45e7627..c2327cda8 100644 --- a/ginkgo/outline/outline.go +++ b/ginkgo/outline/outline.go @@ -85,12 +85,19 @@ func (o *outline) String() string { // one 'width' of spaces for every level of nesting. func (o *outline) StringIndent(width int) string { var b strings.Builder - b.WriteString("Name,Text,Start,End,Spec,Focused,Pending\n") + b.WriteString("Name,Text,Start,End,Spec,Focused,Pending,Labels\n") currentIndent := 0 pre := func(n *ginkgoNode) { b.WriteString(fmt.Sprintf("%*s", currentIndent, "")) - b.WriteString(fmt.Sprintf("%s,%s,%d,%d,%t,%t,%t\n", n.Name, n.Text, n.Start, n.End, n.Spec, n.Focused, n.Pending)) + var labels string + if len(n.Labels) == 1 { + labels = n.Labels[0] + } else { + labels = strings.Join(n.Labels, ", ") + } + //enclosing labels in a double quoted comma separate listed so that when inmported into a CSV app the Labels column has comma separate strings + b.WriteString(fmt.Sprintf("%s,%s,%d,%d,%t,%t,%t,\"%s\"\n", n.Name, n.Text, n.Start, n.End, n.Spec, n.Focused, n.Pending, labels)) currentIndent += width } post := func(n *ginkgoNode) { diff --git a/ginkgo/outline/outline_test.go b/ginkgo/outline/outline_test.go index 05e2a2090..f5ca9d0f6 100644 --- a/ginkgo/outline/outline_test.go +++ b/ginkgo/outline/outline_test.go @@ -60,6 +60,8 @@ var _ = DescribeTable("Validate outline from file with", Entry("specs used to verify position", "position_test.go", "position_test.go.json", "position_test.go.csv"), Entry("suite setup", "suite_test.go", "suite_test.go.json", "suite_test.go.csv"), Entry("core dsl import", "dsl_core_test.go", "dsl_core_test.go.json", "dsl_core_test.go.csv"), + Entry("labels decorator on containers and specs", "labels_test.go", "labels_test.go.json", "labels_test.go.csv"), + Entry("pending decorator on containers and specs", "pending_decorator_test.go", "pending_decorator_test.go.json", "pending_decorator_test.go.csv"), ) var _ = Describe("Validate position", func() {