You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/index.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -2597,8 +2597,8 @@ These mechanisms can all be used in concert. They combine with the following ru
2597
2597
2598
2598
-`Pending` specs are always pending and can never be coerced to run by another filtering mechanism.
2599
2599
- Specs that invoke `Skip()` will always be skipped regardless of other filtering mechanisms.
2600
-
-The CLI based filters (`--label-filter`, `--focus-file/--skip-file`, `--focus/--skip`) **always** override any programmatic focus.
2601
-
- When multiple CLI filters are provided they are all ANDed together. The spec must satisfy the label filter query **and** any location-based filters **and** any description based filters.
2600
+
-Programmatic filters always apply and result in a non-zero exit code. Any additional CLI filters only apply to the subset of specs selected by the programmatic filters.
2601
+
- When multiple CLI filters (`--label-filter`, `--focus-file/--skip-file`, `--focus/--skip`) are provided they are all ANDed together. The spec must satisfy the label filter query **and** any location-based filters **and** any description based filters.
Copy file name to clipboardExpand all lines: internal/focus.go
+34-37
Original file line number
Diff line number
Diff line change
@@ -8,22 +8,22 @@ import (
8
8
)
9
9
10
10
/*
11
-
If a container marked as focus has a descendant that is also marked as focus, Ginkgo's policy is to
12
-
unmark the container's focus. This gives developers a more intuitive experience when debugging specs.
13
-
It is common to focus a container to just run a subset of specs, then identify the specific specs within the container to focus -
14
-
this policy allows the developer to simply focus those specific specs and not need to go back and turn the focus off of the container:
15
-
16
-
As a common example, consider:
17
-
18
-
FDescribe("something to debug", function() {
19
-
It("works", function() {...})
20
-
It("works", function() {...})
21
-
FIt("doesn't work", function() {...})
22
-
It("works", function() {...})
23
-
})
24
-
25
-
here the developer's intent is to focus in on the `"doesn't work"` spec and not to run the adjacent specs in the focused `"something to debug"` container.
26
-
The nested policy applied by this function enables this behavior.
11
+
If a container marked as focus has a descendant that is also marked as focus, Ginkgo's policy is to
12
+
unmark the container's focus. This gives developers a more intuitive experience when debugging specs.
13
+
It is common to focus a container to just run a subset of specs, then identify the specific specs within the container to focus -
14
+
this policy allows the developer to simply focus those specific specs and not need to go back and turn the focus off of the container:
15
+
16
+
As a common example, consider:
17
+
18
+
FDescribe("something to debug", function() {
19
+
It("works", function() {...})
20
+
It("works", function() {...})
21
+
FIt("doesn't work", function() {...})
22
+
It("works", function() {...})
23
+
})
24
+
25
+
here the developer's intent is to focus in on the `"doesn't work"` spec and not to run the adjacent specs in the focused `"something to debug"` container.
26
+
The nested policy applied by this function enables this behavior.
Ginkgo supports focussing specs using `FIt`, `FDescribe`, etc. - this is called "programmatic focus"
48
-
It also supports focussing specs using regular expressions on the command line (`-focus=`, `-skip=`) that match against spec text
49
-
and file filters (`-focus-files=`, `-skip-files=`) that match against code locations for nodes in specs.
47
+
Ginkgo supports focussing specs using `FIt`, `FDescribe`, etc. - this is called "programmatic focus"
48
+
It also supports focussing specs using regular expressions on the command line (`-focus=`, `-skip=`) that match against spec text and file filters (`-focus-files=`, `-skip-files=`) that match against code locations for nodes in specs.
50
49
51
-
If any of the CLI flags are provided they take precedence. The file filters run first followed by the regex filters.
50
+
When both programmatic and file filters are provided their results are ANDed together. If multiple kinds of filters are provided, the file filters run first followed by the regex filters.
52
51
53
-
This function sets the `Skip` property on specs by applying Ginkgo's focus policy:
54
-
- If there are no CLI arguments and no programmatic focus, do nothing.
55
-
- If there are no CLI arguments but a spec somewhere has programmatic focus, skip any specs that have no programmatic focus.
56
-
- If there are CLI arguments parse them and skip any specs that either don't match the focus filters or do match the skip filters.
52
+
This function sets the `Skip` property on specs by applying Ginkgo's focus policy:
53
+
- If there are no CLI arguments and no programmatic focus, do nothing.
54
+
- If a spec somewhere has programmatic focus skip any specs that have no programmatic focus.
55
+
- If there are CLI arguments parse them and skip any specs that either don't match the focus filters or do match the skip filters.
57
56
58
-
*Note:* specs with pending nodes are Skipped when created by NewSpec.
57
+
*Note:* specs with pending nodes are Skipped when created by NewSpec.
S(N(ntCon, Label("cow")), N(ntIt, "D", Label("fish"))), //skip because fish
244
244
S(N(ntCon, Label("cow")), N(ntIt, "E")), //include because cow and no fish
245
245
S(N(ntCon, Label("cow")), N(ntIt, "F", Pending)), //skip because pending
246
246
}
@@ -277,7 +277,7 @@ var _ = Describe("Focus", func() {
277
277
S(N("dog cat", CL("file_b", 3, "file_b", 15), Label("brown"))), //skip because "file_:15-21" is in FocusFiles but "cat" is in SkipStirngs
278
278
S(N("fish", CL("file_b", 17), Label("brown"))), //skip because "_b:17" is in SkipFiles, even though "fish" is in FocusStrings
279
279
S(N("biscuit", CL("file_b", 20), Pending, Label("brown"))), //skip because spec is flagged pending
280
-
S(N("pony", CL("c", 3), Focus, Label("brown"))), //skip because "c" is not in FocusFiles or FocusStrings - override programmatic focus
280
+
S(N("pony", CL("c", 3), Label("brown"))), //skip because "c" is not in FocusFiles or FocusStrings
281
281
S(N("goat", CL("d", 17), Label("brown"))), //skip because "goat" is in FocusStrings but "d" is not in FocusFiles
282
282
}
283
283
@@ -294,5 +294,32 @@ var _ = Describe("Focus", func() {
294
294
Ω(hasProgrammaticFocus).Should(BeFalse())
295
295
})
296
296
})
297
+
298
+
Context("when configured with focus/skip files, focus/skip strings, and label filters and there is a programmatic focus", func() {
299
+
BeforeEach(func() {
300
+
specs=Specs{
301
+
S(N("dog", CL("file_a", 1), Label("brown"))), //skip because "file_:1" is in FocusFiles and "dog" is in FocusStrings and has "brown" label but a different spec has a programmatic focus
302
+
S(N("dog", CL("file_a", 17), Label("brown"), Focus)), //include because "file_:15-21" is in FocusFiles and "dog" is in FocusStrings and has "brown" label
303
+
S(N("dog", CL("file_a", 1), Label("white"), Focus)), //skip because does not have "brown" label
304
+
S(N("dog cat", CL("file_b", 3, "file_b", 15), Label("brown"))), //skip because "file_:15-21" is in FocusFiles but "cat" is in SkipStirngs
305
+
S(N("fish", CL("file_b", 17), Label("brown"))), //skip because "_b:17" is in SkipFiles, even though "fish" is in FocusStrings
306
+
S(N("biscuit", CL("file_b", 20), Pending, Label("brown"))), //skip because spec is flagged pending
307
+
S(N("pony", CL("c", 3), Label("brown"))), //skip because "c" is not in FocusFiles or FocusStrings
308
+
S(N("goat", CL("d", 17), Label("brown"))), //skip because "goat" is in FocusStrings but "d" is not in FocusFiles
0 commit comments