vendor: Mega update all dependencies

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4080
This commit is contained in:
Jakob Borg
2017-04-05 14:34:41 +00:00
parent 49c1527724
commit a1bcc15458
1354 changed files with 55066 additions and 797850 deletions

View File

@@ -1,14 +0,0 @@
package tmp
import (
"testing"
)
func TestSomethingLessImportant(t *testing.T) {
strp := "hello!"
somethingImportant(t, &strp)
}
func somethingImportant(t *testing.T, message *string) {
t.Log("Something important happened in a test: " + *message)
}

View File

@@ -1,10 +0,0 @@
package nested
import (
"testing"
)
func TestSomethingLessImportant(t *testing.T) {
whatever := &UselessStruct{}
t.Fail(whatever.ImportantField != "SECRET_PASSWORD")
}

View File

@@ -1,9 +0,0 @@
package subpackage
import (
"testing"
)
func TestNestedSubPackages(t *testing.T) {
t.Fail(true)
}

View File

@@ -1,16 +0,0 @@
package tmp_test
import (
"testing"
)
type UselessStruct struct {
ImportantField string
}
func TestSomethingImportant(t *testing.T) {
whatever := &UselessStruct{}
if whatever.ImportantField != "SECRET_PASSWORD" {
t.Fail()
}
}

View File

@@ -1,41 +0,0 @@
package tmp
import (
"testing"
)
type UselessStruct struct {
ImportantField string
T *testing.T
}
var testFunc = func(t *testing.T, arg *string) {}
func assertEqual(t *testing.T, arg1, arg2 interface{}) {
if arg1 != arg2 {
t.Fail()
}
}
func TestSomethingImportant(t *testing.T) {
whatever := &UselessStruct{
T: t,
ImportantField: "SECRET_PASSWORD",
}
something := &UselessStruct{ImportantField: "string value"}
assertEqual(t, whatever.ImportantField, "SECRET_PASSWORD")
assertEqual(t, something.ImportantField, "string value")
var foo = func(t *testing.T) {}
foo(t)
strp := "something"
testFunc(t, &strp)
t.Fail()
}
func Test3Things(t *testing.T) {
if 3 != 3 {
t.Fail()
}
}

View File

@@ -1,17 +0,0 @@
package tmp
import (
. "github.com/onsi/ginkgo"
)
var _ = Describe("Testing with Ginkgo", func() {
It("something less important", func() {
strp := "hello!"
somethingImportant(GinkgoT(), &strp)
})
})
func somethingImportant(t GinkgoTInterface, message *string) {
t.Log("Something important happened in a test: " + *message)
}

View File

@@ -1,13 +0,0 @@
package tmp
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestTmp(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Tmp Suite")
}

View File

@@ -1,11 +0,0 @@
package subpackage
import (
. "github.com/onsi/ginkgo"
)
var _ = Describe("Testing with Ginkgo", func() {
It("nested sub packages", func() {
GinkgoT().Fail(true)
})
})

View File

@@ -1,13 +0,0 @@
package nested_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestNested(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Nested Suite")
}

View File

@@ -1,13 +0,0 @@
package nested
import (
. "github.com/onsi/ginkgo"
)
var _ = Describe("Testing with Ginkgo", func() {
It("something less important", func() {
whatever := &UselessStruct{}
GinkgoT().Fail(whatever.ImportantField != "SECRET_PASSWORD")
})
})

View File

@@ -1,19 +0,0 @@
package tmp_test
import (
. "github.com/onsi/ginkgo"
)
var _ = Describe("Testing with Ginkgo", func() {
It("something important", func() {
whatever := &UselessStruct{}
if whatever.ImportantField != "SECRET_PASSWORD" {
GinkgoT().Fail()
}
})
})
type UselessStruct struct {
ImportantField string
}

View File

@@ -1,13 +0,0 @@
package tmp_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestConvertFixtures(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "ConvertFixtures Suite")
}

View File

@@ -1,44 +0,0 @@
package tmp
import (
. "github.com/onsi/ginkgo"
)
var _ = Describe("Testing with Ginkgo", func() {
It("something important", func() {
whatever := &UselessStruct{
T: GinkgoT(),
ImportantField: "SECRET_PASSWORD",
}
something := &UselessStruct{ImportantField: "string value"}
assertEqual(GinkgoT(), whatever.ImportantField, "SECRET_PASSWORD")
assertEqual(GinkgoT(), something.ImportantField, "string value")
var foo = func(t GinkgoTInterface) {}
foo(GinkgoT())
strp := "something"
testFunc(GinkgoT(), &strp)
GinkgoT().Fail()
})
It("3 things", func() {
if 3 != 3 {
GinkgoT().Fail()
}
})
})
type UselessStruct struct {
ImportantField string
T GinkgoTInterface
}
var testFunc = func(t GinkgoTInterface, arg *string) {}
func assertEqual(t GinkgoTInterface, arg1, arg2 interface{}) {
if arg1 != arg2 {
t.Fail()
}
}

View File

@@ -1,21 +0,0 @@
package coverage_fixture
func A() string {
return "A"
}
func B() string {
return "B"
}
func C() string {
return "C"
}
func D() string {
return "D"
}
func E() string {
return "untested"
}

View File

@@ -1,13 +0,0 @@
package coverage_fixture_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestCoverageFixture(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "CoverageFixture Suite")
}

View File

@@ -1,31 +0,0 @@
package coverage_fixture_test
import (
. "github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture"
. "github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture/external_coverage_fixture"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("CoverageFixture", func() {
It("should test A", func() {
Ω(A()).Should(Equal("A"))
})
It("should test B", func() {
Ω(B()).Should(Equal("B"))
})
It("should test C", func() {
Ω(C()).Should(Equal("C"))
})
It("should test D", func() {
Ω(D()).Should(Equal("D"))
})
It("should test external package", func() {
Ω(Tested()).Should(Equal("tested"))
})
})

View File

@@ -1,9 +0,0 @@
package external_coverage
func Tested() string {
return "tested"
}
func Untested() string {
return "untested"
}

View File

@@ -1,13 +0,0 @@
package does_not_compile_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestDoes_not_compile(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Does_not_compile Suite")
}

View File

@@ -1,11 +0,0 @@
package does_not_compile_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/integration/_fixtures/does_not_compile"
. "github.com/onsi/gomega"
)
var _ = Describe("DoesNotCompile", func() {
})

View File

@@ -1,13 +0,0 @@
package eventually_failing_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestEventuallyFailing(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "EventuallyFailing Suite")
}

View File

@@ -1,29 +0,0 @@
package eventually_failing_test
import (
"fmt"
"io/ioutil"
"strings"
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("EventuallyFailing", func() {
It("should fail on the third try", func() {
time.Sleep(time.Second)
files, err := ioutil.ReadDir(".")
Ω(err).ShouldNot(HaveOccurred())
numRuns := 1
for _, file := range files {
if strings.HasPrefix(file.Name(), "counter") {
numRuns++
}
}
Ω(numRuns).Should(BeNumerically("<", 3))
ioutil.WriteFile(fmt.Sprintf("./counter-%d", numRuns), []byte("foo"), 0777)
})
})

View File

@@ -1,35 +0,0 @@
package synchronized_setup_tests_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"fmt"
"os"
"testing"
)
func TestSynchronized_setup_tests(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Synchronized_setup_tests Suite")
}
var beforeData string
var _ = SynchronizedBeforeSuite(func() []byte {
fmt.Printf("BEFORE_A_%d\n", GinkgoParallelNode())
os.Exit(1)
return []byte("WHAT EVZ")
}, func(data []byte) {
println("NEVER SEE THIS")
})
var _ = Describe("Synchronized Setup", func() {
It("should do nothing", func() {
Ω(true).Should(BeTrue())
})
It("should do nothing", func() {
Ω(true).Should(BeTrue())
})
})

View File

@@ -1,13 +0,0 @@
package fail_fixture_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestFail_fixture(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Fail_fixture Suite")
}

View File

@@ -1,99 +0,0 @@
package fail_fixture_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = It("handles top level failures", func() {
Ω("a top level failure on line 9").Should(Equal("nope"))
println("NEVER SEE THIS")
})
var _ = It("handles async top level failures", func(done Done) {
Fail("an async top level failure on line 14")
println("NEVER SEE THIS")
}, 0.1)
var _ = It("FAIL in a goroutine", func(done Done) {
go func() {
defer GinkgoRecover()
Fail("a top level goroutine failure on line 21")
println("NEVER SEE THIS")
}()
}, 0.1)
var _ = Describe("Excercising different failure modes", func() {
It("synchronous failures", func() {
Ω("a sync failure").Should(Equal("nope"))
println("NEVER SEE THIS")
})
It("synchronous panics", func() {
panic("a sync panic")
println("NEVER SEE THIS")
})
It("synchronous failures with FAIL", func() {
Fail("a sync FAIL failure")
println("NEVER SEE THIS")
})
It("async timeout", func(done Done) {
Ω(true).Should(BeTrue())
}, 0.1)
It("async failure", func(done Done) {
Ω("an async failure").Should(Equal("nope"))
println("NEVER SEE THIS")
}, 0.1)
It("async panic", func(done Done) {
panic("an async panic")
println("NEVER SEE THIS")
}, 0.1)
It("async failure with FAIL", func(done Done) {
Fail("an async FAIL failure")
println("NEVER SEE THIS")
}, 0.1)
It("FAIL in a goroutine", func(done Done) {
go func() {
defer GinkgoRecover()
Fail("a goroutine FAIL failure")
println("NEVER SEE THIS")
}()
}, 0.1)
It("Gomega in a goroutine", func(done Done) {
go func() {
defer GinkgoRecover()
Ω("a goroutine failure").Should(Equal("nope"))
println("NEVER SEE THIS")
}()
}, 0.1)
It("Panic in a goroutine", func(done Done) {
go func() {
defer GinkgoRecover()
panic("a goroutine panic")
println("NEVER SEE THIS")
}()
}, 0.1)
Measure("a FAIL measure", func(Benchmarker) {
Fail("a measure FAIL failure")
println("NEVER SEE THIS")
}, 1)
Measure("a gomega failed measure", func(Benchmarker) {
Ω("a measure failure").Should(Equal("nope"))
println("NEVER SEE THIS")
}, 1)
Measure("a panicking measure", func(Benchmarker) {
panic("a measure panic")
println("NEVER SEE THIS")
}, 1)
})

View File

@@ -1,22 +0,0 @@
package failing_before_suite_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestFailingAfterSuite(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "FailingAfterSuite Suite")
}
var _ = BeforeSuite(func() {
println("BEFORE SUITE")
})
var _ = AfterSuite(func() {
println("AFTER SUITE")
panic("BAM!")
})

View File

@@ -1,15 +0,0 @@
package failing_before_suite_test
import (
. "github.com/onsi/ginkgo"
)
var _ = Describe("FailingBeforeSuite", func() {
It("should run", func() {
println("A TEST")
})
It("should run", func() {
println("A TEST")
})
})

View File

@@ -1,22 +0,0 @@
package failing_before_suite_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestFailing_before_suite(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Failing_before_suite Suite")
}
var _ = BeforeSuite(func() {
println("BEFORE SUITE")
panic("BAM!")
})
var _ = AfterSuite(func() {
println("AFTER SUITE")
})

View File

@@ -1,15 +0,0 @@
package failing_before_suite_test
import (
. "github.com/onsi/ginkgo"
)
var _ = Describe("FailingBeforeSuite", func() {
It("should never run", func() {
println("NEVER SEE THIS")
})
It("should never run", func() {
println("NEVER SEE THIS")
})
})

View File

@@ -1,5 +0,0 @@
package failing_ginkgo_tests
func AlwaysFalse() bool {
return false
}

View File

@@ -1,13 +0,0 @@
package failing_ginkgo_tests_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestFailing_ginkgo_tests(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Failing_ginkgo_tests Suite")
}

View File

@@ -1,17 +0,0 @@
package failing_ginkgo_tests_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/integration/_fixtures/failing_ginkgo_tests"
. "github.com/onsi/gomega"
)
var _ = Describe("FailingGinkgoTests", func() {
It("should fail", func() {
Ω(AlwaysFalse()).Should(BeTrue())
})
It("should pass", func() {
Ω(AlwaysFalse()).Should(BeFalse())
})
})

View File

@@ -1,9 +0,0 @@
package flags
func Tested() string {
return "tested"
}
func Untested() string {
return "untested"
}

View File

@@ -1,13 +0,0 @@
package flags_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestFlags(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Flags Suite")
}

View File

@@ -1,82 +0,0 @@
package flags_test
import (
"flag"
"fmt"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/integration/_fixtures/flags_tests"
. "github.com/onsi/gomega"
"time"
)
var customFlag string
func init() {
flag.StringVar(&customFlag, "customFlag", "default", "custom flag!")
}
var _ = Describe("Testing various flags", func() {
FDescribe("the focused set", func() {
Measure("a measurement", func(b Benchmarker) {
b.RecordValue("a value", 3)
}, 3)
It("should honor -cover", func() {
Ω(Tested()).Should(Equal("tested"))
})
PIt("should honor -failOnPending and -noisyPendings")
Describe("smores", func() {
It("should honor -skip: marshmallow", func() {
println("marshmallow")
})
It("should honor -focus: chocolate", func() {
println("chocolate")
})
})
It("should detect races", func(done Done) {
var a string
go func() {
a = "now you don't"
close(done)
}()
a = "now you see me"
println(a)
})
It("should randomize A", func() {
println("RANDOM_A")
})
It("should randomize B", func() {
println("RANDOM_B")
})
It("should randomize C", func() {
println("RANDOM_C")
})
It("should honor -slowSpecThreshold", func() {
time.Sleep(100 * time.Millisecond)
})
It("should pass in additional arguments after '--' directly to the test process", func() {
fmt.Printf("CUSTOM_FLAG: %s", customFlag)
})
})
Describe("more smores", func() {
It("should not run these unless -focus is set", func() {
println("smores")
})
})
Describe("a failing test", func() {
It("should fail", func() {
Ω(true).Should(Equal(false))
})
})
})

View File

@@ -1,13 +0,0 @@
package focused_fixture_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestFocused_fixture(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Focused_fixture Suite")
}

View File

@@ -1,63 +0,0 @@
package focused_fixture_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
)
var _ = Describe("FocusedFixture", func() {
FDescribe("focused", func() {
It("focused", func() {
})
})
FContext("focused", func() {
It("focused", func() {
})
})
FIt("focused", func() {
})
FMeasure("focused", func(b Benchmarker) {
}, 2)
FDescribeTable("focused",
func() {},
Entry("focused"),
)
DescribeTable("focused",
func() {},
FEntry("focused"),
)
Describe("not focused", func() {
It("not focused", func() {
})
})
Context("not focused", func() {
It("not focused", func() {
})
})
It("not focused", func() {
})
Measure("not focused", func(b Benchmarker) {
}, 2)
DescribeTable("not focused",
func() {},
Entry("not focused"),
)
})

View File

@@ -1,13 +0,0 @@
package hanging_suite_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestHangingSuite(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "HangingSuite Suite")
}

View File

@@ -1,30 +0,0 @@
package hanging_suite_test
import (
"fmt"
"time"
. "github.com/onsi/ginkgo"
)
var _ = AfterSuite(func() {
fmt.Println("Heading Out After Suite")
})
var _ = Describe("HangingSuite", func() {
BeforeEach(func() {
fmt.Fprintln(GinkgoWriter, "Just beginning")
})
Context("inner context", func() {
BeforeEach(func() {
fmt.Fprintln(GinkgoWriter, "Almost there...")
})
It("should hang out for a while", func() {
fmt.Fprintln(GinkgoWriter, "Hanging Out")
fmt.Println("Sleeping...")
time.Sleep(time.Hour)
})
})
})

View File

@@ -1,5 +0,0 @@
package more_ginkgo_tests
func AlwaysTrue() bool {
return true
}

View File

@@ -1,13 +0,0 @@
package more_ginkgo_tests_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestMore_ginkgo_tests(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "More_ginkgo_tests Suite")
}

View File

@@ -1,17 +0,0 @@
package more_ginkgo_tests_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/integration/_fixtures/more_ginkgo_tests"
. "github.com/onsi/gomega"
)
var _ = Describe("MoreGinkgoTests", func() {
It("should pass", func() {
Ω(AlwaysTrue()).Should(BeTrue())
})
It("should always pass", func() {
Ω(AlwaysTrue()).Should(BeTrue())
})
})

View File

@@ -1,4 +0,0 @@
package main
func main() {
}

View File

@@ -1,9 +0,0 @@
package passing_ginkgo_tests
func StringIdentity(a string) string {
return a
}
func IntegerIdentity(a int) int {
return a
}

View File

@@ -1,13 +0,0 @@
package passing_ginkgo_tests_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestPassing_ginkgo_tests(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Passing_ginkgo_tests Suite")
}

View File

@@ -1,30 +0,0 @@
package passing_ginkgo_tests_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/integration/_fixtures/passing_ginkgo_tests"
. "github.com/onsi/gomega"
)
var _ = Describe("PassingGinkgoTests", func() {
It("should proxy strings", func() {
Ω(StringIdentity("foo")).Should(Equal("foo"))
})
It("should proxy integers", func() {
Ω(IntegerIdentity(3)).Should(Equal(3))
})
It("should do it again", func() {
Ω(StringIdentity("foo")).Should(Equal("foo"))
Ω(IntegerIdentity(3)).Should(Equal(3))
})
It("should be able to run Bys", func() {
By("emitting one By")
Ω(3).Should(Equal(3))
By("emitting another By")
Ω(4).Should(Equal(4))
})
})

View File

@@ -1,26 +0,0 @@
package passing_before_suite_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestPassingSuiteSetup(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "PassingSuiteSetup Suite")
}
var a string
var b string
var _ = BeforeSuite(func() {
a = "ran before suite"
println("BEFORE SUITE")
})
var _ = AfterSuite(func() {
b = "ran after suite"
println("AFTER SUITE")
})

View File

@@ -1,28 +0,0 @@
package passing_before_suite_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("PassingSuiteSetup", func() {
It("should pass", func() {
Ω(a).Should(Equal("ran before suite"))
Ω(b).Should(BeEmpty())
})
It("should pass", func() {
Ω(a).Should(Equal("ran before suite"))
Ω(b).Should(BeEmpty())
})
It("should pass", func() {
Ω(a).Should(Equal("ran before suite"))
Ω(b).Should(BeEmpty())
})
It("should pass", func() {
Ω(a).Should(Equal("ran before suite"))
Ω(b).Should(BeEmpty())
})
})

View File

@@ -1,13 +0,0 @@
package progress_fixture_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestProgressFixture(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "ProgressFixture Suite")
}

View File

@@ -1,39 +0,0 @@
package progress_fixture_test
import (
"fmt"
. "github.com/onsi/ginkgo"
)
var _ = Describe("ProgressFixture", func() {
BeforeEach(func() {
fmt.Fprintln(GinkgoWriter, ">outer before<")
})
JustBeforeEach(func() {
fmt.Fprintln(GinkgoWriter, ">outer just before<")
})
AfterEach(func() {
fmt.Fprintln(GinkgoWriter, ">outer after<")
})
Context("Inner Context", func() {
BeforeEach(func() {
fmt.Fprintln(GinkgoWriter, ">inner before<")
})
JustBeforeEach(func() {
fmt.Fprintln(GinkgoWriter, ">inner just before<")
})
AfterEach(func() {
fmt.Fprintln(GinkgoWriter, ">inner after<")
})
It("should emit progress as it goes", func() {
fmt.Fprintln(GinkgoWriter, ">it<")
})
})
})

View File

@@ -1,13 +0,0 @@
package fail_fixture_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestFail_fixture(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Skip_fixture Suite")
}

View File

@@ -1,71 +0,0 @@
package fail_fixture_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = It("handles top level skips", func() {
Skip("a top level skip on line 9")
println("NEVER SEE THIS")
})
var _ = It("handles async top level skips", func(done Done) {
Skip("an async top level skip on line 14")
println("NEVER SEE THIS")
}, 0.1)
var _ = It("SKIP in a goroutine", func(done Done) {
go func() {
defer GinkgoRecover()
Skip("a top level goroutine skip on line 21")
println("NEVER SEE THIS")
}()
}, 0.1)
var _ = Describe("Excercising different skip modes", func() {
It("synchronous skip", func() {
Skip("a sync SKIP")
println("NEVER SEE THIS")
})
It("async skip", func(done Done) {
Skip("an async SKIP")
println("NEVER SEE THIS")
}, 0.1)
It("SKIP in a goroutine", func(done Done) {
go func() {
defer GinkgoRecover()
Skip("a goroutine SKIP")
println("NEVER SEE THIS")
}()
}, 0.1)
Measure("a SKIP measure", func(Benchmarker) {
Skip("a measure SKIP")
println("NEVER SEE THIS")
}, 1)
})
var _ = Describe("SKIP in a BeforeEach", func() {
BeforeEach(func() {
Skip("a BeforeEach SKIP")
println("NEVER SEE THIS")
})
It("a SKIP BeforeEach", func() {
println("NEVER SEE THIS")
})
})
var _ = Describe("SKIP in an AfterEach", func() {
AfterEach(func() {
Skip("an AfterEach SKIP")
println("NEVER SEE THIS")
})
It("a SKIP AfterEach", func() {
Expect(true).To(BeTrue())
})
})

View File

@@ -1,9 +0,0 @@
package suite_command
func Tested() string {
return "tested"
}
func Untested() string {
return "untested"
}

View File

@@ -1,13 +0,0 @@
package suite_command_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestSuiteCommand(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Suite Command Suite")
}

View File

@@ -1,18 +0,0 @@
package suite_command_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Testing suite command", func() {
It("it should succeed", func() {
Ω(true).Should(Equal(true))
})
PIt("a failing test", func() {
It("should fail", func() {
Ω(true).Should(Equal(false))
})
})
})

View File

@@ -1,43 +0,0 @@
package synchronized_setup_tests_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"fmt"
"testing"
"time"
)
func TestSynchronized_setup_tests(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Synchronized_setup_tests Suite")
}
var beforeData string
var _ = SynchronizedBeforeSuite(func() []byte {
fmt.Printf("BEFORE_A_%d\n", GinkgoParallelNode())
time.Sleep(100 * time.Millisecond)
return []byte("DATA")
}, func(data []byte) {
fmt.Printf("BEFORE_B_%d: %s\n", GinkgoParallelNode(), string(data))
beforeData += string(data) + "OTHER"
})
var _ = SynchronizedAfterSuite(func() {
fmt.Printf("\nAFTER_A_%d\n", GinkgoParallelNode())
time.Sleep(100 * time.Millisecond)
}, func() {
fmt.Printf("AFTER_B_%d\n", GinkgoParallelNode())
})
var _ = Describe("Synchronized Setup", func() {
It("should run the before suite once", func() {
Ω(beforeData).Should(Equal("DATAOTHER"))
})
It("should run the before suite once", func() {
Ω(beforeData).Should(Equal("DATAOTHER"))
})
})

View File

@@ -1,17 +0,0 @@
// +build complex_tests
package tags_tests_test
import (
. "github.com/onsi/ginkgo"
)
var _ = Describe("Ignored", func() {
It("should not have these tests", func() {
})
It("should not have these tests", func() {
})
})

View File

@@ -1,13 +0,0 @@
package tags_tests_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestTagsTests(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "TagsTests Suite")
}

View File

@@ -1,11 +0,0 @@
package tags_tests_test
import (
. "github.com/onsi/ginkgo"
)
var _ = Describe("TagsTests", func() {
It("should have a test", func() {
})
})

View File

@@ -1,13 +0,0 @@
package test_description_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestTestDescription(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "TestDescription Suite")
}

View File

@@ -1,23 +0,0 @@
package test_description_test
import (
"fmt"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("TestDescription", func() {
It("should pass", func() {
Ω(true).Should(BeTrue())
})
It("should fail", func() {
Ω(true).Should(BeFalse())
})
AfterEach(func() {
description := CurrentGinkgoTestDescription()
fmt.Printf("%s:%t\n", description.FullTestText, description.Failed)
})
})

View File

@@ -1,7 +0,0 @@
package A
import "github.com/onsi/B"
func DoIt() string {
return B.DoIt()
}

View File

@@ -1,13 +0,0 @@
package A_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestA(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "A Suite")
}

View File

@@ -1,14 +0,0 @@
package A_test
import (
. "github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/A"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("A", func() {
It("should do it", func() {
Ω(DoIt()).Should(Equal("done!"))
})
})

View File

@@ -1,7 +0,0 @@
package B
import "github.com/onsi/C"
func DoIt() string {
return C.DoIt()
}

View File

@@ -1,13 +0,0 @@
package B_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestB(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "B Suite")
}

View File

@@ -1,14 +0,0 @@
package B_test
import (
. "github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/B"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("B", func() {
It("should do it", func() {
Ω(DoIt()).Should(Equal("done!"))
})
})

View File

@@ -1,5 +0,0 @@
package C
func DoIt() string {
return "done!"
}

View File

@@ -1,13 +0,0 @@
package C_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestC(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "C Suite")
}

View File

@@ -1,14 +0,0 @@
package C_test
import (
. "github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/C"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("C", func() {
It("should do it", func() {
Ω(DoIt()).Should(Equal("done!"))
})
})

View File

@@ -1,7 +0,0 @@
package D
import "github.com/onsi/C"
func DoIt() string {
return C.DoIt()
}

View File

@@ -1,13 +0,0 @@
package D_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestD(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "D Suite")
}

View File

@@ -1,14 +0,0 @@
package D_test
import (
. "github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/C"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("D", func() {
It("should do it", func() {
Ω(DoIt()).Should(Equal("done!"))
})
})

View File

@@ -1,5 +0,0 @@
package xunit_tests
func AlwaysTrue() bool {
return true
}

View File

@@ -1,11 +0,0 @@
package xunit_tests
import (
"testing"
)
func TestAlwaysTrue(t *testing.T) {
if AlwaysTrue() != true {
t.Errorf("Expected true, got false")
}
}

View File

@@ -1,121 +0,0 @@
package integration_test
import (
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strings"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("ginkgo convert", func() {
var tmpDir string
readConvertedFileNamed := func(pathComponents ...string) string {
pathToFile := filepath.Join(tmpDir, "convert_fixtures", filepath.Join(pathComponents...))
bytes, err := ioutil.ReadFile(pathToFile)
ExpectWithOffset(1, err).NotTo(HaveOccurred())
return string(bytes)
}
readGoldMasterNamed := func(filename string) string {
bytes, err := ioutil.ReadFile(filepath.Join("_fixtures", "convert_goldmasters", filename))
Ω(err).ShouldNot(HaveOccurred())
return string(bytes)
}
BeforeEach(func() {
var err error
tmpDir, err = ioutil.TempDir("", "ginkgo-convert")
Ω(err).ShouldNot(HaveOccurred())
err = exec.Command("cp", "-r", filepath.Join("_fixtures", "convert_fixtures"), tmpDir).Run()
Ω(err).ShouldNot(HaveOccurred())
})
JustBeforeEach(func() {
cwd, err := os.Getwd()
Ω(err).ShouldNot(HaveOccurred())
relPath, err := filepath.Rel(cwd, filepath.Join(tmpDir, "convert_fixtures"))
Ω(err).ShouldNot(HaveOccurred())
cmd := exec.Command(pathToGinkgo, "convert", relPath)
cmd.Env = os.Environ()
for i, env := range cmd.Env {
if strings.HasPrefix(env, "PATH") {
cmd.Env[i] = cmd.Env[i] + ":" + filepath.Dir(pathToGinkgo)
break
}
}
err = cmd.Run()
Ω(err).ShouldNot(HaveOccurred())
})
AfterEach(func() {
err := os.RemoveAll(tmpDir)
Ω(err).ShouldNot(HaveOccurred())
})
It("rewrites xunit tests as ginkgo tests", func() {
convertedFile := readConvertedFileNamed("xunit_test.go")
goldMaster := readGoldMasterNamed("xunit_test.go")
Ω(convertedFile).Should(Equal(goldMaster))
})
It("rewrites all usages of *testing.T as mr.T()", func() {
convertedFile := readConvertedFileNamed("extra_functions_test.go")
goldMaster := readGoldMasterNamed("extra_functions_test.go")
Ω(convertedFile).Should(Equal(goldMaster))
})
It("rewrites tests in the package dir that belong to other packages", func() {
convertedFile := readConvertedFileNamed("outside_package_test.go")
goldMaster := readGoldMasterNamed("outside_package_test.go")
Ω(convertedFile).Should(Equal(goldMaster))
})
It("rewrites tests in nested packages", func() {
convertedFile := readConvertedFileNamed("nested", "nested_test.go")
goldMaster := readGoldMasterNamed("nested_test.go")
Ω(convertedFile).Should(Equal(goldMaster))
})
Context("ginkgo test suite files", func() {
It("creates a ginkgo test suite file for the package you specified", func() {
testsuite := readConvertedFileNamed("convert_fixtures_suite_test.go")
goldMaster := readGoldMasterNamed("suite_test.go")
Ω(testsuite).Should(Equal(goldMaster))
})
It("converts go tests in deeply nested packages (some may not contain go files)", func() {
testsuite := readConvertedFileNamed("nested_without_gofiles", "subpackage", "nested_subpackage_test.go")
goldMaster := readGoldMasterNamed("nested_subpackage_test.go")
Ω(testsuite).Should(Equal(goldMaster))
})
It("creates ginkgo test suites for all nested packages", func() {
testsuite := readConvertedFileNamed("nested", "nested_suite_test.go")
goldMaster := readGoldMasterNamed("nested_suite_test.go")
Ω(testsuite).Should(Equal(goldMaster))
})
})
Context("with an existing test suite file", func() {
BeforeEach(func() {
goldMaster := readGoldMasterNamed("fixtures_suite_test.go")
err := ioutil.WriteFile(filepath.Join(tmpDir, "convert_fixtures", "tmp_suite_test.go"), []byte(goldMaster), 0600)
Ω(err).ShouldNot(HaveOccurred())
})
It("gracefully handles existing test suite files", func() {
//nothing should have gone wrong!
})
})
})

View File

@@ -1,54 +0,0 @@
package integration_test
import (
"os"
"os/exec"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
)
var _ = Describe("Coverage Specs", func() {
AfterEach(func() {
os.RemoveAll("./_fixtures/coverage_fixture/coverage_fixture.coverprofile")
})
It("runs coverage analysis in series and in parallel", func() {
session := startGinkgo("./_fixtures/coverage_fixture", "-cover")
Eventually(session).Should(gexec.Exit(0))
output := session.Out.Contents()
Ω(output).Should(ContainSubstring("coverage: 80.0% of statements"))
serialCoverProfileOutput, err := exec.Command("go", "tool", "cover", "-func=./_fixtures/coverage_fixture/coverage_fixture.coverprofile").CombinedOutput()
Ω(err).ShouldNot(HaveOccurred())
os.RemoveAll("./_fixtures/coverage_fixture/coverage_fixture.coverprofile")
Eventually(startGinkgo("./_fixtures/coverage_fixture", "-cover", "-nodes=4")).Should(gexec.Exit(0))
parallelCoverProfileOutput, err := exec.Command("go", "tool", "cover", "-func=./_fixtures/coverage_fixture/coverage_fixture.coverprofile").CombinedOutput()
Ω(err).ShouldNot(HaveOccurred())
Ω(parallelCoverProfileOutput).Should(Equal(serialCoverProfileOutput))
})
It("runs coverage analysis on external packages in series and in parallel", func() {
session := startGinkgo("./_fixtures/coverage_fixture", "-coverpkg=github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture,github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture/external_coverage_fixture")
Eventually(session).Should(gexec.Exit(0))
output := session.Out.Contents()
Ω(output).Should(ContainSubstring("coverage: 71.4% of statements in github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture, github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture/external_coverage_fixture"))
serialCoverProfileOutput, err := exec.Command("go", "tool", "cover", "-func=./_fixtures/coverage_fixture/coverage_fixture.coverprofile").CombinedOutput()
Ω(err).ShouldNot(HaveOccurred())
os.RemoveAll("./_fixtures/coverage_fixture/coverage_fixture.coverprofile")
Eventually(startGinkgo("./_fixtures/coverage_fixture", "-coverpkg=github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture,github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture/external_coverage_fixture", "-nodes=4")).Should(gexec.Exit(0))
parallelCoverProfileOutput, err := exec.Command("go", "tool", "cover", "-func=./_fixtures/coverage_fixture/coverage_fixture.coverprofile").CombinedOutput()
Ω(err).ShouldNot(HaveOccurred())
Ω(parallelCoverProfileOutput).Should(Equal(serialCoverProfileOutput))
})
})

View File

@@ -1,48 +0,0 @@
package integration_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
)
var _ = Describe("Failing Specs", func() {
var pathToTest string
BeforeEach(func() {
pathToTest = tmpPath("failing")
copyIn("fail_fixture", pathToTest)
})
It("should fail in all the possible ways", func() {
session := startGinkgo(pathToTest, "--noColor")
Eventually(session).Should(gexec.Exit(1))
output := string(session.Out.Contents())
Ω(output).ShouldNot(ContainSubstring("NEVER SEE THIS"))
Ω(output).Should(ContainSubstring("a top level failure on line 9"))
Ω(output).Should(ContainSubstring("fail_fixture_test.go:9"))
Ω(output).Should(ContainSubstring("an async top level failure on line 14"))
Ω(output).Should(ContainSubstring("fail_fixture_test.go:14"))
Ω(output).Should(ContainSubstring("a top level goroutine failure on line 21"))
Ω(output).Should(ContainSubstring("fail_fixture_test.go:21"))
Ω(output).Should(ContainSubstring("a sync failure"))
Ω(output).Should(MatchRegexp(`Test Panicked\n\s+a sync panic`))
Ω(output).Should(ContainSubstring("a sync FAIL failure"))
Ω(output).Should(ContainSubstring("async timeout [It]"))
Ω(output).Should(ContainSubstring("Timed out"))
Ω(output).Should(ContainSubstring("an async failure"))
Ω(output).Should(MatchRegexp(`Test Panicked\n\s+an async panic`))
Ω(output).Should(ContainSubstring("an async FAIL failure"))
Ω(output).Should(ContainSubstring("a goroutine FAIL failure"))
Ω(output).Should(ContainSubstring("a goroutine failure"))
Ω(output).Should(MatchRegexp(`Test Panicked\n\s+a goroutine panic`))
Ω(output).Should(ContainSubstring("a measure failure"))
Ω(output).Should(ContainSubstring("a measure FAIL failure"))
Ω(output).Should(MatchRegexp(`Test Panicked\n\s+a measure panic`))
Ω(output).Should(ContainSubstring("0 Passed | 16 Failed"))
})
})

View File

@@ -1,176 +0,0 @@
package integration_test
import (
"os"
"path/filepath"
"strings"
. "github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/types"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
)
var _ = Describe("Flags Specs", func() {
var pathToTest string
BeforeEach(func() {
pathToTest = tmpPath("flags")
copyIn("flags_tests", pathToTest)
})
getRandomOrders := func(output string) []int {
return []int{strings.Index(output, "RANDOM_A"), strings.Index(output, "RANDOM_B"), strings.Index(output, "RANDOM_C")}
}
It("normally passes, runs measurements, prints out noisy pendings, does not randomize tests, and honors the programmatic focus", func() {
session := startGinkgo(pathToTest, "--noColor")
Eventually(session).Should(gexec.Exit(types.GINKGO_FOCUS_EXIT_CODE))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("Ran 3 samples:"), "has a measurement")
Ω(output).Should(ContainSubstring("10 Passed"))
Ω(output).Should(ContainSubstring("0 Failed"))
Ω(output).Should(ContainSubstring("1 Pending"))
Ω(output).Should(ContainSubstring("2 Skipped"))
Ω(output).Should(ContainSubstring("[PENDING]"))
Ω(output).Should(ContainSubstring("marshmallow"))
Ω(output).Should(ContainSubstring("chocolate"))
Ω(output).Should(ContainSubstring("CUSTOM_FLAG: default"))
Ω(output).Should(ContainSubstring("Detected Programmatic Focus - setting exit status to %d", types.GINKGO_FOCUS_EXIT_CODE))
Ω(output).ShouldNot(ContainSubstring("smores"))
Ω(output).ShouldNot(ContainSubstring("SLOW TEST"))
Ω(output).ShouldNot(ContainSubstring("should honor -slowSpecThreshold"))
orders := getRandomOrders(output)
Ω(orders[0]).Should(BeNumerically("<", orders[1]))
Ω(orders[1]).Should(BeNumerically("<", orders[2]))
})
It("should run a coverprofile when passed -cover", func() {
session := startGinkgo(pathToTest, "--noColor", "--cover", "--focus=the focused set")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())
_, err := os.Stat(filepath.Join(pathToTest, "flags.coverprofile"))
Ω(err).ShouldNot(HaveOccurred())
Ω(output).Should(ContainSubstring("coverage: "))
})
It("should fail when there are pending tests and it is passed --failOnPending", func() {
session := startGinkgo(pathToTest, "--noColor", "--failOnPending")
Eventually(session).Should(gexec.Exit(1))
})
It("should not print out pendings when --noisyPendings=false", func() {
session := startGinkgo(pathToTest, "--noColor", "--noisyPendings=false")
Eventually(session).Should(gexec.Exit(types.GINKGO_FOCUS_EXIT_CODE))
output := string(session.Out.Contents())
Ω(output).ShouldNot(ContainSubstring("[PENDING]"))
Ω(output).Should(ContainSubstring("1 Pending"))
})
It("should override the programmatic focus when told to focus", func() {
session := startGinkgo(pathToTest, "--noColor", "--focus=smores")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("marshmallow"))
Ω(output).Should(ContainSubstring("chocolate"))
Ω(output).Should(ContainSubstring("smores"))
Ω(output).Should(ContainSubstring("3 Passed"))
Ω(output).Should(ContainSubstring("0 Failed"))
Ω(output).Should(ContainSubstring("0 Pending"))
Ω(output).Should(ContainSubstring("10 Skipped"))
})
It("should override the programmatic focus when told to skip", func() {
session := startGinkgo(pathToTest, "--noColor", "--skip=marshmallow|failing")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())
Ω(output).ShouldNot(ContainSubstring("marshmallow"))
Ω(output).Should(ContainSubstring("chocolate"))
Ω(output).Should(ContainSubstring("smores"))
Ω(output).Should(ContainSubstring("10 Passed"))
Ω(output).Should(ContainSubstring("0 Failed"))
Ω(output).Should(ContainSubstring("1 Pending"))
Ω(output).Should(ContainSubstring("2 Skipped"))
})
It("should run the race detector when told to", func() {
session := startGinkgo(pathToTest, "--noColor", "--race")
Eventually(session).Should(gexec.Exit(types.GINKGO_FOCUS_EXIT_CODE))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("WARNING: DATA RACE"))
})
It("should randomize tests when told to", func() {
session := startGinkgo(pathToTest, "--noColor", "--randomizeAllSpecs", "--seed=21")
Eventually(session).Should(gexec.Exit(types.GINKGO_FOCUS_EXIT_CODE))
output := string(session.Out.Contents())
orders := getRandomOrders(output)
Ω(orders[0]).ShouldNot(BeNumerically("<", orders[1]))
})
It("should skip measurements when told to", func() {
session := startGinkgo(pathToTest, "--skipMeasurements")
Eventually(session).Should(gexec.Exit(types.GINKGO_FOCUS_EXIT_CODE))
output := string(session.Out.Contents())
Ω(output).ShouldNot(ContainSubstring("Ran 3 samples:"), "has a measurement")
Ω(output).Should(ContainSubstring("3 Skipped"))
})
It("should watch for slow specs", func() {
session := startGinkgo(pathToTest, "--slowSpecThreshold=0.05")
Eventually(session).Should(gexec.Exit(types.GINKGO_FOCUS_EXIT_CODE))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("SLOW TEST"))
Ω(output).Should(ContainSubstring("should honor -slowSpecThreshold"))
})
It("should pass additional arguments in", func() {
session := startGinkgo(pathToTest, "--", "--customFlag=madagascar")
Eventually(session).Should(gexec.Exit(types.GINKGO_FOCUS_EXIT_CODE))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("CUSTOM_FLAG: madagascar"))
})
It("should print out full stack traces for failures when told to", func() {
session := startGinkgo(pathToTest, "--focus=a failing test", "--trace")
Eventually(session).Should(gexec.Exit(1))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("Full Stack Trace"))
})
It("should fail fast when told to", func() {
pathToTest = tmpPath("fail")
copyIn("fail_fixture", pathToTest)
session := startGinkgo(pathToTest, "--failFast")
Eventually(session).Should(gexec.Exit(1))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("1 Failed"))
Ω(output).Should(ContainSubstring("15 Skipped"))
})
It("should perform a dry run when told to", func() {
pathToTest = tmpPath("fail")
copyIn("fail_fixture", pathToTest)
session := startGinkgo(pathToTest, "--dryRun", "-v")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("synchronous failures"))
Ω(output).Should(ContainSubstring("16 Specs"))
Ω(output).Should(ContainSubstring("0 Passed"))
Ω(output).Should(ContainSubstring("0 Failed"))
})
})

View File

@@ -1,91 +0,0 @@
package integration_test
import (
"io"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
"testing"
"time"
)
var tmpDir string
var pathToGinkgo string
func TestIntegration(t *testing.T) {
SetDefaultEventuallyTimeout(15 * time.Second)
RegisterFailHandler(Fail)
RunSpecs(t, "Integration Suite")
}
var _ = SynchronizedBeforeSuite(func() []byte {
pathToGinkgo, err := gexec.Build("github.com/onsi/ginkgo/ginkgo")
Ω(err).ShouldNot(HaveOccurred())
return []byte(pathToGinkgo)
}, func(computedPathToGinkgo []byte) {
pathToGinkgo = string(computedPathToGinkgo)
})
var _ = BeforeEach(func() {
var err error
tmpDir, err = ioutil.TempDir("", "ginkgo-run")
Ω(err).ShouldNot(HaveOccurred())
})
var _ = AfterEach(func() {
err := os.RemoveAll(tmpDir)
Ω(err).ShouldNot(HaveOccurred())
})
var _ = SynchronizedAfterSuite(func() {}, func() {
gexec.CleanupBuildArtifacts()
})
func tmpPath(destination string) string {
return filepath.Join(tmpDir, destination)
}
func copyIn(fixture string, destination string) {
err := os.MkdirAll(destination, 0777)
Ω(err).ShouldNot(HaveOccurred())
filepath.Walk(filepath.Join("_fixtures", fixture), func(path string, info os.FileInfo, err error) error {
if info.IsDir() {
return nil
}
base := filepath.Base(path)
src, err := os.Open(path)
Ω(err).ShouldNot(HaveOccurred())
defer src.Close()
dst, err := os.Create(filepath.Join(destination, base))
Ω(err).ShouldNot(HaveOccurred())
defer dst.Close()
_, err = io.Copy(dst, src)
Ω(err).ShouldNot(HaveOccurred())
return nil
})
}
func ginkgoCommand(dir string, args ...string) *exec.Cmd {
cmd := exec.Command(pathToGinkgo, args...)
cmd.Dir = dir
return cmd
}
func startGinkgo(dir string, args ...string) *gexec.Session {
cmd := ginkgoCommand(dir, args...)
session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
Ω(err).ShouldNot(HaveOccurred())
return session
}

View File

@@ -1,51 +0,0 @@
package integration_test
import (
"os/exec"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
)
var _ = Describe("Interrupt", func() {
var pathToTest string
BeforeEach(func() {
pathToTest = tmpPath("hanging")
copyIn("hanging_suite", pathToTest)
})
Context("when interrupting a suite", func() {
var session *gexec.Session
BeforeEach(func() {
//we need to signal the actual process, so we must compile the test first
var err error
cmd := exec.Command("go", "test", "-c")
cmd.Dir = pathToTest
session, err = gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
Ω(err).ShouldNot(HaveOccurred())
Eventually(session).Should(gexec.Exit(0))
//then run the compiled test directly
cmd = exec.Command("./hanging.test", "--test.v=true", "--ginkgo.noColor")
cmd.Dir = pathToTest
session, err = gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
Ω(err).ShouldNot(HaveOccurred())
Eventually(session).Should(gbytes.Say("Sleeping..."))
session.Interrupt()
Eventually(session, 1000).Should(gexec.Exit(1))
})
It("should emit the contents of the GinkgoWriter", func() {
Ω(session).Should(gbytes.Say("Just beginning"))
Ω(session).Should(gbytes.Say("Almost there..."))
Ω(session).Should(gbytes.Say("Hanging Out"))
})
It("should run the AfterSuite", func() {
Ω(session).Should(gbytes.Say("Heading Out After Suite"))
})
})
})

View File

@@ -1,53 +0,0 @@
package integration_test
import (
"os"
"os/exec"
"path/filepath"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
)
var _ = Describe("ginkgo build", func() {
var pathToTest string
BeforeEach(func() {
pathToTest = tmpPath("passing_ginkgo_tests")
copyIn("passing_ginkgo_tests", pathToTest)
session := startGinkgo(pathToTest, "build")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("Compiling passing_ginkgo_tests"))
Ω(output).Should(ContainSubstring("compiled passing_ginkgo_tests.test"))
})
It("should build a test binary", func() {
_, err := os.Stat(filepath.Join(pathToTest, "passing_ginkgo_tests.test"))
Ω(err).ShouldNot(HaveOccurred())
})
It("should be possible to run the test binary directly", func() {
cmd := exec.Command("./passing_ginkgo_tests.test")
cmd.Dir = pathToTest
session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
Ω(err).ShouldNot(HaveOccurred())
Eventually(session).Should(gexec.Exit(0))
Ω(session).Should(gbytes.Say("Running Suite: Passing_ginkgo_tests Suite"))
})
It("should be possible to run the test binary via ginkgo", func() {
session := startGinkgo(pathToTest, "./passing_ginkgo_tests.test")
Eventually(session).Should(gexec.Exit(0))
Ω(session).Should(gbytes.Say("Running Suite: Passing_ginkgo_tests Suite"))
})
It("should be possible to run the test binary in parallel", func() {
session := startGinkgo(pathToTest, "--nodes=4", "--noColor", "./passing_ginkgo_tests.test")
Eventually(session).Should(gexec.Exit(0))
Ω(session).Should(gbytes.Say("Running Suite: Passing_ginkgo_tests Suite"))
Ω(session).Should(gbytes.Say("Running in parallel across 4 nodes"))
})
})

View File

@@ -1,75 +0,0 @@
package integration_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
)
var _ = Describe("Emitting progress", func() {
var pathToTest string
var session *gexec.Session
var args []string
BeforeEach(func() {
args = []string{"--noColor"}
pathToTest = tmpPath("progress")
copyIn("progress_fixture", pathToTest)
})
JustBeforeEach(func() {
session = startGinkgo(pathToTest, args...)
Eventually(session).Should(gexec.Exit(0))
})
Context("with the -progress flag, but no -v flag", func() {
BeforeEach(func() {
args = append(args, "-progress")
})
It("should not emit progress", func() {
Ω(session).ShouldNot(gbytes.Say("[bB]efore"))
})
})
Context("with the -v flag", func() {
BeforeEach(func() {
args = append(args, "-v")
})
It("should not emit progress", func() {
Ω(session).ShouldNot(gbytes.Say(`\[BeforeEach\]`))
Ω(session).Should(gbytes.Say(`>outer before<`))
})
})
Context("with the -progress flag and the -v flag", func() {
BeforeEach(func() {
args = append(args, "-progress", "-v")
})
It("should emit progress (by writing to the GinkgoWriter)", func() {
Ω(session).Should(gbytes.Say(`\[BeforeEach\] ProgressFixture`))
Ω(session).Should(gbytes.Say(`>outer before<`))
Ω(session).Should(gbytes.Say(`\[BeforeEach\] Inner Context`))
Ω(session).Should(gbytes.Say(`>inner before<`))
Ω(session).Should(gbytes.Say(`\[JustBeforeEach\] ProgressFixture`))
Ω(session).Should(gbytes.Say(`>outer just before<`))
Ω(session).Should(gbytes.Say(`\[JustBeforeEach\] Inner Context`))
Ω(session).Should(gbytes.Say(`>inner just before<`))
Ω(session).Should(gbytes.Say(`\[It\] should emit progress as it goes`))
Ω(session).Should(gbytes.Say(`>it<`))
Ω(session).Should(gbytes.Say(`\[AfterEach\] Inner Context`))
Ω(session).Should(gbytes.Say(`>inner after<`))
Ω(session).Should(gbytes.Say(`\[AfterEach\] ProgressFixture`))
Ω(session).Should(gbytes.Say(`>outer after<`))
})
})
})

View File

@@ -1,382 +0,0 @@
package integration_test
import (
"fmt"
"regexp"
"runtime"
"strings"
. "github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/types"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
)
var _ = Describe("Running Specs", func() {
var pathToTest string
isWindows := (runtime.GOOS == "windows")
denoter := "•"
if isWindows {
denoter = "+"
}
Context("when pointed at the current directory", func() {
BeforeEach(func() {
pathToTest = tmpPath("ginkgo")
copyIn("passing_ginkgo_tests", pathToTest)
})
It("should run the tests in the working directory", func() {
session := startGinkgo(pathToTest, "--noColor")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("Running Suite: Passing_ginkgo_tests Suite"))
Ω(output).Should(ContainSubstring(strings.Repeat(denoter, 4)))
Ω(output).Should(ContainSubstring("SUCCESS! -- 4 Passed"))
Ω(output).Should(ContainSubstring("Test Suite Passed"))
})
})
Context("when passed an explicit package to run", func() {
BeforeEach(func() {
pathToTest = tmpPath("ginkgo")
copyIn("passing_ginkgo_tests", pathToTest)
})
It("should run the ginkgo style tests", func() {
session := startGinkgo(tmpDir, "--noColor", pathToTest)
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("Running Suite: Passing_ginkgo_tests Suite"))
Ω(output).Should(ContainSubstring(strings.Repeat(denoter, 4)))
Ω(output).Should(ContainSubstring("SUCCESS! -- 4 Passed"))
Ω(output).Should(ContainSubstring("Test Suite Passed"))
})
})
Context("when passed a number of packages to run", func() {
BeforeEach(func() {
pathToTest = tmpPath("ginkgo")
otherPathToTest := tmpPath("other")
copyIn("passing_ginkgo_tests", pathToTest)
copyIn("more_ginkgo_tests", otherPathToTest)
})
It("should run the ginkgo style tests", func() {
session := startGinkgo(tmpDir, "--noColor", "--succinct=false", "ginkgo", "./other")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("Running Suite: Passing_ginkgo_tests Suite"))
Ω(output).Should(ContainSubstring("Running Suite: More_ginkgo_tests Suite"))
Ω(output).Should(ContainSubstring("Test Suite Passed"))
})
})
Context("when passed a number of packages to run, some of which have focused tests", func() {
BeforeEach(func() {
pathToTest = tmpPath("ginkgo")
otherPathToTest := tmpPath("other")
focusedPathToTest := tmpPath("focused")
copyIn("passing_ginkgo_tests", pathToTest)
copyIn("more_ginkgo_tests", otherPathToTest)
copyIn("focused_fixture", focusedPathToTest)
})
It("should exit with a status code of 2 and explain why", func() {
session := startGinkgo(tmpDir, "--noColor", "--succinct=false", "-r")
Eventually(session).Should(gexec.Exit(types.GINKGO_FOCUS_EXIT_CODE))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("Running Suite: Passing_ginkgo_tests Suite"))
Ω(output).Should(ContainSubstring("Running Suite: More_ginkgo_tests Suite"))
Ω(output).Should(ContainSubstring("Test Suite Passed"))
Ω(output).Should(ContainSubstring("Detected Programmatic Focus - setting exit status to %d", types.GINKGO_FOCUS_EXIT_CODE))
})
})
Context("when told to skipPackages", func() {
BeforeEach(func() {
pathToTest = tmpPath("ginkgo")
otherPathToTest := tmpPath("other")
focusedPathToTest := tmpPath("focused")
copyIn("passing_ginkgo_tests", pathToTest)
copyIn("more_ginkgo_tests", otherPathToTest)
copyIn("focused_fixture", focusedPathToTest)
})
It("should skip packages that match the list", func() {
session := startGinkgo(tmpDir, "--noColor", "--skipPackage=other,focused", "-r")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("Passing_ginkgo_tests Suite"))
Ω(output).ShouldNot(ContainSubstring("More_ginkgo_tests Suite"))
Ω(output).ShouldNot(ContainSubstring("Focused_fixture Suite"))
Ω(output).Should(ContainSubstring("Test Suite Passed"))
})
Context("when all packages are skipped", func() {
It("should not run anything, but still exit 0", func() {
session := startGinkgo(tmpDir, "--noColor", "--skipPackage=other,focused,ginkgo", "-r")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("All tests skipped!"))
Ω(output).ShouldNot(ContainSubstring("Passing_ginkgo_tests Suite"))
Ω(output).ShouldNot(ContainSubstring("More_ginkgo_tests Suite"))
Ω(output).ShouldNot(ContainSubstring("Focused_fixture Suite"))
Ω(output).ShouldNot(ContainSubstring("Test Suite Passed"))
})
})
})
Context("when there are no tests to run", func() {
It("should exit 1", func() {
session := startGinkgo(tmpDir, "--noColor", "--skipPackage=other,focused", "-r")
Eventually(session).Should(gexec.Exit(1))
output := string(session.Err.Contents())
Ω(output).Should(ContainSubstring("Found no test suites"))
})
})
Context("when told to randomizeSuites", func() {
BeforeEach(func() {
pathToTest = tmpPath("ginkgo")
otherPathToTest := tmpPath("other")
copyIn("passing_ginkgo_tests", pathToTest)
copyIn("more_ginkgo_tests", otherPathToTest)
})
It("should skip packages that match the regexp", func() {
session := startGinkgo(tmpDir, "--noColor", "--randomizeSuites", "-r", "--seed=2")
Eventually(session).Should(gexec.Exit(0))
Ω(session).Should(gbytes.Say("More_ginkgo_tests Suite"))
Ω(session).Should(gbytes.Say("Passing_ginkgo_tests Suite"))
session = startGinkgo(tmpDir, "--noColor", "--randomizeSuites", "-r", "--seed=3")
Eventually(session).Should(gexec.Exit(0))
Ω(session).Should(gbytes.Say("Passing_ginkgo_tests Suite"))
Ω(session).Should(gbytes.Say("More_ginkgo_tests Suite"))
})
})
Context("when pointed at a package with xunit style tests", func() {
BeforeEach(func() {
pathToTest = tmpPath("xunit")
copyIn("xunit_tests", pathToTest)
})
It("should run the xunit style tests", func() {
session := startGinkgo(pathToTest)
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("--- PASS: TestAlwaysTrue"))
Ω(output).Should(ContainSubstring("Test Suite Passed"))
})
})
Context("when pointed at a package with no tests", func() {
BeforeEach(func() {
pathToTest = tmpPath("no_tests")
copyIn("no_tests", pathToTest)
})
It("should fail", func() {
session := startGinkgo(pathToTest, "--noColor")
Eventually(session).Should(gexec.Exit(1))
Ω(session.Err.Contents()).Should(ContainSubstring("Found no test suites"))
})
})
Context("when pointed at a package that fails to compile", func() {
BeforeEach(func() {
pathToTest = tmpPath("does_not_compile")
copyIn("does_not_compile", pathToTest)
})
It("should fail", func() {
session := startGinkgo(pathToTest, "--noColor")
Eventually(session).Should(gexec.Exit(1))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("Failed to compile"))
})
})
Context("when running in parallel", func() {
BeforeEach(func() {
pathToTest = tmpPath("ginkgo")
copyIn("passing_ginkgo_tests", pathToTest)
})
Context("with a specific number of -nodes", func() {
It("should use the specified number of nodes", func() {
session := startGinkgo(pathToTest, "--noColor", "-succinct", "-nodes=2")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())
Ω(output).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs - 2 nodes [%s]{4} SUCCESS! \d+(\.\d+)?[muµ]s`, regexp.QuoteMeta(denoter)))
Ω(output).Should(ContainSubstring("Test Suite Passed"))
})
})
Context("with -p", func() {
It("it should autocompute the number of nodes", func() {
session := startGinkgo(pathToTest, "--noColor", "-succinct", "-p")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())
nodes := runtime.NumCPU()
if nodes > 4 {
nodes = nodes - 1
}
Ω(output).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs - %d nodes [%s]{4} SUCCESS! \d+(\.\d+)?[muµ]s`, nodes, regexp.QuoteMeta(denoter)))
Ω(output).Should(ContainSubstring("Test Suite Passed"))
})
})
})
Context("when streaming in parallel", func() {
BeforeEach(func() {
pathToTest = tmpPath("ginkgo")
copyIn("passing_ginkgo_tests", pathToTest)
})
It("should print output in realtime", func() {
session := startGinkgo(pathToTest, "--noColor", "-stream", "-nodes=2")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring(`[1] Parallel test node 1/2.`))
Ω(output).Should(ContainSubstring(`[2] Parallel test node 2/2.`))
Ω(output).Should(ContainSubstring(`[1] SUCCESS!`))
Ω(output).Should(ContainSubstring(`[2] SUCCESS!`))
Ω(output).Should(ContainSubstring("Test Suite Passed"))
})
})
Context("when running recursively", func() {
BeforeEach(func() {
passingTest := tmpPath("A")
otherPassingTest := tmpPath("E")
copyIn("passing_ginkgo_tests", passingTest)
copyIn("more_ginkgo_tests", otherPassingTest)
})
Context("when all the tests pass", func() {
It("should run all the tests (in succinct mode) and succeed", func() {
session := startGinkgo(tmpDir, "--noColor", "-r")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())
outputLines := strings.Split(output, "\n")
Ω(outputLines[0]).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs [%s]{4} SUCCESS! \d+(\.\d+)?[muµ]s PASS`, regexp.QuoteMeta(denoter)))
Ω(outputLines[1]).Should(MatchRegexp(`\[\d+\] More_ginkgo_tests Suite - 2/2 specs [%s]{2} SUCCESS! \d+(\.\d+)?[muµ]s PASS`, regexp.QuoteMeta(denoter)))
Ω(output).Should(ContainSubstring("Test Suite Passed"))
})
})
Context("when one of the packages has a failing tests", func() {
BeforeEach(func() {
failingTest := tmpPath("C")
copyIn("failing_ginkgo_tests", failingTest)
})
It("should fail and stop running tests", func() {
session := startGinkgo(tmpDir, "--noColor", "-r")
Eventually(session).Should(gexec.Exit(1))
output := string(session.Out.Contents())
outputLines := strings.Split(output, "\n")
Ω(outputLines[0]).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs [%s]{4} SUCCESS! \d+(\.\d+)?[muµ]s PASS`, regexp.QuoteMeta(denoter)))
Ω(outputLines[1]).Should(MatchRegexp(`\[\d+\] Failing_ginkgo_tests Suite - 2/2 specs`))
Ω(output).Should(ContainSubstring(fmt.Sprintf("%s Failure", denoter)))
Ω(output).ShouldNot(ContainSubstring("More_ginkgo_tests Suite"))
Ω(output).Should(ContainSubstring("Test Suite Failed"))
Ω(output).Should(ContainSubstring("Summarizing 1 Failure:"))
Ω(output).Should(ContainSubstring("[Fail] FailingGinkgoTests [It] should fail"))
})
})
Context("when one of the packages fails to compile", func() {
BeforeEach(func() {
doesNotCompileTest := tmpPath("C")
copyIn("does_not_compile", doesNotCompileTest)
})
It("should fail and stop running tests", func() {
session := startGinkgo(tmpDir, "--noColor", "-r")
Eventually(session).Should(gexec.Exit(1))
output := string(session.Out.Contents())
outputLines := strings.Split(output, "\n")
Ω(outputLines[0]).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs [%s]{4} SUCCESS! \d+(\.\d+)?[muµ]s PASS`, regexp.QuoteMeta(denoter)))
Ω(outputLines[1]).Should(ContainSubstring("Failed to compile C:"))
Ω(output).ShouldNot(ContainSubstring("More_ginkgo_tests Suite"))
Ω(output).Should(ContainSubstring("Test Suite Failed"))
})
})
Context("when either is the case, but the keepGoing flag is set", func() {
BeforeEach(func() {
doesNotCompileTest := tmpPath("B")
copyIn("does_not_compile", doesNotCompileTest)
failingTest := tmpPath("C")
copyIn("failing_ginkgo_tests", failingTest)
})
It("should soldier on", func() {
session := startGinkgo(tmpDir, "--noColor", "-r", "-keepGoing")
Eventually(session).Should(gexec.Exit(1))
output := string(session.Out.Contents())
outputLines := strings.Split(output, "\n")
Ω(outputLines[0]).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs [%s]{4} SUCCESS! \d+(\.\d+)?[muµ]s PASS`, regexp.QuoteMeta(denoter)))
Ω(outputLines[1]).Should(ContainSubstring("Failed to compile B:"))
Ω(output).Should(MatchRegexp(`\[\d+\] Failing_ginkgo_tests Suite - 2/2 specs`))
Ω(output).Should(ContainSubstring(fmt.Sprintf("%s Failure", denoter)))
Ω(output).Should(MatchRegexp(`\[\d+\] More_ginkgo_tests Suite - 2/2 specs [%s]{2} SUCCESS! \d+(\.\d+)?[muµ]s PASS`, regexp.QuoteMeta(denoter)))
Ω(output).Should(ContainSubstring("Test Suite Failed"))
})
})
})
Context("when told to keep going --untilItFails", func() {
BeforeEach(func() {
copyIn("eventually_failing", tmpDir)
})
It("should keep rerunning the tests, until a failure occurs", func() {
session := startGinkgo(tmpDir, "--untilItFails", "--noColor")
Eventually(session).Should(gexec.Exit(1))
Ω(session).Should(gbytes.Say("This was attempt #1"))
Ω(session).Should(gbytes.Say("This was attempt #2"))
Ω(session).Should(gbytes.Say("Tests failed on attempt #3"))
//it should change the random seed between each test
lines := strings.Split(string(session.Out.Contents()), "\n")
randomSeeds := []string{}
for _, line := range lines {
if strings.Contains(line, "Random Seed:") {
randomSeeds = append(randomSeeds, strings.Split(line, ": ")[1])
}
}
Ω(randomSeeds[0]).ShouldNot(Equal(randomSeeds[1]))
Ω(randomSeeds[1]).ShouldNot(Equal(randomSeeds[2]))
Ω(randomSeeds[0]).ShouldNot(Equal(randomSeeds[2]))
})
})
})

View File

@@ -1,43 +0,0 @@
package integration_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
)
var _ = Describe("Skipping Specs", func() {
var pathToTest string
BeforeEach(func() {
pathToTest = tmpPath("skipping")
copyIn("skip_fixture", pathToTest)
})
It("should skip in all the possible ways", func() {
session := startGinkgo(pathToTest, "--noColor")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())
Ω(output).ShouldNot(ContainSubstring("NEVER SEE THIS"))
Ω(output).Should(ContainSubstring("a top level skip on line 9"))
Ω(output).Should(ContainSubstring("skip_fixture_test.go:9"))
Ω(output).Should(ContainSubstring("an async top level skip on line 14"))
Ω(output).Should(ContainSubstring("skip_fixture_test.go:14"))
Ω(output).Should(ContainSubstring("a top level goroutine skip on line 21"))
Ω(output).Should(ContainSubstring("skip_fixture_test.go:21"))
Ω(output).Should(ContainSubstring("a sync SKIP"))
Ω(output).Should(ContainSubstring("an async SKIP"))
Ω(output).Should(ContainSubstring("a goroutine SKIP"))
Ω(output).Should(ContainSubstring("a measure SKIP"))
Ω(output).Should(ContainSubstring("S [SKIPPING] in Spec Setup (BeforeEach) ["))
Ω(output).Should(ContainSubstring("a BeforeEach SKIP"))
Ω(output).Should(ContainSubstring("S [SKIPPING] in Spec Teardown (AfterEach) ["))
Ω(output).Should(ContainSubstring("an AfterEach SKIP"))
Ω(output).Should(ContainSubstring("0 Passed | 0 Failed | 0 Pending | 9 Skipped"))
})
})

View File

@@ -1,364 +0,0 @@
package integration_test
import (
"io/ioutil"
"os"
"path/filepath"
"strings"
. "github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/types"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
)
var _ = Describe("Subcommand", func() {
Describe("ginkgo bootstrap", func() {
var pkgPath string
BeforeEach(func() {
pkgPath = tmpPath("foo")
os.Mkdir(pkgPath, 0777)
})
It("should generate a bootstrap file, as long as one does not exist", func() {
session := startGinkgo(pkgPath, "bootstrap")
Eventually(session).Should(gexec.Exit(0))
output := session.Out.Contents()
Ω(output).Should(ContainSubstring("foo_suite_test.go"))
content, err := ioutil.ReadFile(filepath.Join(pkgPath, "foo_suite_test.go"))
Ω(err).ShouldNot(HaveOccurred())
Ω(content).Should(ContainSubstring("package foo_test"))
Ω(content).Should(ContainSubstring("func TestFoo(t *testing.T) {"))
Ω(content).Should(ContainSubstring("RegisterFailHandler"))
Ω(content).Should(ContainSubstring("RunSpecs"))
Ω(content).Should(ContainSubstring("\t" + `. "github.com/onsi/ginkgo"`))
Ω(content).Should(ContainSubstring("\t" + `. "github.com/onsi/gomega"`))
session = startGinkgo(pkgPath, "bootstrap")
Eventually(session).Should(gexec.Exit(1))
output = session.Out.Contents()
Ω(output).Should(ContainSubstring("foo_suite_test.go already exists"))
})
It("should import nodot declarations when told to", func() {
session := startGinkgo(pkgPath, "bootstrap", "--nodot")
Eventually(session).Should(gexec.Exit(0))
output := session.Out.Contents()
Ω(output).Should(ContainSubstring("foo_suite_test.go"))
content, err := ioutil.ReadFile(filepath.Join(pkgPath, "foo_suite_test.go"))
Ω(err).ShouldNot(HaveOccurred())
Ω(content).Should(ContainSubstring("package foo_test"))
Ω(content).Should(ContainSubstring("func TestFoo(t *testing.T) {"))
Ω(content).Should(ContainSubstring("RegisterFailHandler"))
Ω(content).Should(ContainSubstring("RunSpecs"))
Ω(content).Should(ContainSubstring("var It = ginkgo.It"))
Ω(content).Should(ContainSubstring("var Ω = gomega.Ω"))
Ω(content).Should(ContainSubstring("\t" + `"github.com/onsi/ginkgo"`))
Ω(content).Should(ContainSubstring("\t" + `"github.com/onsi/gomega"`))
})
It("should generate an agouti bootstrap file when told to", func() {
session := startGinkgo(pkgPath, "bootstrap", "--agouti")
Eventually(session).Should(gexec.Exit(0))
output := session.Out.Contents()
Ω(output).Should(ContainSubstring("foo_suite_test.go"))
content, err := ioutil.ReadFile(filepath.Join(pkgPath, "foo_suite_test.go"))
Ω(err).ShouldNot(HaveOccurred())
Ω(content).Should(ContainSubstring("package foo_test"))
Ω(content).Should(ContainSubstring("func TestFoo(t *testing.T) {"))
Ω(content).Should(ContainSubstring("RegisterFailHandler"))
Ω(content).Should(ContainSubstring("RunSpecs"))
Ω(content).Should(ContainSubstring("\t" + `. "github.com/onsi/ginkgo"`))
Ω(content).Should(ContainSubstring("\t" + `. "github.com/onsi/gomega"`))
Ω(content).Should(ContainSubstring("\t" + `"github.com/sclevine/agouti"`))
})
})
Describe("nodot", func() {
It("should update the declarations in the bootstrap file", func() {
pkgPath := tmpPath("foo")
os.Mkdir(pkgPath, 0777)
session := startGinkgo(pkgPath, "bootstrap", "--nodot")
Eventually(session).Should(gexec.Exit(0))
byteContent, err := ioutil.ReadFile(filepath.Join(pkgPath, "foo_suite_test.go"))
Ω(err).ShouldNot(HaveOccurred())
content := string(byteContent)
content = strings.Replace(content, "var It =", "var MyIt =", -1)
content = strings.Replace(content, "var Ω = gomega.Ω\n", "", -1)
err = ioutil.WriteFile(filepath.Join(pkgPath, "foo_suite_test.go"), []byte(content), os.ModePerm)
Ω(err).ShouldNot(HaveOccurred())
session = startGinkgo(pkgPath, "nodot")
Eventually(session).Should(gexec.Exit(0))
byteContent, err = ioutil.ReadFile(filepath.Join(pkgPath, "foo_suite_test.go"))
Ω(err).ShouldNot(HaveOccurred())
Ω(byteContent).Should(ContainSubstring("var MyIt = ginkgo.It"))
Ω(byteContent).ShouldNot(ContainSubstring("var It = ginkgo.It"))
Ω(byteContent).Should(ContainSubstring("var Ω = gomega.Ω"))
})
})
Describe("ginkgo generate", func() {
var pkgPath string
BeforeEach(func() {
pkgPath = tmpPath("foo_bar")
os.Mkdir(pkgPath, 0777)
})
Context("with no arguments", func() {
It("should generate a test file named after the package", func() {
session := startGinkgo(pkgPath, "generate")
Eventually(session).Should(gexec.Exit(0))
output := session.Out.Contents()
Ω(output).Should(ContainSubstring("foo_bar_test.go"))
content, err := ioutil.ReadFile(filepath.Join(pkgPath, "foo_bar_test.go"))
Ω(err).ShouldNot(HaveOccurred())
Ω(content).Should(ContainSubstring("package foo_bar_test"))
Ω(content).Should(ContainSubstring(`var _ = Describe("FooBar", func() {`))
Ω(content).Should(ContainSubstring("\t" + `. "github.com/onsi/ginkgo"`))
Ω(content).Should(ContainSubstring("\t" + `. "github.com/onsi/gomega"`))
session = startGinkgo(pkgPath, "generate")
Eventually(session).Should(gexec.Exit(1))
output = session.Out.Contents()
Ω(output).Should(ContainSubstring("foo_bar_test.go already exists"))
})
})
Context("with an argument of the form: foo", func() {
It("should generate a test file named after the argument", func() {
session := startGinkgo(pkgPath, "generate", "baz_buzz")
Eventually(session).Should(gexec.Exit(0))
output := session.Out.Contents()
Ω(output).Should(ContainSubstring("baz_buzz_test.go"))
content, err := ioutil.ReadFile(filepath.Join(pkgPath, "baz_buzz_test.go"))
Ω(err).ShouldNot(HaveOccurred())
Ω(content).Should(ContainSubstring("package foo_bar_test"))
Ω(content).Should(ContainSubstring(`var _ = Describe("BazBuzz", func() {`))
})
})
Context("with an argument of the form: foo.go", func() {
It("should generate a test file named after the argument", func() {
session := startGinkgo(pkgPath, "generate", "baz_buzz.go")
Eventually(session).Should(gexec.Exit(0))
output := session.Out.Contents()
Ω(output).Should(ContainSubstring("baz_buzz_test.go"))
content, err := ioutil.ReadFile(filepath.Join(pkgPath, "baz_buzz_test.go"))
Ω(err).ShouldNot(HaveOccurred())
Ω(content).Should(ContainSubstring("package foo_bar_test"))
Ω(content).Should(ContainSubstring(`var _ = Describe("BazBuzz", func() {`))
})
})
Context("with an argument of the form: foo_test", func() {
It("should generate a test file named after the argument", func() {
session := startGinkgo(pkgPath, "generate", "baz_buzz_test")
Eventually(session).Should(gexec.Exit(0))
output := session.Out.Contents()
Ω(output).Should(ContainSubstring("baz_buzz_test.go"))
content, err := ioutil.ReadFile(filepath.Join(pkgPath, "baz_buzz_test.go"))
Ω(err).ShouldNot(HaveOccurred())
Ω(content).Should(ContainSubstring("package foo_bar_test"))
Ω(content).Should(ContainSubstring(`var _ = Describe("BazBuzz", func() {`))
})
})
Context("with an argument of the form: foo_test.go", func() {
It("should generate a test file named after the argument", func() {
session := startGinkgo(pkgPath, "generate", "baz_buzz_test.go")
Eventually(session).Should(gexec.Exit(0))
output := session.Out.Contents()
Ω(output).Should(ContainSubstring("baz_buzz_test.go"))
content, err := ioutil.ReadFile(filepath.Join(pkgPath, "baz_buzz_test.go"))
Ω(err).ShouldNot(HaveOccurred())
Ω(content).Should(ContainSubstring("package foo_bar_test"))
Ω(content).Should(ContainSubstring(`var _ = Describe("BazBuzz", func() {`))
})
})
Context("with multiple arguments", func() {
It("should generate a test file named after the argument", func() {
session := startGinkgo(pkgPath, "generate", "baz", "buzz")
Eventually(session).Should(gexec.Exit(0))
output := session.Out.Contents()
Ω(output).Should(ContainSubstring("baz_test.go"))
Ω(output).Should(ContainSubstring("buzz_test.go"))
content, err := ioutil.ReadFile(filepath.Join(pkgPath, "baz_test.go"))
Ω(err).ShouldNot(HaveOccurred())
Ω(content).Should(ContainSubstring("package foo_bar_test"))
Ω(content).Should(ContainSubstring(`var _ = Describe("Baz", func() {`))
content, err = ioutil.ReadFile(filepath.Join(pkgPath, "buzz_test.go"))
Ω(err).ShouldNot(HaveOccurred())
Ω(content).Should(ContainSubstring("package foo_bar_test"))
Ω(content).Should(ContainSubstring(`var _ = Describe("Buzz", func() {`))
})
})
Context("with nodot", func() {
It("should not import ginkgo or gomega", func() {
session := startGinkgo(pkgPath, "generate", "--nodot")
Eventually(session).Should(gexec.Exit(0))
output := session.Out.Contents()
Ω(output).Should(ContainSubstring("foo_bar_test.go"))
content, err := ioutil.ReadFile(filepath.Join(pkgPath, "foo_bar_test.go"))
Ω(err).ShouldNot(HaveOccurred())
Ω(content).Should(ContainSubstring("package foo_bar_test"))
Ω(content).ShouldNot(ContainSubstring("\t" + `. "github.com/onsi/ginkgo"`))
Ω(content).ShouldNot(ContainSubstring("\t" + `. "github.com/onsi/gomega"`))
})
})
Context("with agouti", func() {
It("should generate an agouti test file", func() {
session := startGinkgo(pkgPath, "generate", "--agouti")
Eventually(session).Should(gexec.Exit(0))
output := session.Out.Contents()
Ω(output).Should(ContainSubstring("foo_bar_test.go"))
content, err := ioutil.ReadFile(filepath.Join(pkgPath, "foo_bar_test.go"))
Ω(err).ShouldNot(HaveOccurred())
Ω(content).Should(ContainSubstring("package foo_bar_test"))
Ω(content).Should(ContainSubstring("\t" + `. "github.com/onsi/ginkgo"`))
Ω(content).Should(ContainSubstring("\t" + `. "github.com/onsi/gomega"`))
Ω(content).Should(ContainSubstring("\t" + `. "github.com/sclevine/agouti/matchers"`))
Ω(content).Should(ContainSubstring("\t" + `"github.com/sclevine/agouti"`))
Ω(content).Should(ContainSubstring("page, err = agoutiDriver.NewPage()"))
})
})
})
Describe("ginkgo bootstrap/generate", func() {
var pkgPath string
BeforeEach(func() {
pkgPath = tmpPath("some crazy-thing")
os.Mkdir(pkgPath, 0777)
})
Context("when the working directory is empty", func() {
It("generates correctly named bootstrap and generate files with a package name derived from the directory", func() {
session := startGinkgo(pkgPath, "bootstrap")
Eventually(session).Should(gexec.Exit(0))
content, err := ioutil.ReadFile(filepath.Join(pkgPath, "some_crazy_thing_suite_test.go"))
Ω(err).ShouldNot(HaveOccurred())
Ω(content).Should(ContainSubstring("package some_crazy_thing_test"))
Ω(content).Should(ContainSubstring("SomeCrazyThing Suite"))
session = startGinkgo(pkgPath, "generate")
Eventually(session).Should(gexec.Exit(0))
content, err = ioutil.ReadFile(filepath.Join(pkgPath, "some_crazy_thing_test.go"))
Ω(err).ShouldNot(HaveOccurred())
Ω(content).Should(ContainSubstring("package some_crazy_thing_test"))
Ω(content).Should(ContainSubstring("SomeCrazyThing"))
})
})
Context("when the working directory contains a file with a package name", func() {
BeforeEach(func() {
Ω(ioutil.WriteFile(filepath.Join(pkgPath, "foo.go"), []byte("package main\n\nfunc main() {}"), 0777)).Should(Succeed())
})
It("generates correctly named bootstrap and generate files with the package name", func() {
session := startGinkgo(pkgPath, "bootstrap")
Eventually(session).Should(gexec.Exit(0))
content, err := ioutil.ReadFile(filepath.Join(pkgPath, "some_crazy_thing_suite_test.go"))
Ω(err).ShouldNot(HaveOccurred())
Ω(content).Should(ContainSubstring("package main_test"))
Ω(content).Should(ContainSubstring("SomeCrazyThing Suite"))
session = startGinkgo(pkgPath, "generate")
Eventually(session).Should(gexec.Exit(0))
content, err = ioutil.ReadFile(filepath.Join(pkgPath, "some_crazy_thing_test.go"))
Ω(err).ShouldNot(HaveOccurred())
Ω(content).Should(ContainSubstring("package main_test"))
Ω(content).Should(ContainSubstring("SomeCrazyThing"))
})
})
})
Describe("ginkgo blur", func() {
It("should unfocus tests", func() {
pathToTest := tmpPath("focused")
copyIn("focused_fixture", pathToTest)
session := startGinkgo(pathToTest, "--noColor")
Eventually(session).Should(gexec.Exit(types.GINKGO_FOCUS_EXIT_CODE))
output := session.Out.Contents()
Ω(output).Should(ContainSubstring("6 Passed"))
Ω(output).Should(ContainSubstring("5 Skipped"))
session = startGinkgo(pathToTest, "blur")
Eventually(session).Should(gexec.Exit(0))
session = startGinkgo(pathToTest, "--noColor")
Eventually(session).Should(gexec.Exit(0))
output = session.Out.Contents()
Ω(output).Should(ContainSubstring("11 Passed"))
Ω(output).Should(ContainSubstring("0 Skipped"))
})
})
Describe("ginkgo version", func() {
It("should print out the version info", func() {
session := startGinkgo("", "version")
Eventually(session).Should(gexec.Exit(0))
output := session.Out.Contents()
Ω(output).Should(MatchRegexp(`Ginkgo Version \d+\.\d+\.\d+`))
})
})
Describe("ginkgo help", func() {
It("should print out usage information", func() {
session := startGinkgo("", "help")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Err.Contents())
Ω(output).Should(MatchRegexp(`Ginkgo Version \d+\.\d+\.\d+`))
Ω(output).Should(ContainSubstring("ginkgo watch"))
Ω(output).Should(ContainSubstring("-succinct"))
Ω(output).Should(ContainSubstring("-nodes"))
Ω(output).Should(ContainSubstring("ginkgo generate"))
})
})
})

View File

@@ -1,63 +0,0 @@
package integration_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
)
var _ = Describe("Suite Command Specs", func() {
var pathToTest string
BeforeEach(func() {
pathToTest = tmpPath("suite_command")
copyIn("suite_command_tests", pathToTest)
})
It("Runs command after suite echoing out suite data, properly reporting suite name and passing status in successful command output", func() {
command := "-afterSuiteHook=echo THIS IS A (ginkgo-suite-passed) TEST OF THE (ginkgo-suite-name) SYSTEM, THIS IS ONLY A TEST"
expected := "THIS IS A [PASS] TEST OF THE suite_command SYSTEM, THIS IS ONLY A TEST"
session := startGinkgo(pathToTest, command)
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("1 Passed"))
Ω(output).Should(ContainSubstring("0 Failed"))
Ω(output).Should(ContainSubstring("1 Pending"))
Ω(output).Should(ContainSubstring("0 Skipped"))
Ω(output).Should(ContainSubstring("Test Suite Passed"))
Ω(output).Should(ContainSubstring("Post-suite command succeeded:"))
Ω(output).Should(ContainSubstring(expected))
})
It("Runs command after suite reporting that command failed", func() {
command := "-afterSuiteHook=exit 1"
session := startGinkgo(pathToTest, command)
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("1 Passed"))
Ω(output).Should(ContainSubstring("0 Failed"))
Ω(output).Should(ContainSubstring("1 Pending"))
Ω(output).Should(ContainSubstring("0 Skipped"))
Ω(output).Should(ContainSubstring("Test Suite Passed"))
Ω(output).Should(ContainSubstring("Post-suite command failed:"))
})
It("Runs command after suite echoing out suite data, properly reporting suite name and failing status in successful command output", func() {
command := "-afterSuiteHook=echo THIS IS A (ginkgo-suite-passed) TEST OF THE (ginkgo-suite-name) SYSTEM, THIS IS ONLY A TEST"
expected := "THIS IS A [FAIL] TEST OF THE suite_command SYSTEM, THIS IS ONLY A TEST"
session := startGinkgo(pathToTest, "-failOnPending=true", command)
Eventually(session).Should(gexec.Exit(1))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("1 Passed"))
Ω(output).Should(ContainSubstring("0 Failed"))
Ω(output).Should(ContainSubstring("1 Pending"))
Ω(output).Should(ContainSubstring("0 Skipped"))
Ω(output).Should(ContainSubstring("Test Suite Failed"))
Ω(output).Should(ContainSubstring("Post-suite command succeeded:"))
Ω(output).Should(ContainSubstring(expected))
})
})

View File

@@ -1,178 +0,0 @@
package integration_test
import (
"strings"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
)
var _ = Describe("SuiteSetup", func() {
var pathToTest string
Context("when the BeforeSuite and AfterSuite pass", func() {
BeforeEach(func() {
pathToTest = tmpPath("suite_setup")
copyIn("passing_suite_setup", pathToTest)
})
It("should run the BeforeSuite once, then run all the tests", func() {
session := startGinkgo(pathToTest, "--noColor")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())
Ω(strings.Count(output, "BEFORE SUITE")).Should(Equal(1))
Ω(strings.Count(output, "AFTER SUITE")).Should(Equal(1))
})
It("should run the BeforeSuite once per parallel node, then run all the tests", func() {
session := startGinkgo(pathToTest, "--noColor", "--nodes=2")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())
Ω(strings.Count(output, "BEFORE SUITE")).Should(Equal(2))
Ω(strings.Count(output, "AFTER SUITE")).Should(Equal(2))
})
})
Context("when the BeforeSuite fails", func() {
BeforeEach(func() {
pathToTest = tmpPath("suite_setup")
copyIn("failing_before_suite", pathToTest)
})
It("should run the BeforeSuite once, none of the tests, but it should run the AfterSuite", func() {
session := startGinkgo(pathToTest, "--noColor")
Eventually(session).Should(gexec.Exit(1))
output := string(session.Out.Contents())
Ω(strings.Count(output, "BEFORE SUITE")).Should(Equal(1))
Ω(strings.Count(output, "Test Panicked")).Should(Equal(1))
Ω(strings.Count(output, "AFTER SUITE")).Should(Equal(1))
Ω(output).ShouldNot(ContainSubstring("NEVER SEE THIS"))
})
It("should run the BeforeSuite once per parallel node, none of the tests, but it should run the AfterSuite for each node", func() {
session := startGinkgo(pathToTest, "--noColor", "--nodes=2")
Eventually(session).Should(gexec.Exit(1))
output := string(session.Out.Contents())
Ω(strings.Count(output, "BEFORE SUITE")).Should(Equal(2))
Ω(strings.Count(output, "Test Panicked")).Should(Equal(2))
Ω(strings.Count(output, "AFTER SUITE")).Should(Equal(2))
Ω(output).ShouldNot(ContainSubstring("NEVER SEE THIS"))
})
})
Context("when the AfterSuite fails", func() {
BeforeEach(func() {
pathToTest = tmpPath("suite_setup")
copyIn("failing_after_suite", pathToTest)
})
It("should run the BeforeSuite once, none of the tests, but it should run the AfterSuite", func() {
session := startGinkgo(pathToTest, "--noColor")
Eventually(session).Should(gexec.Exit(1))
output := string(session.Out.Contents())
Ω(strings.Count(output, "BEFORE SUITE")).Should(Equal(1))
Ω(strings.Count(output, "AFTER SUITE")).Should(Equal(1))
Ω(strings.Count(output, "Test Panicked")).Should(Equal(1))
Ω(strings.Count(output, "A TEST")).Should(Equal(2))
})
It("should run the BeforeSuite once per parallel node, none of the tests, but it should run the AfterSuite for each node", func() {
session := startGinkgo(pathToTest, "--noColor", "--nodes=2")
Eventually(session).Should(gexec.Exit(1))
output := string(session.Out.Contents())
Ω(strings.Count(output, "BEFORE SUITE")).Should(Equal(2))
Ω(strings.Count(output, "AFTER SUITE")).Should(Equal(2))
Ω(strings.Count(output, "Test Panicked")).Should(Equal(2))
Ω(strings.Count(output, "A TEST")).Should(Equal(2))
})
})
Context("With passing synchronized before and after suites", func() {
BeforeEach(func() {
pathToTest = tmpPath("suite_setup")
copyIn("synchronized_setup_tests", pathToTest)
})
Context("when run with one node", func() {
It("should do all the work on that one node", func() {
session := startGinkgo(pathToTest, "--noColor")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("BEFORE_A_1\nBEFORE_B_1: DATA"))
Ω(output).Should(ContainSubstring("AFTER_A_1\nAFTER_B_1"))
})
})
Context("when run across multiple nodes", func() {
It("should run the first BeforeSuite function (BEFORE_A) on node 1, the second (BEFORE_B) on all the nodes, the first AfterSuite (AFTER_A) on all the nodes, and then the second (AFTER_B) on Node 1 *after* everything else is finished", func() {
session := startGinkgo(pathToTest, "--noColor", "--nodes=3")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("BEFORE_A_1"))
Ω(output).Should(ContainSubstring("BEFORE_B_1: DATA"))
Ω(output).Should(ContainSubstring("BEFORE_B_2: DATA"))
Ω(output).Should(ContainSubstring("BEFORE_B_3: DATA"))
Ω(output).ShouldNot(ContainSubstring("BEFORE_A_2"))
Ω(output).ShouldNot(ContainSubstring("BEFORE_A_3"))
Ω(output).Should(ContainSubstring("AFTER_A_1"))
Ω(output).Should(ContainSubstring("AFTER_A_2"))
Ω(output).Should(ContainSubstring("AFTER_A_3"))
Ω(output).Should(ContainSubstring("AFTER_B_1"))
Ω(output).ShouldNot(ContainSubstring("AFTER_B_2"))
Ω(output).ShouldNot(ContainSubstring("AFTER_B_3"))
})
})
Context("when streaming across multiple nodes", func() {
It("should run the first BeforeSuite function (BEFORE_A) on node 1, the second (BEFORE_B) on all the nodes, the first AfterSuite (AFTER_A) on all the nodes, and then the second (AFTER_B) on Node 1 *after* everything else is finished", func() {
session := startGinkgo(pathToTest, "--noColor", "--nodes=3", "--stream")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("[1] BEFORE_A_1"))
Ω(output).Should(ContainSubstring("[1] BEFORE_B_1: DATA"))
Ω(output).Should(ContainSubstring("[2] BEFORE_B_2: DATA"))
Ω(output).Should(ContainSubstring("[3] BEFORE_B_3: DATA"))
Ω(output).ShouldNot(ContainSubstring("BEFORE_A_2"))
Ω(output).ShouldNot(ContainSubstring("BEFORE_A_3"))
Ω(output).Should(ContainSubstring("[1] AFTER_A_1"))
Ω(output).Should(ContainSubstring("[2] AFTER_A_2"))
Ω(output).Should(ContainSubstring("[3] AFTER_A_3"))
Ω(output).Should(ContainSubstring("[1] AFTER_B_1"))
Ω(output).ShouldNot(ContainSubstring("AFTER_B_2"))
Ω(output).ShouldNot(ContainSubstring("AFTER_B_3"))
})
})
})
Context("With a failing synchronized before suite", func() {
BeforeEach(func() {
pathToTest = tmpPath("suite_setup")
copyIn("exiting_synchronized_setup_tests", pathToTest)
})
It("should fail and let the user know that node 1 disappeared prematurely", func() {
session := startGinkgo(pathToTest, "--noColor", "--nodes=3")
Eventually(session).Should(gexec.Exit(1))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("Node 1 disappeared before completing BeforeSuite"))
Ω(output).Should(ContainSubstring("Ginkgo timed out waiting for all parallel nodes to report back!"))
})
})
})

View File

@@ -1,27 +0,0 @@
package integration_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
)
var _ = Describe("Tags", func() {
var pathToTest string
BeforeEach(func() {
pathToTest = tmpPath("tags")
copyIn("tags_tests", pathToTest)
})
It("should honor the passed in -tags flag", func() {
session := startGinkgo(pathToTest, "--noColor")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())
Ω(output).Should(ContainSubstring("Ran 1 of 1 Specs"))
session = startGinkgo(pathToTest, "--noColor", "-tags=complex_tests")
Eventually(session).Should(gexec.Exit(0))
output = string(session.Out.Contents())
Ω(output).Should(ContainSubstring("Ran 3 of 3 Specs"))
})
})

View File

@@ -1,25 +0,0 @@
package integration_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
)
var _ = Describe("TestDescription", func() {
var pathToTest string
BeforeEach(func() {
pathToTest = tmpPath("test_description")
copyIn("test_description", pathToTest)
})
It("should capture and emit information about the current test", func() {
session := startGinkgo(pathToTest, "--noColor")
Eventually(session).Should(gexec.Exit(1))
Ω(session).Should(gbytes.Say("TestDescription should pass:false"))
Ω(session).Should(gbytes.Say("TestDescription should fail:true"))
})
})

View File

@@ -1,90 +0,0 @@
package integration_test
import (
"regexp"
"runtime"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
)
var _ = Describe("Verbose And Succinct Mode", func() {
var pathToTest string
var otherPathToTest string
isWindows := (runtime.GOOS == "windows")
denoter := "•"
if isWindows {
denoter = "+"
}
Context("when running one package", func() {
BeforeEach(func() {
pathToTest = tmpPath("ginkgo")
copyIn("passing_ginkgo_tests", pathToTest)
})
It("should default to non-succinct mode", func() {
session := startGinkgo(pathToTest, "--noColor")
Eventually(session).Should(gexec.Exit(0))
output := session.Out.Contents()
Ω(output).Should(ContainSubstring("Running Suite: Passing_ginkgo_tests Suite"))
})
})
Context("when running more than one package", func() {
BeforeEach(func() {
pathToTest = tmpPath("ginkgo")
copyIn("passing_ginkgo_tests", pathToTest)
otherPathToTest = tmpPath("more_ginkgo")
copyIn("more_ginkgo_tests", otherPathToTest)
})
Context("with no flags set", func() {
It("should default to succinct mode", func() {
session := startGinkgo(pathToTest, "--noColor", pathToTest, otherPathToTest)
Eventually(session).Should(gexec.Exit(0))
output := session.Out.Contents()
Ω(output).Should(MatchRegexp(`\] Passing_ginkgo_tests Suite - 4/4 specs [%s]{4} SUCCESS!`, regexp.QuoteMeta(denoter)))
Ω(output).Should(MatchRegexp(`\] More_ginkgo_tests Suite - 2/2 specs [%s]{2} SUCCESS!`, regexp.QuoteMeta(denoter)))
})
})
Context("with --succinct=false", func() {
It("should not be in succinct mode", func() {
session := startGinkgo(pathToTest, "--noColor", "--succinct=false", pathToTest, otherPathToTest)
Eventually(session).Should(gexec.Exit(0))
output := session.Out.Contents()
Ω(output).Should(ContainSubstring("Running Suite: Passing_ginkgo_tests Suite"))
Ω(output).Should(ContainSubstring("Running Suite: More_ginkgo_tests Suite"))
})
})
Context("with -v", func() {
It("should not be in succinct mode, but should be verbose", func() {
session := startGinkgo(pathToTest, "--noColor", "-v", pathToTest, otherPathToTest)
Eventually(session).Should(gexec.Exit(0))
output := session.Out.Contents()
Ω(output).Should(ContainSubstring("Running Suite: Passing_ginkgo_tests Suite"))
Ω(output).Should(ContainSubstring("Running Suite: More_ginkgo_tests Suite"))
Ω(output).Should(ContainSubstring("should proxy strings"))
Ω(output).Should(ContainSubstring("should always pass"))
})
It("should emit output from Bys", func() {
session := startGinkgo(pathToTest, "--noColor", "-v", pathToTest)
Eventually(session).Should(gexec.Exit(0))
output := session.Out.Contents()
Ω(output).Should(ContainSubstring("emitting one By"))
Ω(output).Should(ContainSubstring("emitting another By"))
})
})
})
})

View File

@@ -1,239 +0,0 @@
package integration_test
import (
"io/ioutil"
"os"
"path/filepath"
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
)
var _ = Describe("Watch", func() {
var rootPath string
var pathA string
var pathB string
var pathC string
var session *gexec.Session
BeforeEach(func() {
rootPath = tmpPath("root")
pathA = filepath.Join(rootPath, "src", "github.com", "onsi", "A")
pathB = filepath.Join(rootPath, "src", "github.com", "onsi", "B")
pathC = filepath.Join(rootPath, "src", "github.com", "onsi", "C")
err := os.MkdirAll(pathA, 0700)
Ω(err).ShouldNot(HaveOccurred())
err = os.MkdirAll(pathB, 0700)
Ω(err).ShouldNot(HaveOccurred())
err = os.MkdirAll(pathC, 0700)
Ω(err).ShouldNot(HaveOccurred())
copyIn(filepath.Join("watch_fixtures", "A"), pathA)
copyIn(filepath.Join("watch_fixtures", "B"), pathB)
copyIn(filepath.Join("watch_fixtures", "C"), pathC)
})
startGinkgoWithGopath := func(args ...string) *gexec.Session {
cmd := ginkgoCommand(rootPath, args...)
cmd.Env = append([]string{"GOPATH=" + rootPath + ":" + os.Getenv("GOPATH")}, os.Environ()...)
session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
Ω(err).ShouldNot(HaveOccurred())
return session
}
modifyFile := func(path string) {
time.Sleep(time.Second)
content, err := ioutil.ReadFile(path)
Ω(err).ShouldNot(HaveOccurred())
content = append(content, []byte("//")...)
err = ioutil.WriteFile(path, content, 0666)
Ω(err).ShouldNot(HaveOccurred())
}
modifyCode := func(pkgToModify string) {
modifyFile(filepath.Join(rootPath, "src", "github.com", "onsi", pkgToModify, pkgToModify+".go"))
}
modifyTest := func(pkgToModify string) {
modifyFile(filepath.Join(rootPath, "src", "github.com", "onsi", pkgToModify, pkgToModify+"_test.go"))
}
AfterEach(func() {
if session != nil {
session.Kill().Wait()
}
})
It("should be set up correctly", func() {
session = startGinkgoWithGopath("-r")
Eventually(session).Should(gexec.Exit(0))
Ω(session.Out.Contents()).Should(ContainSubstring("A Suite"))
Ω(session.Out.Contents()).Should(ContainSubstring("B Suite"))
Ω(session.Out.Contents()).Should(ContainSubstring("C Suite"))
Ω(session.Out.Contents()).Should(ContainSubstring("Ginkgo ran 3 suites"))
})
Context("when watching just one test suite", func() {
It("should immediately run, and should rerun when the test suite changes", func() {
session = startGinkgoWithGopath("watch", "-succinct", pathA)
Eventually(session).Should(gbytes.Say("A Suite"))
modifyCode("A")
Eventually(session).Should(gbytes.Say("Detected changes in"))
Eventually(session).Should(gbytes.Say("A Suite"))
session.Kill().Wait()
})
})
Context("when watching several test suites", func() {
It("should not immediately run, but should rerun a test when its code changes", func() {
session = startGinkgoWithGopath("watch", "-succinct", "-r")
Eventually(session).Should(gbytes.Say("Identified 3 test suites"))
Consistently(session).ShouldNot(gbytes.Say("A Suite|B Suite|C Suite"))
modifyCode("A")
Eventually(session).Should(gbytes.Say("Detected changes in"))
Eventually(session).Should(gbytes.Say("A Suite"))
Consistently(session).ShouldNot(gbytes.Say("B Suite|C Suite"))
session.Kill().Wait()
})
})
Describe("watching dependencies", func() {
Context("with a depth of 2", func() {
It("should watch down to that depth", func() {
session = startGinkgoWithGopath("watch", "-succinct", "-r", "-depth=2")
Eventually(session).Should(gbytes.Say("Identified 3 test suites"))
Eventually(session).Should(gbytes.Say(`A \[2 dependencies\]`))
Eventually(session).Should(gbytes.Say(`B \[1 dependency\]`))
Eventually(session).Should(gbytes.Say(`C \[0 dependencies\]`))
modifyCode("A")
Eventually(session).Should(gbytes.Say("Detected changes in"))
Eventually(session).Should(gbytes.Say("A Suite"))
Consistently(session).ShouldNot(gbytes.Say("B Suite|C Suite"))
modifyCode("B")
Eventually(session).Should(gbytes.Say("Detected changes in"))
Eventually(session).Should(gbytes.Say("B Suite"))
Eventually(session).Should(gbytes.Say("A Suite"))
Consistently(session).ShouldNot(gbytes.Say("C Suite"))
modifyCode("C")
Eventually(session).Should(gbytes.Say("Detected changes in"))
Eventually(session).Should(gbytes.Say("C Suite"))
Eventually(session).Should(gbytes.Say("B Suite"))
Eventually(session).Should(gbytes.Say("A Suite"))
})
})
Context("with a depth of 1", func() {
It("should watch down to that depth", func() {
session = startGinkgoWithGopath("watch", "-succinct", "-r", "-depth=1")
Eventually(session).Should(gbytes.Say("Identified 3 test suites"))
Eventually(session).Should(gbytes.Say(`A \[1 dependency\]`))
Eventually(session).Should(gbytes.Say(`B \[1 dependency\]`))
Eventually(session).Should(gbytes.Say(`C \[0 dependencies\]`))
modifyCode("A")
Eventually(session).Should(gbytes.Say("Detected changes in"))
Eventually(session).Should(gbytes.Say("A Suite"))
Consistently(session).ShouldNot(gbytes.Say("B Suite|C Suite"))
modifyCode("B")
Eventually(session).Should(gbytes.Say("Detected changes in"))
Eventually(session).Should(gbytes.Say("B Suite"))
Eventually(session).Should(gbytes.Say("A Suite"))
Consistently(session).ShouldNot(gbytes.Say("C Suite"))
modifyCode("C")
Eventually(session).Should(gbytes.Say("Detected changes in"))
Eventually(session).Should(gbytes.Say("C Suite"))
Eventually(session).Should(gbytes.Say("B Suite"))
Consistently(session).ShouldNot(gbytes.Say("A Suite"))
})
})
Context("with a depth of 0", func() {
It("should not watch any dependencies", func() {
session = startGinkgoWithGopath("watch", "-succinct", "-r", "-depth=0")
Eventually(session).Should(gbytes.Say("Identified 3 test suites"))
Eventually(session).Should(gbytes.Say(`A \[0 dependencies\]`))
Eventually(session).Should(gbytes.Say(`B \[0 dependencies\]`))
Eventually(session).Should(gbytes.Say(`C \[0 dependencies\]`))
modifyCode("A")
Eventually(session).Should(gbytes.Say("Detected changes in"))
Eventually(session).Should(gbytes.Say("A Suite"))
Consistently(session).ShouldNot(gbytes.Say("B Suite|C Suite"))
modifyCode("B")
Eventually(session).Should(gbytes.Say("Detected changes in"))
Eventually(session).Should(gbytes.Say("B Suite"))
Consistently(session).ShouldNot(gbytes.Say("A Suite|C Suite"))
modifyCode("C")
Eventually(session).Should(gbytes.Say("Detected changes in"))
Eventually(session).Should(gbytes.Say("C Suite"))
Consistently(session).ShouldNot(gbytes.Say("A Suite|B Suite"))
})
})
It("should not trigger dependents when tests are changed", func() {
session = startGinkgoWithGopath("watch", "-succinct", "-r", "-depth=2")
Eventually(session).Should(gbytes.Say("Identified 3 test suites"))
Eventually(session).Should(gbytes.Say(`A \[2 dependencies\]`))
Eventually(session).Should(gbytes.Say(`B \[1 dependency\]`))
Eventually(session).Should(gbytes.Say(`C \[0 dependencies\]`))
modifyTest("A")
Eventually(session).Should(gbytes.Say("Detected changes in"))
Eventually(session).Should(gbytes.Say("A Suite"))
Consistently(session).ShouldNot(gbytes.Say("B Suite|C Suite"))
modifyTest("B")
Eventually(session).Should(gbytes.Say("Detected changes in"))
Eventually(session).Should(gbytes.Say("B Suite"))
Consistently(session).ShouldNot(gbytes.Say("A Suite|C Suite"))
modifyTest("C")
Eventually(session).Should(gbytes.Say("Detected changes in"))
Eventually(session).Should(gbytes.Say("C Suite"))
Consistently(session).ShouldNot(gbytes.Say("A Suite|B Suite"))
})
})
Describe("when new test suite is added", func() {
It("should start monitoring that test suite", func() {
session = startGinkgoWithGopath("watch", "-succinct", "-r")
Eventually(session).Should(gbytes.Say("Watching 3 suites"))
pathD := filepath.Join(rootPath, "src", "github.com", "onsi", "D")
err := os.MkdirAll(pathD, 0700)
Ω(err).ShouldNot(HaveOccurred())
copyIn(filepath.Join("watch_fixtures", "D"), pathD)
Eventually(session).Should(gbytes.Say("Detected 1 new suite"))
Eventually(session).Should(gbytes.Say(`D \[1 dependency\]`))
Eventually(session).Should(gbytes.Say("D Suite"))
modifyCode("D")
Eventually(session).Should(gbytes.Say("Detected changes in"))
Eventually(session).Should(gbytes.Say("D Suite"))
modifyCode("C")
Eventually(session).Should(gbytes.Say("Detected changes in"))
Eventually(session).Should(gbytes.Say("C Suite"))
Eventually(session).Should(gbytes.Say("D Suite"))
})
})
})