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.15.2
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.0
Choose a head ref
  • 6 commits
  • 15 files changed
  • 4 contributors

Commits on Mar 17, 2021

  1. Fix accidental reference to 1488 (#784)

    Co-authored-by: Eli Sarver <elis@metrumrg.com>
    elisarver and Eli Sarver authored Mar 17, 2021
    Copy the full SHA
    9fb7fe4 View commit details

Commits on Mar 18, 2021

  1. Add slim-sprig template functions to bootstrap/generate (#775)

    * Add sprig template functions to bootstrap/generate
    
    * switch to slim-sprig
    hagaibarel authored Mar 18, 2021
    Copy the full SHA
    9162b86 View commit details

Commits on Apr 2, 2021

  1. Create FUNDING.yml

    onsi authored Apr 2, 2021
    Copy the full SHA
    455bccd View commit details

Commits on Apr 3, 2021

  1. Advertise Ginkgo 2.0. Introduce deprecations.

    - Update README.md to advertise that Ginkgo 2.0 is coming.
    - Backport the 2.0 DeprecationTracker and start alerting users
    about upcoming deprecations.
    onsi committed Apr 3, 2021
    Copy the full SHA
    9ef1913 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    5afe282 View commit details
  3. v1.16.0

    onsi committed Apr 3, 2021
    Copy the full SHA
    c10c6b6 View commit details
Showing with 464 additions and 9 deletions.
  1. +1 −0 .github/FUNDING.yml
  2. +13 −0 CHANGELOG.md
  3. +12 −0 README.md
  4. +1 −1 config/config.go
  5. +1 −1 example/books/book_test.go
  6. +190 −0 formatter/formatter.go
  7. +2 −1 ginkgo/bootstrap_command.go
  8. +6 −0 ginkgo/convert_command.go
  9. +3 −1 ginkgo/generate_command.go
  10. +21 −0 ginkgo/run_command.go
  11. +46 −3 ginkgo_dsl.go
  12. +1 −0 go.mod
  13. +11 −0 go.sum
  14. +60 −2 integration/subcommand_test.go
  15. +96 −0 types/deprecation_support.go
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [onsi]
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## 1.16.0

### Features
- Advertise Ginkgo 2.0. Introduce deprecations. [9ef1913]
- Update README.md to advertise that Ginkgo 2.0 is coming.
- Backport the 2.0 DeprecationTracker and start alerting users
about upcoming deprecations.

- Add slim-sprig template functions to bootstrap/generate (#775) [9162b86]

### Fixes
- Fix accidental reference to 1488 (#784) [9fb7fe4]

## 1.15.2

### Fixes
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -7,6 +7,18 @@ Jump to the [docs](https://onsi.github.io/ginkgo/) | [中文文档](https://ke-c

If you have a question, comment, bug report, feature request, etc. please open a GitHub issue, or visit the [Ginkgo Slack channel](https://app.slack.com/client/T029RQSE6/CQQ50BBNW).

# Ginkgo 2.0 is coming soon!

An effort is underway to develop and deliver Ginkgo 2.0. The work is happening in the [v2](https://github.com/onsi/ginkgo/tree/v2) branch and a changelog and migration guide is being maintained on that branch [here](https://github.com/onsi/ginkgo/blob/v2/docs/MIGRATING_TO_V2.md). Issue [#711](https://github.com/onsi/ginkgo/issues/711) is the central place for discussion and links to the original [proposal doc](https://docs.google.com/document/d/1h28ZknXRsTLPNNiOjdHIO-F2toCzq4xoZDXbfYaBdoQ/edit#).

As described in the [changelog](https://github.com/onsi/ginkgo/blob/v2/docs/MIGRATING_TO_V2.md) and [proposal](https://docs.google.com/document/d/1h28ZknXRsTLPNNiOjdHIO-F2toCzq4xoZDXbfYaBdoQ/edit#), Ginkgo 2.0 will clean up the Ginkgo codebase, deprecate and remove some v1 functionality, and add several new much-requested features. To help users get ready for the migration, Ginkgo v1 has started emitting deprecation warnings for features that will no longer be supported with links to documentation for how to migrate away from these features. If you have concerns or comments please chime in on [#711](https://github.com/onsi/ginkgo/issues/711).

The current timeline for completion of 2.0 looks like:

- Early April 2021: first public release of 2.0, deprecation warnings land in v1.
- May 2021: first beta/rc of 2.0 with most new functionality in place.
- June/July 2021: 2.0 ships and fully replaces the 1.x codebase on master.

## TLDR
Ginkgo builds on Go's `testing` package, allowing expressive [Behavior-Driven Development](https://en.wikipedia.org/wiki/Behavior-driven_development) ("BDD") style tests.
It is typically (and optionally) paired with the [Gomega](https://github.com/onsi/gomega) matcher library.
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.15.2"
const VERSION = "1.16.0"

type GinkgoConfigType struct {
RandomSeed int64
2 changes: 1 addition & 1 deletion example/books/book_test.go
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ var _ = Describe("Book", func() {
longBook = Book{
Title: "Les Miserables",
Author: "Victor Hugo",
Pages: 1488,
Pages: 2783,
}

shortBook = Book{
190 changes: 190 additions & 0 deletions formatter/formatter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
package formatter

import (
"fmt"
"regexp"
"strings"
)

const COLS = 80

type ColorMode uint8

const (
ColorModeNone ColorMode = iota
ColorModeTerminal
ColorModePassthrough
)

var SingletonFormatter = New(ColorModeTerminal)

func F(format string, args ...interface{}) string {
return SingletonFormatter.F(format, args...)
}

func Fi(indentation uint, format string, args ...interface{}) string {
return SingletonFormatter.Fi(indentation, format, args...)
}

func Fiw(indentation uint, maxWidth uint, format string, args ...interface{}) string {
return SingletonFormatter.Fiw(indentation, maxWidth, format, args...)
}

type Formatter struct {
ColorMode ColorMode
colors map[string]string
styleRe *regexp.Regexp
preserveColorStylingTags bool
}

func NewWithNoColorBool(noColor bool) Formatter {
if noColor {
return New(ColorModeNone)
}
return New(ColorModeTerminal)
}

func New(colorMode ColorMode) Formatter {
f := Formatter{
ColorMode: colorMode,
colors: map[string]string{
"/": "\x1b[0m",
"bold": "\x1b[1m",
"underline": "\x1b[4m",

"red": "\x1b[38;5;9m",
"orange": "\x1b[38;5;214m",
"coral": "\x1b[38;5;204m",
"magenta": "\x1b[38;5;13m",
"green": "\x1b[38;5;10m",
"dark-green": "\x1b[38;5;28m",
"yellow": "\x1b[38;5;11m",
"light-yellow": "\x1b[38;5;228m",
"cyan": "\x1b[38;5;14m",
"gray": "\x1b[38;5;243m",
"light-gray": "\x1b[38;5;246m",
"blue": "\x1b[38;5;12m",
},
}
colors := []string{}
for color := range f.colors {
colors = append(colors, color)
}
f.styleRe = regexp.MustCompile("{{(" + strings.Join(colors, "|") + ")}}")
return f
}

func (f Formatter) F(format string, args ...interface{}) string {
return f.Fi(0, format, args...)
}

func (f Formatter) Fi(indentation uint, format string, args ...interface{}) string {
return f.Fiw(indentation, 0, format, args...)
}

func (f Formatter) Fiw(indentation uint, maxWidth uint, format string, args ...interface{}) string {
out := fmt.Sprintf(f.style(format), args...)

if indentation == 0 && maxWidth == 0 {
return out
}

lines := strings.Split(out, "\n")

if maxWidth != 0 {
outLines := []string{}

maxWidth = maxWidth - indentation*2
for _, line := range lines {
if f.length(line) <= maxWidth {
outLines = append(outLines, line)
continue
}
outWords := []string{}
length := uint(0)
words := strings.Split(line, " ")
for _, word := range words {
wordLength := f.length(word)
if length+wordLength <= maxWidth {
length += wordLength
outWords = append(outWords, word)
continue
}
outLines = append(outLines, strings.Join(outWords, " "))
outWords = []string{word}
length = wordLength
}
if len(outWords) > 0 {
outLines = append(outLines, strings.Join(outWords, " "))
}
}

lines = outLines
}

if indentation == 0 {
return strings.Join(lines, "\n")
}

padding := strings.Repeat(" ", int(indentation))
for i := range lines {
if lines[i] != "" {
lines[i] = padding + lines[i]
}
}

return strings.Join(lines, "\n")
}

func (f Formatter) length(styled string) uint {
n := uint(0)
inStyle := false
for _, b := range styled {
if inStyle {
if b == 'm' {
inStyle = false
}
continue
}
if b == '\x1b' {
inStyle = true
continue
}
n += 1
}
return n
}

func (f Formatter) CycleJoin(elements []string, joiner string, cycle []string) string {
if len(elements) == 0 {
return ""
}
n := len(cycle)
out := ""
for i, text := range elements {
out += cycle[i%n] + text
if i < len(elements)-1 {
out += joiner
}
}
out += "{{/}}"
return f.style(out)
}

func (f Formatter) style(s string) string {
switch f.ColorMode {
case ColorModeNone:
return f.styleRe.ReplaceAllString(s, "")
case ColorModePassthrough:
return s
case ColorModeTerminal:
return f.styleRe.ReplaceAllStringFunc(s, func(match string) string {
if out, ok := f.colors[strings.Trim(match, "{}")]; ok {
return out
}
return match
})
}

return ""
}
3 changes: 2 additions & 1 deletion ginkgo/bootstrap_command.go
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ import (

"go/build"

sprig "github.com/go-task/slim-sprig"
"github.com/onsi/ginkgo/ginkgo/nodot"
)

@@ -176,7 +177,7 @@ func generateBootstrap(agouti, noDot, internal bool, customBootstrapFile string)
templateText = bootstrapText
}

bootstrapTemplate, err := template.New("bootstrap").Parse(templateText)
bootstrapTemplate, err := template.New("bootstrap").Funcs(sprig.TxtFuncMap()).Parse(templateText)
if err != nil {
panic(err.Error())
}
6 changes: 6 additions & 0 deletions ginkgo/convert_command.go
Original file line number Diff line number Diff line change
@@ -6,6 +6,8 @@ import (
"os"

"github.com/onsi/ginkgo/ginkgo/convert"
colorable "github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable"
"github.com/onsi/ginkgo/types"
)

func BuildConvertCommand() *Command {
@@ -21,6 +23,10 @@ func BuildConvertCommand() *Command {
}

func convertPackage(args []string, additionalArgs []string) {
deprecationTracker := types.NewDeprecationTracker()
deprecationTracker.TrackDeprecation(types.Deprecations.Convert())
fmt.Fprintln(colorable.NewColorableStderr(), deprecationTracker.DeprecationsReport())

if len(args) != 1 {
println(fmt.Sprintf("usage: ginkgo convert /path/to/your/package"))
os.Exit(1)
4 changes: 3 additions & 1 deletion ginkgo/generate_command.go
Original file line number Diff line number Diff line change
@@ -10,6 +10,8 @@ import (
"strconv"
"strings"
"text/template"

sprig "github.com/go-task/slim-sprig"
)

func BuildGenerateCommand() *Command {
@@ -157,7 +159,7 @@ func generateSpecForSubject(subject string, agouti, noDot, internal bool, custom
templateText = specText
}

specTemplate, err := template.New("spec").Parse(templateText)
specTemplate, err := template.New("spec").Funcs(sprig.TxtFuncMap()).Parse(templateText)
if err != nil {
return err
}
21 changes: 21 additions & 0 deletions ginkgo/run_command.go
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ import (
"github.com/onsi/ginkgo/config"
"github.com/onsi/ginkgo/ginkgo/interrupthandler"
"github.com/onsi/ginkgo/ginkgo/testrunner"
colorable "github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable"
"github.com/onsi/ginkgo/types"
)

@@ -53,6 +54,26 @@ func (r *SpecRunner) RunSpecs(args []string, additionalArgs []string) {
r.commandFlags.computeNodes()
r.notifier.VerifyNotificationsAreAvailable()

deprecationTracker := types.NewDeprecationTracker()

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

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

if deprecationTracker.DidTrackDeprecations() {
fmt.Fprintln(colorable.NewColorableStderr(), deprecationTracker.DeprecationsReport())
}

suites, skippedPackages := findSuites(args, r.commandFlags.Recurse, r.commandFlags.SkipPackage, true)
if len(skippedPackages) > 0 {
fmt.Println("Will skip:")
Loading