Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: onsi/ginkgo
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.16.1
Choose a base ref
...
head repository: onsi/ginkgo
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.16.2
Choose a head ref
  • 2 commits
  • 4 files changed
  • 1 contributor

Commits on May 4, 2021

  1. Verified

    This commit was signed with the committer’s verified signature.
    alexanderniebuhr Alexander Niebuhr
    Copy the full SHA
    5fbcace View commit details
  2. v1.16.2

    onsi committed May 4, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    084bfa8 View commit details
Showing with 62 additions and 1 deletion.
  1. +5 −0 CHANGELOG.md
  2. +1 −1 config/config.go
  3. +2 −0 ginkgo/run_command.go
  4. +54 −0 types/deprecation_support.go
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.16.2

### Fixes
- Deprecations can be suppressed by setting an `ACK_GINKGO_DEPRECATIONS=<semver>` environment variable.

## 1.16.1

### Fixes
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ import (
"fmt"
)

const VERSION = "1.16.1"
const VERSION = "1.16.2"

type GinkgoConfigType struct {
RandomSeed int64
2 changes: 2 additions & 0 deletions ginkgo/run_command.go
Original file line number Diff line number Diff line change
@@ -61,13 +61,15 @@ func (r *SpecRunner) RunSpecs(args []string, additionalArgs []string) {
deprecationTracker.TrackDeprecation(types.Deprecation{
Message: "--stream is deprecated and will be removed in Ginkgo 2.0",
DocLink: "removed--stream",
Version: "1.16.0",
})
}

if r.commandFlags.Notify {
deprecationTracker.TrackDeprecation(types.Deprecation{
Message: "--notify is deprecated and will be removed in Ginkgo 2.0",
DocLink: "removed--notify",
Version: "1.16.0",
})
}

54 changes: 54 additions & 0 deletions types/deprecation_support.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
package types

import (
"os"
"strconv"
"strings"
"unicode"

"github.com/onsi/ginkgo/config"
"github.com/onsi/ginkgo/formatter"
)

type Deprecation struct {
Message string
DocLink string
Version string
}

type deprecations struct{}
@@ -17,40 +24,46 @@ func (d deprecations) CustomReporter() Deprecation {
return Deprecation{
Message: "You are using a custom reporter. Support for custom reporters will likely be removed in V2. Most users were using them to generate junit or teamcity reports and this functionality will be merged into the core reporter. In addition, Ginkgo 2.0 will support emitting a JSON-formatted report that users can then manipulate to generate custom reports.\n\n{{red}}{{bold}}If this change will be impactful to you please leave a comment on {{cyan}}{{underline}}https://github.com/onsi/ginkgo/issues/711{{/}}",
DocLink: "removed-custom-reporters",
Version: "1.16.0",
}
}

func (d deprecations) V1Reporter() Deprecation {
return Deprecation{
Message: "You are using a V1 Ginkgo Reporter. Please update your custom reporter to the new V2 Reporter interface.",
DocLink: "changed-reporter-interface",
Version: "1.16.0",
}
}

func (d deprecations) Async() Deprecation {
return Deprecation{
Message: "You are passing a Done channel to a test node to test asynchronous behavior. This is deprecated in Ginkgo V2. Your test will run synchronously and the timeout will be ignored.",
DocLink: "removed-async-testing",
Version: "1.16.0",
}
}

func (d deprecations) Measure() Deprecation {
return Deprecation{
Message: "Measure is deprecated in Ginkgo V2",
DocLink: "removed-measure",
Version: "1.16.0",
}
}

func (d deprecations) Convert() Deprecation {
return Deprecation{
Message: "The convert command is deprecated in Ginkgo V2",
DocLink: "removed-ginkgo-convert",
Version: "1.16.0",
}
}

func (d deprecations) Blur() Deprecation {
return Deprecation{
Message: "The blur command is deprecated in Ginkgo V2. Use 'ginkgo unfocus' instead.",
Version: "1.16.0",
}
}

@@ -65,6 +78,15 @@ func NewDeprecationTracker() *DeprecationTracker {
}

func (d *DeprecationTracker) TrackDeprecation(deprecation Deprecation, cl ...CodeLocation) {
ackVersion := os.Getenv("ACK_GINKGO_DEPRECATIONS")
if deprecation.Version != "" && ackVersion != "" {
ack := ParseSemVer(ackVersion)
version := ParseSemVer(deprecation.Version)
if ack.GreaterThanOrEqualTo(version) {
return
}
}

if len(cl) == 1 {
d.deprecations[deprecation] = append(d.deprecations[deprecation], cl[0])
} else {
@@ -92,5 +114,37 @@ func (d *DeprecationTracker) DeprecationsReport() string {
out += formatter.Fi(2, "{{gray}}%s{{/}}\n", location)
}
}
out += formatter.F("\n{{gray}}To silence deprecations that can be silenced set the following environment variable:{{/}}\n")
out += formatter.Fi(1, "{{gray}}ACK_GINKGO_DEPRECATIONS=%s{{/}}\n", config.VERSION)
return out
}

type SemVer struct {
Major int
Minor int
Patch int
}

func (s SemVer) GreaterThanOrEqualTo(o SemVer) bool {
return (s.Major > o.Major) ||
(s.Major == o.Major && s.Minor > o.Minor) ||
(s.Major == o.Major && s.Minor == o.Minor && s.Patch >= o.Patch)
}

func ParseSemVer(semver string) SemVer {
out := SemVer{}
semver = strings.TrimFunc(semver, func(r rune) bool {
return !(unicode.IsNumber(r) || r == '.')
})
components := strings.Split(semver, ".")
if len(components) > 0 {
out.Major, _ = strconv.Atoi(components[0])
}
if len(components) > 1 {
out.Minor, _ = strconv.Atoi(components[1])
}
if len(components) > 2 {
out.Patch, _ = strconv.Atoi(components[2])
}
return out
}