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: decorator_dsl.go
+21Lines changed: 21 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -117,6 +117,27 @@ You can learn more here: https://onsi.github.io/ginkgo/#spec-semantic-version-fi
117
117
*/
118
118
typeSemVerConstraints= internal.SemVerConstraints
119
119
120
+
/*
121
+
ComponentSemVerConstraint decorates specs with ComponentSemVerConstraints. Multiple components semantic version constraints can be passed to ComponentSemVerConstraint and the component can't be empy, also the version strings must follow the semantic version constraint rules.
122
+
ComponentSemVerConstraints can be applied to container and subject nodes, but not setup nodes. You can provide multiple ComponentSemVerConstraints to a given node and a spec's component semantic version constraints is the union of all component semantic version constraints in its node hierarchy.
123
+
124
+
You can learn more here: https://onsi.github.io/ginkgo/#spec-semantic-version-filtering
125
+
You can learn more about decorators here: https://onsi.github.io/ginkgo/#decorator-reference
ComponentSemVerConstraints are the type for spec ComponentSemVerConstraint decorators. Use ComponentSemVerConstraint(...) to construct ComponentSemVerConstraints.
137
+
You can learn more here: https://onsi.github.io/ginkgo/#spec-semantic-version-filtering
Copy file name to clipboardExpand all lines: docs/index.md
+19-2Lines changed: 19 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2930,13 +2930,17 @@ Describe("Feature with version requirements", func() {
2930
2930
It("should work in a specific version range (1.0.0, 2.0.0)", SemVerConstraint("> 1.0.0", "< 2.0.0"), func() {
2931
2931
// This test will only run when version is between 1.0.0 (exclusive) and 2.0.0 (exclusive)
2932
2932
})
2933
+
2934
+
It("should work in a specific version range (1.0.0, 2.0.0) and third-party dependency redis in [8.0.0, ~)", SemVerConstraint(">= 3.2.0"), ComponentSemVerConstraint("redis", ">= 8.0.0") func() {
2935
+
// This test will only run when version is between 1.0.0 (exclusive) and 2.0.0 (exclusive) and redis version is >= 8.0.0
2936
+
})
2933
2937
})
2934
2938
```
2935
2939
2936
2940
You can then filter specs by providing a semantic version via the `--sem-ver-filter` flag:
2937
2941
2938
2942
```bash
2939
-
ginkgo --sem-ver-filter="2.1.1"
2943
+
ginkgo --sem-ver-filter="2.1.1, redis=8.2.0"
2940
2944
```
2941
2945
2942
2946
This will only run specs whose semantic version constraints are satisfied by the provided version.
@@ -2963,14 +2967,27 @@ Describe("Feature with version requirements", SemVerConstraint(">= 2.0.0, < 2.3.
2963
2967
It("should only run in a narrower range", SemVerConstraint(">= 2.1.0, <= 2.2.0"), func() {
2964
2968
// Effective constraint: >= 2.1.0, <= 2.2.0 (intersection with parent)
2965
2969
})
2970
+
2971
+
Context("should work in the base version range and third-party dependency", ComponentSemVerConstraint("redis", ">= 6.0.0"), func() {
2972
+
It("should run when both constraints are satisfied", func() {
2973
+
// Effective constraint: >= 2.0.0, < 2.3.0 and redis version >= 6.0.0
2974
+
})
2975
+
2976
+
It("should run in a narrower range with third-party dependency", ComponentSemVerConstraint("redis", ">= 7.0.0", "< 8.0.0"), func() {
2977
+
// Effective constraint: >= 2.0.0, < 2.3.0 and redis version >= 7.0.0, < 8.0.0
2978
+
})
2979
+
})
2966
2980
})
2967
2981
```
2968
2982
2969
2983
In this example, the second spec will only run when the version satisfies both the parent constraint (`>= 2.0.0, < 2.3.0`) and its own constraint (`>= 2.1.0, <= 2.2.0`), resulting in an effective constraint of `>= 2.1.0, <= 2.2.0`.
2984
+
Additionally, the specs within the `Context` will only run when both the parent constraint and the third-party dependency constraint are satisfied.
2985
+
2986
+
Note that while using `ComponentSemVerConstraint` decorator, the component name can not be empty.
2970
2987
2971
2988
##### Unconstrained Specs
2972
2989
2973
-
Specs that don't have a `SemVerConstraint` decorator are considered unconstrained and will always run when the `--sem-ver-filter` flag is provided. This allows you to have a mix of version-specific and version-agnostic tests in the same suite.
2990
+
Specs that don't have `SemVerConstraint` or `ComponentSemVerConstraint` decorator are considered unconstrained and will always run when the `--sem-ver-filter` flag is provided. This allows you to have a mix of version-specific and version-agnostic tests in the same suite.
Copy file name to clipboardExpand all lines: integration/_fixtures/semver_fixture/semver_test.go
+38Lines changed: 38 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,21 @@ var _ = Describe("Semantic Version Filtering", func() {
16
16
17
17
It("should run with version in range [2.0.0, 5.0.0)", SemVerConstraint(">= 2.0.0"), SemVerConstraint("< 5.0.0"), func() {})
18
18
19
+
It("should run with ComponentA in range [2.0.0, ~)", ComponentSemVerConstraint("ComponentA", ">= 2.0.0"), func() {})
20
+
21
+
It("should run with ComponentA in range [2.0.0, 3.0.0)", ComponentSemVerConstraint("ComponentA", ">= 2.0.0, < 3.0.0"), func() {})
22
+
23
+
It("should run with ComponentA in range [2.0.0, 4.0.0)", ComponentSemVerConstraint("ComponentA", ">= 2.0.0", "< 4.0.0"), func() {})
24
+
25
+
It("should run with ComponentA in range [2.0.0, 5.0.0)", ComponentSemVerConstraint("ComponentA", ">= 2.0.0"), ComponentSemVerConstraint("ComponentA", "< 5.0.0"), func() {})
26
+
27
+
It("should run with a mixed of component-specific and non-component constraints", SemVerConstraint(">= 2.0.0"), ComponentSemVerConstraint("ComponentA", ">= 2.0.0"), func() {})
28
+
19
29
It("shouldn't run with version in a conflict range", SemVerConstraint("2.0.0 - 6.0.0"), SemVerConstraint("<= 1.0.0"), func() {})
30
+
31
+
It("shouldn't run with ComponentA in a conflict range", ComponentSemVerConstraint("ComponentA", "2.0.0 - 6.0.0"), ComponentSemVerConstraint("ComponentA", "<= 1.0.0"), func() {})
32
+
33
+
It("shouldn't run with a mixed of component-specific and non-component conflict constraints", SemVerConstraint(">= 2.0.0"), ComponentSemVerConstraint("ComponentA", "<= 1.0.0"), func() {})
20
34
})
21
35
22
36
var_=Describe("Hierarchy Semantic Version Filtering", func() {
@@ -35,6 +49,27 @@ var _ = Describe("Hierarchy Semantic Version Filtering", func() {
It("should inherit container constraints and a new component-specific constraint", ComponentSemVerConstraint("ComponentB", ">= 0.1.0"), func() {})
72
+
})
38
73
})
39
74
40
75
var_=DescribeTable("Semantic Version Filtering in table-driven spec", func() {
@@ -43,4 +78,7 @@ var _ = DescribeTable("Semantic Version Filtering in table-driven spec", func()
43
78
Entry("should run without constraints by table driven"),
44
79
Entry("should run with version in range [2.0.0, ~) by table driven", SemVerConstraint(">= 2.0.0")),
45
80
Entry("shouldn't run with version in a conflict range by table driven", SemVerConstraint(">= 2.0.0"), SemVerConstraint("~1.2.3")),
81
+
Entry("should run with ComponentA in range [2.0.0, ~) by table driven", ComponentSemVerConstraint("ComponentA", ">= 2.0.0")),
82
+
Entry("shouldn't run with ComponentA in a conflict range by table driven", ComponentSemVerConstraint("ComponentA", ">= 2.0.0"), ComponentSemVerConstraint("ComponentA", "~1.2.3")),
83
+
Entry("should run with mixed constraints by table driven", SemVerConstraint(">= 2.0.0"), ComponentSemVerConstraint("ComponentA", ">= 2.0.0")),
0 commit comments