-
-
Notifications
You must be signed in to change notification settings - Fork 650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds 'outline' command to print the outline of specs/containers in a file #754
Conversation
…file Implements feature request in onsi#753
First CI run failed all jobs, because I hadn't run Second CI run failed just the "tip" job, because that version of |
Third CI run failed just the "tip" job. Looks unrelated to my changes:
|
Thanks @dlipovetsky - this is super exciting! I'll take a look in the next few days. I suspect the integration test is flaky (possibly because of a change in go tip, but more likely it's just flakey and the travis worker it was on was slow). |
…its ginkgo metadata The post-order traversal needs to check whether the AST Node is a ginkgo node. That can be done by comparing the positions of the AST Node and the last visited ginkgo node. Deriving the ginkgo metadata is not necessary.
…us/pending properties
…t results To make it easier to maintain the outline tests.
The content has not changed; only the JSON formatting and the filenames have changed.
The top-level function needed to be shorter.
Again, the top-level function needed to be shorter.
Keep the unexprted ginkgoNode code in a separate file.
…e in outline An advantage of embedding is that it does not require casting. The outline receivers does not change.
The "text" was being ignored by mistake.
The test and its result samples were already present, but the test was not run.
This is really just for fun. Here's an example: ``shell ginkgo outline -format=indent outline/_testdata/normal_test.go ``` ```shell Name,Text,Start,End,Spec,Focused,Pending Describe,NormalFixture,116,605,false,false,false Describe,normal,152,244,false,false,false It,normal,182,240,true,false,false By,step 1,207,219,false,false,false By,step 2,223,235,false,false,false Context,normal,247,307,false,false,false It,normal,276,303,true,false,false When,normal,310,367,false,false,false It,normal,336,363,true,false,false It,normal,370,396,true,false,false Specify,normal,399,430,true,false,false Measure,normal,433,480,true,false,false ``` It also happens to look nice piped through `column`: ```shell ginkgo outline -format=indent outline/_testdata/normal_test.go | column --table -s="," ``` ``` Name Text Start End Spec Focused Pending Describe NormalFixture 116 605 false false false Describe normal 152 244 false false false It normal 182 240 true false false By step 1 207 219 false false false By step 2 223 235 false false false Context normal 247 307 false false false It normal 276 303 true false false When normal 310 367 false false false It normal 336 363 true false false It normal 370 396 true false false Specify normal 399 430 true false false Measure normal 433 480 true false false ```
@@ -0,0 +1,61 @@ | |||
// Copyright 2013 The Go Authors. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if you see any problem with copy/pasting upstream code here. I've kept the upstream license, and noted the source commit.
// > leaf-node is marked focused, any of its ancestor nodes that are marked | ||
// > focus will be unfocused. | ||
func (n *ginkgoNode) BackpropagateUnfocus() { | ||
focusedSpecInSubtreeStack := []bool{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is hard to understand. I need to add some explanatory comments, and probably a unit test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the whole back propagate thing is intrinsically complex! thanks for making this work!!
if !ok { | ||
// Because `Nodes` calls this function only when the node is an | ||
// ast.CallExpr, this should never happen | ||
panic(fmt.Errorf("node starting at %d, ending at %d is not an *ast.CallExpr", node.Pos(), node.End())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if panicking is the only option. This is supposed to be impossible to reach.
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered moving this to a ginkgoNode.String()
receiver, but because most of the work is "opinionated" formatting, I thought it best not to put it there.
@dlipovetsky this is amazing, thanks so much! I'm going to merge this in. Would you be up for updating the documentation on the I may do a bit of clean-up and move the tests over to the integration test suite. But I didn't want to delay so am pulling this in now! Thanks so much!! |
Will do!
That sounds right. Thanks! |
The `ginkgo outline` command was added in onsi#754.
The `ginkgo outline` command was added in #754.
Why this PR is needed:
Implements feature request in #753.
Please see the test fixtures for example CSV and JSON output.
Special notes:
There are a couple of TODOs in the code, and I'll call them out here: