Skip to content

Commit

Permalink
Adds 'outline' command to print the outline of specs/containers in a …
Browse files Browse the repository at this point in the history
…file

Implements feature request in #753
  • Loading branch information
dlipovetsky committed Dec 26, 2020
1 parent f9457b0 commit 3be1637
Show file tree
Hide file tree
Showing 18 changed files with 849 additions and 6 deletions.
6 changes: 6 additions & 0 deletions ginkgo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ will output an executable file named `package.test`. This can be run directly o
ginkgo <path-to-package.test>
To print an outline of Ginkgo specs and containers in a file:
gingko outline <filename>
To print out Ginkgo's version:
ginkgo version
Expand Down Expand Up @@ -172,6 +177,7 @@ func init() {
Commands = append(Commands, BuildUnfocusCommand())
Commands = append(Commands, BuildVersionCommand())
Commands = append(Commands, BuildHelpCommand())
Commands = append(Commands, BuildOutlineCommand())
}

func main() {
Expand Down
48 changes: 48 additions & 0 deletions ginkgo/outline/_testdata/focused_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package example_test

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
)

var _ = Describe("FocusedFixture", func() {
FDescribe("focused", func() {
It("focused", func() {

})
})

FContext("focused", func() {
It("focused", func() {

})
})

FWhen("focused", func() {
It("focused", func() {

})
})

FIt("focused", func() {

})

FSpecify("focused", func() {

})

FMeasure("focused", func(b Benchmarker) {

}, 2)

FDescribeTable("focused",
func() {},
Entry("focused"),
)

DescribeTable("focused",
func() {},
FEntry("focused"),
)
})
11 changes: 11 additions & 0 deletions ginkgo/outline/_testdata/focused_test_outline.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Name,Text,Start,End,Spec,Focused,Pending
Describe,FocusedFixture,116,596,false,false,false
FDescribe,focused,153,217,false,true,false
It,focused,185,213,true,false,false
FContext,focused,220,283,false,true,false
It,focused,251,279,true,false,false
FWhen,focused,286,346,false,true,false
It,focused,314,342,true,false,false
FIt,focused,349,377,true,true,false
FSpecify,focused,380,413,true,true,false
FMeasure,focused,416,465,true,true,false
100 changes: 100 additions & 0 deletions ginkgo/outline/_testdata/focused_test_outline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
[
{
"name": "Describe",
"text": "FocusedFixture",
"start": 116,
"end": 596,
"spec": false,
"focused": false,
"pending": false,
"nodes": [
{
"name": "FDescribe",
"text": "focused",
"start": 153,
"end": 217,
"spec": false,
"focused": true,
"pending": false,
"nodes": [
{
"name": "It",
"text": "focused",
"start": 185,
"end": 213,
"spec": true,
"focused": false,
"pending": false
}
]
},
{
"name": "FContext",
"text": "focused",
"start": 220,
"end": 283,
"spec": false,
"focused": true,
"pending": false,
"nodes": [
{
"name": "It",
"text": "focused",
"start": 251,
"end": 279,
"spec": true,
"focused": false,
"pending": false
}
]
},
{
"name": "FWhen",
"text": "focused",
"start": 286,
"end": 346,
"spec": false,
"focused": true,
"pending": false,
"nodes": [
{
"name": "It",
"text": "focused",
"start": 314,
"end": 342,
"spec": true,
"focused": false,
"pending": false
}
]
},
{
"name": "FIt",
"text": "focused",
"start": 349,
"end": 377,
"spec": true,
"focused": true,
"pending": false
},
{
"name": "FSpecify",
"text": "focused",
"start": 380,
"end": 413,
"spec": true,
"focused": true,
"pending": false
},
{
"name": "FMeasure",
"text": "focused",
"start": 416,
"end": 465,
"spec": true,
"focused": true,
"pending": false
}
]
}
]
48 changes: 48 additions & 0 deletions ginkgo/outline/_testdata/normal_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package example_test

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
)

var _ = Describe("NormalFixture", func() {
Describe("normal", func() {
It("normal", func() {

})
})

Context("normal", func() {
It("normal", func() {

})
})

When("normal", func() {
It("normal", func() {

})
})

It("normal", func() {

})

Specify("normal", func() {

})

Measure("normal", func(b Benchmarker) {

}, 2)

DescribeTable("normal",
func() {},
Entry("normal"),
)

DescribeTable("normal",
func() {},
Entry("normal"),
)
})
11 changes: 11 additions & 0 deletions ginkgo/outline/_testdata/normal_test_outline.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Name,Text,Start,End,Spec,Focused,Pending
Describe,NormalFixture,116,574,false,false,false
Describe,normal,152,213,false,false,false
It,normal,182,209,true,false,false
Context,normal,216,276,false,false,false
It,normal,245,272,true,false,false
When,normal,279,336,false,false,false
It,normal,305,332,true,false,false
It,normal,339,365,true,false,false
Specify,normal,368,399,true,false,false
Measure,normal,402,449,true,false,false
100 changes: 100 additions & 0 deletions ginkgo/outline/_testdata/normal_test_outline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
[
{
"name": "Describe",
"text": "NormalFixture",
"start": 116,
"end": 574,
"spec": false,
"focused": false,
"pending": false,
"nodes": [
{
"name": "Describe",
"text": "normal",
"start": 152,
"end": 213,
"spec": false,
"focused": false,
"pending": false,
"nodes": [
{
"name": "It",
"text": "normal",
"start": 182,
"end": 209,
"spec": true,
"focused": false,
"pending": false
}
]
},
{
"name": "Context",
"text": "normal",
"start": 216,
"end": 276,
"spec": false,
"focused": false,
"pending": false,
"nodes": [
{
"name": "It",
"text": "normal",
"start": 245,
"end": 272,
"spec": true,
"focused": false,
"pending": false
}
]
},
{
"name": "When",
"text": "normal",
"start": 279,
"end": 336,
"spec": false,
"focused": false,
"pending": false,
"nodes": [
{
"name": "It",
"text": "normal",
"start": 305,
"end": 332,
"spec": true,
"focused": false,
"pending": false
}
]
},
{
"name": "It",
"text": "normal",
"start": 339,
"end": 365,
"spec": true,
"focused": false,
"pending": false
},
{
"name": "Specify",
"text": "normal",
"start": 368,
"end": 399,
"spec": true,
"focused": false,
"pending": false
},
{
"name": "Measure",
"text": "normal",
"start": 402,
"end": 449,
"spec": true,
"focused": false,
"pending": false
}
]
}
]
48 changes: 48 additions & 0 deletions ginkgo/outline/_testdata/pending_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package example_test

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
)

var _ = Describe("PendingFixture", func() {
PDescribe("pending", func() {
It("pending", func() {

})
})

PContext("pending", func() {
It("pending", func() {

})
})

PWhen("pending", func() {
It("pending", func() {

})
})

PIt("pending", func() {

})

PSpecify("pending", func() {

})

PMeasure("pending", func(b Benchmarker) {

}, 2)

PDescribeTable("pending",
func() {},
Entry("pending"),
)

DescribeTable("pending",
func() {},
PEntry("pending"),
)
})
Loading

0 comments on commit 3be1637

Please sign in to comment.