Ejemplo n.º 1
0
	. "github.com/zerobotlabs/relax/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/writer"
	. "github.com/zerobotlabs/relax/Godeps/_workspace/src/github.com/onsi/gomega"
)

var _ = Describe("Writer", func() {
	var writer *Writer
	var out *gbytes.Buffer

	BeforeEach(func() {
		out = gbytes.NewBuffer()
		writer = New(out)
	})

	It("should stream directly to the outbuffer by default", func() {
		writer.Write([]byte("foo"))
		Ω(out).Should(gbytes.Say("foo"))
	})

	It("should not emit the header when asked to DumpOutWitHeader", func() {
		writer.Write([]byte("foo"))
		writer.DumpOutWithHeader("my header")
		Ω(out).ShouldNot(gbytes.Say("my header"))
		Ω(out).Should(gbytes.Say("foo"))
	})

	Context("when told not to stream", func() {
		BeforeEach(func() {
			writer.SetStream(false)
		})

		It("should only write to the buffer when told to DumpOut", func() {
Ejemplo n.º 2
0
					newContainer("outer container", noneFlag,
						newBef("outer bef A", false),
						newJusBef("outer jusbef A", false),
						newAft("outer aft A", false),
					),
					newContainer("inner container", noneFlag,
						newBef("inner bef A", false),
						newJusBef("inner jusbef A", false),
						newAft("inner aft A", false),
					),
				),
				true,
			)
			spec.Run(buffer)

			Ω(buffer).Should(gbytes.Say(`\[BeforeEach\] outer container`))
			Ω(buffer).Should(gbytes.Say(`\[BeforeEach\] inner container`))
			Ω(buffer).Should(gbytes.Say(`\[JustBeforeEach\] outer container`))
			Ω(buffer).Should(gbytes.Say(`\[JustBeforeEach\] inner container`))
			Ω(buffer).Should(gbytes.Say(`\[It\] it node`))
			Ω(buffer).Should(gbytes.Say(`\[AfterEach\] inner container`))
			Ω(buffer).Should(gbytes.Say(`\[AfterEach\] outer container`))
		})

		It("should emit progress to the writer as it runs Befores, JustBefores, Afters, and Measures", func() {
			spec = New(
				newMeasure("measure node", noneFlag, false, 2),
				containers(),
				true,
			)
			spec.Run(buffer)
Ejemplo n.º 3
0
		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() {
Ejemplo n.º 4
0
		Ω(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"))
	})
})
Ejemplo n.º 5
0
		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"))
		})
	})
})
Ejemplo n.º 6
0
package integration_test

import (
	. "github.com/zerobotlabs/relax/Godeps/_workspace/src/github.com/onsi/ginkgo"
	. "github.com/zerobotlabs/relax/Godeps/_workspace/src/github.com/onsi/gomega"
	"github.com/zerobotlabs/relax/Godeps/_workspace/src/github.com/onsi/gomega/gbytes"
	"github.com/zerobotlabs/relax/Godeps/_workspace/src/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"))
	})
})
Ejemplo n.º 7
0
			})
		})
	})

	Describe("Logging to the Writer", func() {
		var buf *gbytes.Buffer
		BeforeEach(func() {
			buf = gbytes.NewBuffer()
			s.Writer = buf
			s.AppendHandlers(func(w http.ResponseWriter, req *http.Request) {})
			s.AppendHandlers(func(w http.ResponseWriter, req *http.Request) {})
		})

		It("should write to the buffer when a request comes in", func() {
			http.Get(s.URL() + "/foo")
			Ω(buf).Should(gbytes.Say("GHTTP Received Request: GET - /foo\n"))

			http.Post(s.URL()+"/bar", "", nil)
			Ω(buf).Should(gbytes.Say("GHTTP Received Request: POST - /bar\n"))
		})
	})

	Describe("Request Handlers", func() {
		Describe("VerifyRequest", func() {
			BeforeEach(func() {
				s.AppendHandlers(VerifyRequest("GET", "/foo"))
			})

			It("should verify the method, path", func() {
				resp, err = http.Get(s.URL() + "/foo?baz=bar")
				Ω(err).ShouldNot(HaveOccurred())
Ejemplo n.º 8
0
		}
	})

	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"))
Ejemplo n.º 9
0
		})
	})

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