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.14.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.15.0
Choose a head ref
  • 17 commits
  • 58 files changed
  • 8 contributors

Commits on Oct 13, 2020

  1. chore: update go.sum to fix Travis CI

    In CI we run `go mod tidy` and check that it hasn't changed `go.sum` in
    order to check that we haven't comitted an "untidy" file. It seems that
    Go 1.14 (in development) does some extra tidying of `go.sum` which is
    backwards compatible with Go 1.13 and Go 1.12. Because of this backwards
    compatability, it feels safe to commit this. If changes are made in
    future that are not backwards compatible, then we should just run this
    check on the lowest compatible version of Go.
    blgm committed Oct 13, 2020
    Copy the full SHA
    dfe3698 View commit details

Commits on Dec 8, 2020

  1. Create codeql-analysis.yml

    onsi authored Dec 8, 2020
    Copy the full SHA
    adac43d View commit details

Commits on Dec 12, 2020

  1. Copy the full SHA
    43c12da View commit details

Commits on Dec 15, 2020

  1. Add support for using template to generate tests (#752)

    * Add support for using template to generate tests
    
    Fixes #749
    
    * Add unit test
    
    * Fix test - package is foo_bar
    
    * Fix integration test
    
    For Test templates, the import path for the package being tests was
    incorrect. Updating to check for a string that ends with the package
    name.
    Kevin S Kirkup authored Dec 15, 2020
    Copy the full SHA
    efb9e69 View commit details

Commits on Dec 22, 2020

  1. travis: use supported Go versions (1.14+)

    Go 1.15 was released in August 2020, let's use it for testing.
    
    Go 1.13 is no longer supported since Go 1.15 is released, so remove it.
    
    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin authored and williammartin committed Dec 22, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    bb85580 View commit details
  2. travis: simplify check for go mod tidy-ness

    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin authored and williammartin committed Dec 22, 2020
    Copy the full SHA
    d44a343 View commit details
  3. travis: simplify

    - use $GOPATH instead of $HOME/gopath;
    - put $GOPATH/bin first so we don't have to explicitly
      specify the path when calling ginkgo;
    
    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin authored and williammartin committed Dec 22, 2020
    Copy the full SHA
    487ea8f View commit details
  4. travis: separate go vet, put it first

    Since go vet is much quicker than running tests, call it first
    (no sense in doing further tests if it fails).
    
    Also, put it to a separate line, as the travis output is more
    comprehensible this way.
    
    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin authored and williammartin committed Dec 22, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    f9457b0 View commit details

Commits on Dec 30, 2020

  1. Adds 'outline' command to print the outline of specs/containers in a …

    …file (#754)
    
    * Adds 'outline' command to print the outline of specs/containers in a file
    
    Implements feature request in #753
    
    * outline: Add support for nodot and alias import of the ginkgo package
    
    * outline: During a post-order traversal of an AST Node, do not derive 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.
    
    * outline: Add backpropagation of unfocus, propagation of inherited focus/pending properties
    
    * outline: Add instructions and script for creating/updating sample test results
    
    To make it easier to maintain the outline tests.
    
    * outline: Use script to re-create result samples for all tests
    
    The content has not changed; only the JSON formatting and the filenames have
    changed.
    
    * outline: Factor the back/propagation code to helper functions
    
    The top-level function needed to be shorter.
    
    * outline: Refactor deriving ginkgo identifier from call expression
    
    Again, the top-level function needed to be shorter.
    
    * outline: Move the exported outline code into its own file
    
    Keep the unexprted ginkgoNode code in a separate file.
    
    * outline: Instead of aliasing ginkgoNode with outline, embed ginkgoNode in outline
    
    An advantage of embedding is that it does not require casting. The outline
    receivers does not change.
    
    * outline: (fix) Derive the "text" of the By ginkgo call
    
    The "text" was being ignored by mistake.
    
    * outline: Test an outline of a "suite_test.go" file
    
    The test and its result samples were already present, but the test was not run.
    
    * outline: Add "indent" format
    
    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
    ```
    dlipovetsky authored Dec 30, 2020
    Copy the full SHA
    071c369 View commit details

Commits on Jan 3, 2021

  1. outline: Add support for "table" extension containers and specs (#758)

    * outline: Do not embed ginkgoNode in the outline struct
    
    Although the outline struct did embed the ginkgoNode struct, I think embedding
    does not make sense: The outline struct only needs a `Nodes` field, and does
    not use the other fields of the ginkgoNode struct.
    
    * outline: Import table extension in alias and nodot tests
    
    Although the table extension isn't supported by outline, the import was left
    out by mistake.
    
    * outline: Refactor package name comparison
    
    * outline: Add support for "table" extension containers and specs
    dlipovetsky authored Jan 3, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    6803cc3 View commit details

Commits on Jan 11, 2021

  1. outline: Make reading source from stdin uniform across operating syst…

    …ems (#760)
    
    * outline: Make reading source from stdin uniform across operating systems
    
    Let's say that there is an IDE plugin that calls `gingko outline`. It will
    likely pipe the document contents via stdin. And the IDE will likely run on
    multiple operating systems. With the `-` alias for stdin, the plugin can use
    the same ginkgo command on every operating system. This alias is common, but
    not ubiquituous. Users can continue to use operating system-specific filenames
    for stdin.
    
    Example:
    
    ```shell
    > cat outline/_testdata/normal_test.go | ./ginkgo outline -format=indent -
    ```
    
    ```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
        DescribeTable,normal,483,541,false,false,false
            Entry,normal,522,537,true,false,false
        DescribeTable,normal,544,602,false,false,false
            Entry,normal,583,598,true,false,false
    ```
    
    * outline: Remove duplicate definition of the short usage message
    dlipovetsky authored Jan 11, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    935b538 View commit details
  2. Add a Chinese Doc #755 (#756)

    * Update README.md
    
    add a Chinese Version Doc
    
    * Update README.md
    
    add "|"  between "doc" and "中文文档"
    ke-chain authored Jan 11, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    Wirone Greg Korba
    Copy the full SHA
    5207632 View commit details
  3. cli: allow multiple -focus and -skip flags (#736)

    As an example, now instead of
    
    	... --skip one|two|three|four ...
    
    one can specify
    
    	... \
    	--skip one \
    	--skip two \
    	--skip three \
    	--skip four \
    	...
    
    which helps readability and maintainability a lot in case there are many
    tests to skip.
    
    Fixes #735
    
    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin authored Jan 11, 2021
    Copy the full SHA
    9a782fb View commit details

Commits on Jan 18, 2021

  1. Copy the full SHA
    06744e8 View commit details

Commits on Jan 19, 2021

  1. Copy the full SHA
    0c40583 View commit details
  2. internal/remote: use unix.Dup2 instead of wrapping Dup2/Dup3 manually (

    …#761)
    
    The latest version of the golang.org/x/sys/unix package already
    implements func Dup2 using Dup3 on platforms which dont have the dup2
    syscall. Use Dup2 and let x/sys/unix figure out the correct syscall.
    
    This effectivly reverts PR #680. Verified that ginkgo still correctly
    builds on linux/mips64le.
    tklauser authored Jan 19, 2021
    Copy the full SHA
    c2b0e16 View commit details

Commits on Feb 1, 2021

  1. v1.15.0

    blgm committed Feb 1, 2021
    Copy the full SHA
    c75f46e View commit details
Showing with 1,369 additions and 160 deletions.
  1. +67 −0 .github/workflows/codeql-analysis.yml
  2. +5 −6 .travis.yml
  3. +11 −0 CHANGELOG.md
  4. +1 −1 README.md
  5. +24 −9 config/config.go
  6. +22 −7 ginkgo/generate_command.go
  7. +6 −0 ginkgo/main.go
  8. +50 −0 ginkgo/outline/_testdata/alias_test.go
  9. +17 −0 ginkgo/outline/_testdata/alias_test.go.csv
  10. +1 −0 ginkgo/outline/_testdata/alias_test.go.json
  11. +17 −0 ginkgo/outline/_testdata/create_result.sh
  12. +49 −0 ginkgo/outline/_testdata/focused_test.go
  13. +17 −0 ginkgo/outline/_testdata/focused_test.go.csv
  14. +1 −0 ginkgo/outline/_testdata/focused_test.go.json
  15. +45 −0 ginkgo/outline/_testdata/mixed_test.go
  16. +18 −0 ginkgo/outline/_testdata/mixed_test.go.csv
  17. +1 −0 ginkgo/outline/_testdata/mixed_test.go.json
  18. +36 −0 ginkgo/outline/_testdata/nestedfocused_test.go
  19. +15 −0 ginkgo/outline/_testdata/nestedfocused_test.go.csv
  20. +1 −0 ginkgo/outline/_testdata/nestedfocused_test.go.json
  21. +49 −0 ginkgo/outline/_testdata/nodot_test.go
  22. +17 −0 ginkgo/outline/_testdata/nodot_test.go.csv
  23. +1 −0 ginkgo/outline/_testdata/nodot_test.go.json
  24. +49 −0 ginkgo/outline/_testdata/normal_test.go
  25. +17 −0 ginkgo/outline/_testdata/normal_test.go.csv
  26. +1 −0 ginkgo/outline/_testdata/normal_test.go.json
  27. +49 −0 ginkgo/outline/_testdata/pending_test.go
  28. +17 −0 ginkgo/outline/_testdata/pending_test.go.csv
  29. +1 −0 ginkgo/outline/_testdata/pending_test.go.json
  30. +22 −0 ginkgo/outline/_testdata/position_test.go
  31. +3 −0 ginkgo/outline/_testdata/position_test.go.csv
  32. +1 −0 ginkgo/outline/_testdata/position_test.go.json
  33. +13 −0 ginkgo/outline/_testdata/suite_test.go
  34. +1 −0 ginkgo/outline/_testdata/suite_test.go.csv
  35. +1 −0 ginkgo/outline/_testdata/suite_test.go.json
  36. +243 −0 ginkgo/outline/ginkgo.go
  37. +65 −0 ginkgo/outline/import.go
  38. +107 −0 ginkgo/outline/outline.go
  39. +13 −0 ginkgo/outline/outline_suite_test.go
  40. +95 −0 ginkgo/outline/outline_test.go
  41. +95 −0 ginkgo/outline_command.go
  42. +2 −2 go.mod
  43. +23 −16 go.sum
  44. +13 −0 integration/flags_test.go
  45. +30 −0 integration/subcommand_test.go
  46. +0 −11 internal/remote/output_interceptor_darwin.go
  47. +0 −11 internal/remote/output_interceptor_dragonfly.go
  48. +0 −11 internal/remote/output_interceptor_freebsd.go
  49. +0 −12 internal/remote/output_interceptor_linux.go
  50. +0 −12 internal/remote/output_interceptor_linux_mips64le.go
  51. +0 −11 internal/remote/output_interceptor_netbsd.go
  52. +0 −11 internal/remote/output_interceptor_openbsd.go
  53. +0 −11 internal/remote/output_interceptor_solaris.go
  54. +5 −2 internal/remote/output_interceptor_unix.go
  55. +10 −10 internal/spec/specs.go
  56. +17 −12 internal/spec/specs_test.go
  57. +1 −1 internal/suite/suite.go
  58. +4 −4 internal/suite/suite_test.go
67 changes: 67 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '21 7 * * 0'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
11 changes: 5 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: go
go:
- 1.13.x
- 1.14.x
- 1.15.x
- tip

cache:
@@ -16,10 +16,9 @@ install:
- GO111MODULE="off" go get golang.org/x/tools/cmd/cover
- GO111MODULE="off" go get github.com/onsi/gomega
- GO111MODULE="off" go install github.com/onsi/ginkgo/ginkgo
- export PATH=$PATH:$HOME/gopath/bin
- export PATH=$GOPATH/bin:$PATH

script:
- GO111MODULE="on" go mod tidy
- diff -u <(echo -n) <(git diff go.mod)
- diff -u <(echo -n) <(git diff go.sum)
- $HOME/gopath/bin/ginkgo -r --randomizeAllSpecs --randomizeSuites --race --trace && go vet
- GO111MODULE="on" go mod tidy && git diff --exit-code go.mod go.sum
- go vet
- ginkgo -r --randomizeAllSpecs --randomizeSuites --race --trace
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## 1.15.0

### Features
- Adds 'outline' command to print the outline of specs/containers in a file (#754) [071c369] [6803cc3] [935b538] [06744e8] [0c40583]
- Add support for using template to generate tests (#752) [efb9e69]
- Add a Chinese Doc #755 (#756) [5207632]
- cli: allow multiple -focus and -skip flags (#736) [9a782fb]

### Fixes
- Add _internal to filename of tests created with internal flag (#751) [43c12da]

## 1.14.2

### Fixes
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

[![Build Status](https://travis-ci.org/onsi/ginkgo.svg?branch=master)](https://travis-ci.org/onsi/ginkgo)

Jump to the [docs](https://onsi.github.io/ginkgo/) to learn more. To start rolling your Ginkgo tests *now* [keep reading](#set-me-up)!
Jump to the [docs](https://onsi.github.io/ginkgo/) | [中文文档](https://ke-chain.github.io/ginkgodoc) to learn more. To start rolling your Ginkgo tests *now* [keep reading](#set-me-up)!

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).

33 changes: 24 additions & 9 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -20,14 +20,14 @@ import (
"fmt"
)

const VERSION = "1.14.2"
const VERSION = "1.15.0"

type GinkgoConfigType struct {
RandomSeed int64
RandomizeAllSpecs bool
RegexScansFilePath bool
FocusString string
SkipString string
FocusStrings []string
SkipStrings []string
SkipMeasurements bool
FailOnPending bool
FailFast bool
@@ -65,6 +65,11 @@ func processPrefix(prefix string) string {
return prefix
}

type flagFunc func(string)

func (f flagFunc) String() string { return "" }
func (f flagFunc) Set(s string) error { f(s); return nil }

func Flags(flagSet *flag.FlagSet, prefix string, includeParallelFlags bool) {
prefix = processPrefix(prefix)
flagSet.Int64Var(&(GinkgoConfig.RandomSeed), prefix+"seed", time.Now().Unix(), "The seed used to randomize the spec suite.")
@@ -75,8 +80,8 @@ func Flags(flagSet *flag.FlagSet, prefix string, includeParallelFlags bool) {

flagSet.BoolVar(&(GinkgoConfig.DryRun), prefix+"dryRun", false, "If set, ginkgo will walk the test hierarchy without actually running anything. Best paired with -v.")

flagSet.StringVar(&(GinkgoConfig.FocusString), prefix+"focus", "", "If set, ginkgo will only run specs that match this regular expression.")
flagSet.StringVar(&(GinkgoConfig.SkipString), prefix+"skip", "", "If set, ginkgo will only run specs that do not match this regular expression.")
flagSet.Var(flagFunc(flagFocus), prefix+"focus", "If set, ginkgo will only run specs that match this regular expression. Can be specified multiple times, values are ORed.")
flagSet.Var(flagFunc(flagSkip), prefix+"skip", "If set, ginkgo will only run specs that do not match this regular expression. Can be specified multiple times, values are ORed.")

flagSet.BoolVar(&(GinkgoConfig.RegexScansFilePath), prefix+"regexScansFilePath", false, "If set, ginkgo regex matching also will look at the file path (code location).")

@@ -133,12 +138,12 @@ func BuildFlagArgs(prefix string, ginkgo GinkgoConfigType, reporter DefaultRepor
result = append(result, fmt.Sprintf("--%sdryRun", prefix))
}

if ginkgo.FocusString != "" {
result = append(result, fmt.Sprintf("--%sfocus=%s", prefix, ginkgo.FocusString))
for _, s := range ginkgo.FocusStrings {
result = append(result, fmt.Sprintf("--%sfocus=%s", prefix, s))
}

if ginkgo.SkipString != "" {
result = append(result, fmt.Sprintf("--%sskip=%s", prefix, ginkgo.SkipString))
for _, s := range ginkgo.SkipStrings {
result = append(result, fmt.Sprintf("--%sskip=%s", prefix, s))
}

if ginkgo.FlakeAttempts > 1 {
@@ -211,3 +216,13 @@ func BuildFlagArgs(prefix string, ginkgo GinkgoConfigType, reporter DefaultRepor

return result
}

// flagFocus implements the -focus flag.
func flagFocus(arg string) {
GinkgoConfig.FocusStrings = append(GinkgoConfig.FocusStrings, arg)
}

// flagSkip implements the -skip flag.
func flagSkip(arg string) {
GinkgoConfig.SkipStrings = append(GinkgoConfig.SkipStrings, arg)
}
29 changes: 22 additions & 7 deletions ginkgo/generate_command.go
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strconv"
@@ -12,11 +13,15 @@ import (
)

func BuildGenerateCommand() *Command {
var agouti, noDot, internal bool
var (
agouti, noDot, internal bool
customTestFile string
)
flagSet := flag.NewFlagSet("generate", flag.ExitOnError)
flagSet.BoolVar(&agouti, "agouti", false, "If set, generate will generate a test file for writing Agouti tests")
flagSet.BoolVar(&noDot, "nodot", false, "If set, generate will generate a test file that does not . import ginkgo and gomega")
flagSet.BoolVar(&internal, "internal", false, "If set, generate will generate a test file that uses the regular package name")
flagSet.StringVar(&customTestFile, "template", "", "If specified, generate will use the contents of the file passed as the test file template")

return &Command{
Name: "generate",
@@ -28,7 +33,7 @@ func BuildGenerateCommand() *Command {
"Accepts the following flags:",
},
Command: func(args []string, additionalArgs []string) {
generateSpec(args, agouti, noDot, internal)
generateSpec(args, agouti, noDot, internal, customTestFile)
},
}
}
@@ -81,9 +86,9 @@ type specData struct {
ImportPackage bool
}

func generateSpec(args []string, agouti, noDot, internal bool) {
func generateSpec(args []string, agouti, noDot, internal bool, customTestFile string) {
if len(args) == 0 {
err := generateSpecForSubject("", agouti, noDot, internal)
err := generateSpecForSubject("", agouti, noDot, internal, customTestFile)
if err != nil {
fmt.Println(err.Error())
fmt.Println("")
@@ -95,7 +100,7 @@ func generateSpec(args []string, agouti, noDot, internal bool) {

var failed bool
for _, arg := range args {
err := generateSpecForSubject(arg, agouti, noDot, internal)
err := generateSpecForSubject(arg, agouti, noDot, internal, customTestFile)
if err != nil {
failed = true
fmt.Println(err.Error())
@@ -107,13 +112,17 @@ func generateSpec(args []string, agouti, noDot, internal bool) {
}
}

func generateSpecForSubject(subject string, agouti, noDot, internal bool) error {
func generateSpecForSubject(subject string, agouti, noDot, internal bool, customTestFile string) error {
packageName, specFilePrefix, formattedName := getPackageAndFormattedName()
if subject != "" {
specFilePrefix = formatSubject(subject)
formattedName = prettifyPackageName(specFilePrefix)
}

if internal {
specFilePrefix = specFilePrefix + "_internal"
}

data := specData{
Package: determinePackageName(packageName, internal),
Subject: formattedName,
@@ -136,7 +145,13 @@ func generateSpecForSubject(subject string, agouti, noDot, internal bool) error
defer f.Close()

var templateText string
if agouti {
if customTestFile != "" {
tpl, err := ioutil.ReadFile(customTestFile)
if err != nil {
panic(err.Error())
}
templateText = string(tpl)
} else if agouti {
templateText = agoutiSpecText
} else {
templateText = specText
6 changes: 6 additions & 0 deletions ginkgo/main.go
Original file line number Diff line number Diff line change
@@ -111,6 +111,11 @@ will output an executable file named `package.test`. This can be run directly o
ginkgo <path-to-package.test>
To print an outline of Ginkgo specs and containers in a file:
gingko outline <filename>
To print out Ginkgo's version:
ginkgo version
@@ -172,6 +177,7 @@ func init() {
Commands = append(Commands, BuildUnfocusCommand())
Commands = append(Commands, BuildVersionCommand())
Commands = append(Commands, BuildHelpCommand())
Commands = append(Commands, BuildOutlineCommand())
}

func main() {
50 changes: 50 additions & 0 deletions ginkgo/outline/_testdata/alias_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package example_test

import (
fooginkgo "github.com/onsi/ginkgo"
footable "github.com/onsi/ginkgo/extensions/table"
)

var _ = fooginkgo.Describe("NodotFixture", func() {
fooginkgo.Describe("normal", func() {
fooginkgo.It("normal", func() {
fooginkgo.By("normal")
fooginkgo.By("normal")

})
})

fooginkgo.Context("normal", func() {
fooginkgo.It("normal", func() {

})
})

fooginkgo.When("normal", func() {
fooginkgo.It("normal", func() {

})
})

fooginkgo.It("normal", func() {

})

fooginkgo.Specify("normal", func() {

})

fooginkgo.Measure("normal", func(b fooginkgo.Benchmarker) {

}, 2)

footable.DescribeTable("normal",
func() {},
footable.Entry("normal"),
)

footable.DescribeTable("normal",
func() {},
footable.Entry("normal"),
)
})
17 changes: 17 additions & 0 deletions ginkgo/outline/_testdata/alias_test.go.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Name,Text,Start,End,Spec,Focused,Pending
Describe,NodotFixture,130,785,false,false,false
Describe,normal,175,308,false,false,false
It,normal,215,304,true,false,false
By,normal,250,272,false,false,false
By,normal,276,298,false,false,false
Context,normal,311,391,false,false,false
It,normal,350,387,true,false,false
When,normal,394,471,false,false,false
It,normal,430,467,true,false,false
It,normal,474,510,true,false,false
Specify,normal,513,554,true,false,false
Measure,normal,557,624,true,false,false
DescribeTable,normal,627,703,false,false,false
Entry,normal,675,699,true,false,false
DescribeTable,normal,706,782,false,false,false
Entry,normal,754,778,true,false,false
1 change: 1 addition & 0 deletions ginkgo/outline/_testdata/alias_test.go.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"name":"Describe","text":"NodotFixture","start":130,"end":785,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"Describe","text":"normal","start":175,"end":308,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"It","text":"normal","start":215,"end":304,"spec":true,"focused":false,"pending":false,"nodes":[{"name":"By","text":"normal","start":250,"end":272,"spec":false,"focused":false,"pending":false,"nodes":[]},{"name":"By","text":"normal","start":276,"end":298,"spec":false,"focused":false,"pending":false,"nodes":[]}]}]},{"name":"Context","text":"normal","start":311,"end":391,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"It","text":"normal","start":350,"end":387,"spec":true,"focused":false,"pending":false,"nodes":[]}]},{"name":"When","text":"normal","start":394,"end":471,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"It","text":"normal","start":430,"end":467,"spec":true,"focused":false,"pending":false,"nodes":[]}]},{"name":"It","text":"normal","start":474,"end":510,"spec":true,"focused":false,"pending":false,"nodes":[]},{"name":"Specify","text":"normal","start":513,"end":554,"spec":true,"focused":false,"pending":false,"nodes":[]},{"name":"Measure","text":"normal","start":557,"end":624,"spec":true,"focused":false,"pending":false,"nodes":[]},{"name":"DescribeTable","text":"normal","start":627,"end":703,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"Entry","text":"normal","start":675,"end":699,"spec":true,"focused":false,"pending":false,"nodes":[]}]},{"name":"DescribeTable","text":"normal","start":706,"end":782,"spec":false,"focused":false,"pending":false,"nodes":[{"name":"Entry","text":"normal","start":754,"end":778,"spec":true,"focused":false,"pending":false,"nodes":[]}]}]}]
17 changes: 17 additions & 0 deletions ginkgo/outline/_testdata/create_result.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -o errexit
set -o nounset

GINKGO=${GINKGO:-ginkgo}

input=${1:-""}
for format in "csv" "json"; do
set -o xtrace
output="$(dirname $input)/$(basename $input).$format"
tmp=$(mktemp ginkgo-outline-test.XXX)
if "$GINKGO" outline --format="$format" "$input" 1>"$tmp"
then mv "$tmp" "$output"
else rm "$tmp"
set +o xtrace
fi
done
Loading