diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 6a18143..6ac7886 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,24 +1,24 @@ { "ImportPath": "github.com/concourse/autopilot", - "GoVersion": "go1.3.3", + "GoVersion": "go1.4.2", "Packages": [ "./..." ], "Deps": [ { "ImportPath": "github.com/cloudfoundry/cli/plugin", - "Comment": "v6.7.0-97-g8c42f92", - "Rev": "8c42f925d35ff55d1005e64131178d76852b0146" + "Comment": "v6.10.0-30-gba2a20f", + "Rev": "ba2a20fb1e0e327e672513970a13efb67ec1b1ae" }, { "ImportPath": "github.com/onsi/ginkgo", - "Comment": "v1.1.0-28-g7d3d52b", - "Rev": "7d3d52b3a3a79d745c2a03ee81b5bc2086642201" + "Comment": "v1.1.0-33-g17ea479", + "Rev": "17ea479729ee427265ac1e913443018350946ddf" }, { "ImportPath": "github.com/onsi/gomega", - "Comment": "v1.0-25-g85936b2", - "Rev": "85936b29809b7df066a8d839dd105e158e510264" + "Comment": "v1.0-28-g8adf9e1", + "Rev": "8adf9e1730c55cdc590de7d49766cb2acc88d8f2" } ] } diff --git a/Godeps/_workspace/src/github.com/cloudfoundry/cli/plugin/plugin.go b/Godeps/_workspace/src/github.com/cloudfoundry/cli/plugin/plugin.go index 2d0f710..2393b36 100644 --- a/Godeps/_workspace/src/github.com/cloudfoundry/cli/plugin/plugin.go +++ b/Godeps/_workspace/src/github.com/cloudfoundry/cli/plugin/plugin.go @@ -16,12 +16,26 @@ type CliConnection interface { CliCommand(args ...string) ([]string, error) } +type VersionType struct { + Major int + Minor int + Build int +} + type PluginMetadata struct { Name string + Version VersionType Commands []Command } +type Usage struct { + Usage string + Options map[string]string +} + type Command struct { - Name string - HelpText string + Name string + Alias string + HelpText string + UsageDetails Usage //Detail usage to be displayed in `cf help ` } diff --git a/Godeps/_workspace/src/github.com/cloudfoundry/cli/plugin/rpc/cli_rpc_server.go b/Godeps/_workspace/src/github.com/cloudfoundry/cli/plugin/rpc/cli_rpc_server.go index 74452f9..67fb8c0 100644 --- a/Godeps/_workspace/src/github.com/cloudfoundry/cli/plugin/rpc/cli_rpc_server.go +++ b/Godeps/_workspace/src/github.com/cloudfoundry/cli/plugin/rpc/cli_rpc_server.go @@ -81,6 +81,10 @@ func (cli *CliRpcService) Start() error { return nil } +func (cmd *CliRpcService) SetTheApp(app *cli.App) { + cmd.RpcCmd.coreCommandRunner = app +} + func (cmd *CliRpcCmd) SetPluginMetadata(pluginMetadata plugin.PluginMetadata, retVal *bool) error { cmd.PluginMetadata = &pluginMetadata *retVal = true diff --git a/Godeps/_workspace/src/github.com/cloudfoundry/cli/plugin/rpc/run_plugin.go b/Godeps/_workspace/src/github.com/cloudfoundry/cli/plugin/rpc/run_plugin.go index 67984ac..9d89784 100644 --- a/Godeps/_workspace/src/github.com/cloudfoundry/cli/plugin/rpc/run_plugin.go +++ b/Godeps/_workspace/src/github.com/cloudfoundry/cli/plugin/rpc/run_plugin.go @@ -5,29 +5,25 @@ import ( "os/exec" "github.com/cloudfoundry/cli/cf/configuration/plugin_config" - "github.com/cloudfoundry/cli/cf/terminal" - "github.com/codegangsta/cli" ) -func RunMethodIfExists(coreCommandRunner *cli.App, args []string, outputCapture terminal.OutputCapture, terminalOutputSwitch terminal.TerminalOutputSwitch) bool { - pluginsConfig := plugin_config.NewPluginConfig(func(err error) { panic(err) }) - pluginList := pluginsConfig.Plugins() +func RunMethodIfExists(rpcService *CliRpcService, args []string, pluginList map[string]plugin_config.PluginMetadata) bool { for _, metadata := range pluginList { for _, command := range metadata.Commands { - if command.Name == args[0] { - cliServer, err := startCliServer(coreCommandRunner, outputCapture, terminalOutputSwitch) - if err != nil { - os.Exit(1) - } + if command.Name == args[0] || command.Alias == args[0] { + args[0] = command.Name + + rpcService.Start() + defer rpcService.Stop() + + pluginArgs := append([]string{rpcService.Port()}, args...) - defer cliServer.Stop() - pluginArgs := append([]string{cliServer.Port()}, args...) cmd := exec.Command(metadata.Location, pluginArgs...) cmd.Stdout = os.Stdout cmd.Stdin = os.Stdin defer stopPlugin(cmd) - err = cmd.Run() + err := cmd.Run() if err != nil { os.Exit(1) } @@ -38,20 +34,6 @@ func RunMethodIfExists(coreCommandRunner *cli.App, args []string, outputCapture return false } -func startCliServer(coreCommandRunner *cli.App, outputCapture terminal.OutputCapture, terminalOutputSwitch terminal.TerminalOutputSwitch) (*CliRpcService, error) { - cliServer, err := NewRpcService(coreCommandRunner, outputCapture, terminalOutputSwitch) - if err != nil { - return nil, err - } - - err = cliServer.Start() - if err != nil { - return nil, err - } - - return cliServer, nil -} - func stopPlugin(plugin *exec.Cmd) { plugin.Process.Kill() plugin.Wait() diff --git a/Godeps/_workspace/src/github.com/onsi/ginkgo/.travis.yml b/Godeps/_workspace/src/github.com/onsi/ginkgo/.travis.yml index 988b7b2..f8b6984 100644 --- a/Godeps/_workspace/src/github.com/onsi/ginkgo/.travis.yml +++ b/Godeps/_workspace/src/github.com/onsi/ginkgo/.travis.yml @@ -1,10 +1,10 @@ language: go go: - - 1.3 + - 1.4 install: - go get -v ./... - - go get code.google.com/p/go.tools/cmd/cover + - go get golang.org/x/tools/cmd/cover - go get github.com/onsi/gomega - go install github.com/onsi/ginkgo/ginkgo - export PATH=$PATH:$HOME/gopath/bin diff --git a/Godeps/_workspace/src/github.com/onsi/ginkgo/CHANGELOG.md b/Godeps/_workspace/src/github.com/onsi/ginkgo/CHANGELOG.md index 5309ac1..06c7428 100644 --- a/Godeps/_workspace/src/github.com/onsi/ginkgo/CHANGELOG.md +++ b/Godeps/_workspace/src/github.com/onsi/ginkgo/CHANGELOG.md @@ -24,10 +24,15 @@ Improvements: - The compiled `package.test` file can be run directly. This runs the tests in series. - To run precompiled tests in parallel, you can run: `ginkgo -p package.test` - Support `bootstrap`ping and `generate`ing [Agouti](http://agouti.org) specs. +- `ginkgo generate` and `ginkgo bootstrap` now honor the package name already defined in a given directory +- The `ginkgo` CLI ignores `SIGQUIT`. Prevents its stack dump from interlacing with the underlying test suite's stack dump. Bug Fixes: - If --skipPackages is used and all packages are skipped, Ginkgo should exit 0. +- Fix tempfile leak when running in parallel +- Fix incorrect failure message when a panic occurs during a parallel test run + ## 1.1.0 (8/2/2014) diff --git a/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/bootstrap_command.go b/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/bootstrap_command.go index b626079..daade74 100644 --- a/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/bootstrap_command.go +++ b/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/bootstrap_command.go @@ -9,6 +9,8 @@ import ( "strings" "text/template" + "go/build" + "github.com/onsi/ginkgo/ginkgo/nodot" ) @@ -41,9 +43,9 @@ import ( "testing" ) -func Test{{.FormattedPackage}}(t *testing.T) { +func Test{{.FormattedName}}(t *testing.T) { RegisterFailHandler(Fail) - RunSpecs(t, "{{.FormattedPackage}} Suite") + RunSpecs(t, "{{.FormattedName}} Suite") } ` @@ -57,9 +59,9 @@ import ( "testing" ) -func Test{{.FormattedPackage}}(t *testing.T) { +func Test{{.FormattedName}}(t *testing.T) { RegisterFailHandler(Fail) - RunSpecs(t, "{{.FormattedPackage}} Suite") + RunSpecs(t, "{{.FormattedName}} Suite") } var agoutiDriver WebDriver @@ -83,19 +85,37 @@ var _ = AfterSuite(func() { ` type bootstrapData struct { - Package string - FormattedPackage string - GinkgoImport string - GomegaImport string + Package string + FormattedName string + GinkgoImport string + GomegaImport string } -func getPackage() string { - workingDir, err := os.Getwd() +func getPackageAndFormattedName() (string, string, string) { + path, err := os.Getwd() + if err != nil { + complainAndQuit("Could not get current working directory: \n" + err.Error()) + } + + dirName := strings.Replace(filepath.Base(path), "-", "_", -1) + dirName = strings.Replace(dirName, " ", "_", -1) + + pkg, err := build.ImportDir(path, 0) + packageName := pkg.Name if err != nil { - complainAndQuit("Could not find package: " + err.Error()) + packageName = dirName } - packageName := filepath.Base(workingDir) - return strings.Replace(packageName, "-", "_", -1) + + formattedName := prettifyPackageName(filepath.Base(path)) + return packageName, dirName, formattedName +} + +func prettifyPackageName(name string) string { + name = strings.Replace(name, "-", " ", -1) + name = strings.Replace(name, "_", " ", -1) + name = strings.Title(name) + name = strings.Replace(name, " ", "", -1) + return name } func fileExists(path string) bool { @@ -107,13 +127,12 @@ func fileExists(path string) bool { } func generateBootstrap(agouti bool, noDot bool) { - packageName := getPackage() - formattedPackage := strings.Replace(strings.Title(strings.Replace(packageName, "_", " ", -1)), " ", "", -1) + packageName, bootstrapFilePrefix, formattedName := getPackageAndFormattedName() data := bootstrapData{ - Package: packageName, - FormattedPackage: formattedPackage, - GinkgoImport: `. "github.com/onsi/ginkgo"`, - GomegaImport: `. "github.com/onsi/gomega"`, + Package: packageName, + FormattedName: formattedName, + GinkgoImport: `. "github.com/onsi/ginkgo"`, + GomegaImport: `. "github.com/onsi/gomega"`, } if noDot { @@ -121,7 +140,7 @@ func generateBootstrap(agouti bool, noDot bool) { data.GomegaImport = `"github.com/onsi/gomega"` } - targetFile := fmt.Sprintf("%s_suite_test.go", packageName) + targetFile := fmt.Sprintf("%s_suite_test.go", bootstrapFilePrefix) if fileExists(targetFile) { fmt.Printf("%s already exists.\n\n", targetFile) os.Exit(1) diff --git a/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/build_command.go b/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/build_command.go index 78d99d9..badae02 100644 --- a/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/build_command.go +++ b/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/build_command.go @@ -6,12 +6,13 @@ import ( "os" "path/filepath" + "github.com/onsi/ginkgo/ginkgo/interrupthandler" "github.com/onsi/ginkgo/ginkgo/testrunner" ) func BuildBuildCommand() *Command { commandFlags := NewBuildCommandFlags(flag.NewFlagSet("build", flag.ExitOnError)) - interruptHandler := NewInterruptHandler() + interruptHandler := interrupthandler.NewInterruptHandler() builder := &SpecBuilder{ commandFlags: commandFlags, interruptHandler: interruptHandler, @@ -31,7 +32,7 @@ func BuildBuildCommand() *Command { type SpecBuilder struct { commandFlags *RunWatchAndBuildCommandFlags - interruptHandler *InterruptHandler + interruptHandler *interrupthandler.InterruptHandler } func (r *SpecBuilder) BuildSpecs(args []string, additionalArgs []string) { diff --git a/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/generate_command.go b/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/generate_command.go index 6911d21..ad25dd8 100644 --- a/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/generate_command.go +++ b/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/generate_command.go @@ -104,24 +104,22 @@ func generateSpec(args []string, agouti, noDot bool) { } func generateSpecForSubject(subject string, agouti, noDot bool) error { - packageName := getPackage() - if subject == "" { - subject = packageName - } else { + packageName, specFilePrefix, formattedName := getPackageAndFormattedName() + if subject != "" { subject = strings.Split(subject, ".go")[0] subject = strings.Split(subject, "_test")[0] + specFilePrefix = subject + formattedName = prettifyPackageName(subject) } - formattedSubject := strings.Replace(strings.Title(strings.Replace(subject, "_", " ", -1)), " ", "", -1) - data := specData{ Package: packageName, - Subject: formattedSubject, + Subject: formattedName, PackageImportPath: getPackageImportPath(), IncludeImports: !noDot, } - targetFile := fmt.Sprintf("%s_test.go", subject) + targetFile := fmt.Sprintf("%s_test.go", specFilePrefix) if fileExists(targetFile) { return fmt.Errorf("%s already exists.", targetFile) } else { diff --git a/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/interrupt_handler.go b/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/interrupthandler/interrupt_handler.go similarity index 94% rename from Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/interrupt_handler.go rename to Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/interrupthandler/interrupt_handler.go index 81567a4..82e49ad 100644 --- a/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/interrupt_handler.go +++ b/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/interrupthandler/interrupt_handler.go @@ -1,4 +1,4 @@ -package main +package interrupthandler import ( "os" @@ -19,6 +19,7 @@ func NewInterruptHandler() *InterruptHandler { } go h.handleInterrupt() + SwallowSigQuit() return h } diff --git a/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/interrupthandler/sigquit_swallower_unix.go b/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/interrupthandler/sigquit_swallower_unix.go new file mode 100644 index 0000000..14c9421 --- /dev/null +++ b/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/interrupthandler/sigquit_swallower_unix.go @@ -0,0 +1,14 @@ +// +build freebsd openbsd netbsd dragonfly darwin linux + +package interrupthandler + +import ( + "os" + "os/signal" + "syscall" +) + +func SwallowSigQuit() { + c := make(chan os.Signal, 1024) + signal.Notify(c, syscall.SIGQUIT) +} diff --git a/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/interrupthandler/sigquit_swallower_windows.go b/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/interrupthandler/sigquit_swallower_windows.go new file mode 100644 index 0000000..7f4a50e --- /dev/null +++ b/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/interrupthandler/sigquit_swallower_windows.go @@ -0,0 +1,7 @@ +// +build windows + +package interrupthandler + +func SwallowSigQuit() { + //noop +} diff --git a/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/run_command.go b/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/run_command.go index de65342..c8caa99 100644 --- a/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/run_command.go +++ b/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/run_command.go @@ -8,6 +8,7 @@ import ( "time" "github.com/onsi/ginkgo/config" + "github.com/onsi/ginkgo/ginkgo/interrupthandler" "github.com/onsi/ginkgo/ginkgo/testrunner" "github.com/onsi/ginkgo/types" ) @@ -15,7 +16,7 @@ import ( func BuildRunCommand() *Command { commandFlags := NewRunCommandFlags(flag.NewFlagSet("ginkgo", flag.ExitOnError)) notifier := NewNotifier(commandFlags) - interruptHandler := NewInterruptHandler() + interruptHandler := interrupthandler.NewInterruptHandler() runner := &SpecRunner{ commandFlags: commandFlags, notifier: notifier, @@ -39,7 +40,7 @@ func BuildRunCommand() *Command { type SpecRunner struct { commandFlags *RunWatchAndBuildCommandFlags notifier *Notifier - interruptHandler *InterruptHandler + interruptHandler *interrupthandler.InterruptHandler suiteRunner *SuiteRunner } diff --git a/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/suite_runner.go b/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/suite_runner.go index 194573d..28daf2e 100644 --- a/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/suite_runner.go +++ b/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/suite_runner.go @@ -5,13 +5,14 @@ import ( "runtime" "github.com/onsi/ginkgo/config" + "github.com/onsi/ginkgo/ginkgo/interrupthandler" "github.com/onsi/ginkgo/ginkgo/testrunner" "github.com/onsi/ginkgo/ginkgo/testsuite" ) type SuiteRunner struct { notifier *Notifier - interruptHandler *InterruptHandler + interruptHandler *interrupthandler.InterruptHandler } type compiler struct { @@ -31,7 +32,7 @@ func (c *compiler) compile() { c.compilationError <- err } -func NewSuiteRunner(notifier *Notifier, interruptHandler *InterruptHandler) *SuiteRunner { +func NewSuiteRunner(notifier *Notifier, interruptHandler *interrupthandler.InterruptHandler) *SuiteRunner { return &SuiteRunner{ notifier: notifier, interruptHandler: interruptHandler, diff --git a/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/watch_command.go b/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/watch_command.go index ae988fb..02e89f1 100644 --- a/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/watch_command.go +++ b/Godeps/_workspace/src/github.com/onsi/ginkgo/ginkgo/watch_command.go @@ -6,6 +6,7 @@ import ( "time" "github.com/onsi/ginkgo/config" + "github.com/onsi/ginkgo/ginkgo/interrupthandler" "github.com/onsi/ginkgo/ginkgo/testrunner" "github.com/onsi/ginkgo/ginkgo/testsuite" "github.com/onsi/ginkgo/ginkgo/watch" @@ -13,7 +14,7 @@ import ( func BuildWatchCommand() *Command { commandFlags := NewWatchCommandFlags(flag.NewFlagSet("watch", flag.ExitOnError)) - interruptHandler := NewInterruptHandler() + interruptHandler := interrupthandler.NewInterruptHandler() notifier := NewNotifier(commandFlags) watcher := &SpecWatcher{ commandFlags: commandFlags, @@ -41,7 +42,7 @@ func BuildWatchCommand() *Command { type SpecWatcher struct { commandFlags *RunWatchAndBuildCommandFlags notifier *Notifier - interruptHandler *InterruptHandler + interruptHandler *interrupthandler.InterruptHandler suiteRunner *SuiteRunner } diff --git a/Godeps/_workspace/src/github.com/onsi/ginkgo/integration/run_test.go b/Godeps/_workspace/src/github.com/onsi/ginkgo/integration/run_test.go index 5d2e924..c346bb3 100644 --- a/Godeps/_workspace/src/github.com/onsi/ginkgo/integration/run_test.go +++ b/Godeps/_workspace/src/github.com/onsi/ginkgo/integration/run_test.go @@ -217,7 +217,7 @@ var _ = Describe("Running Specs", func() { Eventually(session).Should(gexec.Exit(0)) output := string(session.Out.Contents()) - Ω(output).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs - 2 nodes •••• SUCCESS! [\d.mus]+`)) + Ω(output).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs - 2 nodes •••• SUCCESS! [\d.µs]+`)) Ω(output).Should(ContainSubstring("Test Suite Passed")) }) }) @@ -232,7 +232,7 @@ var _ = Describe("Running Specs", func() { if nodes > 4 { nodes = nodes - 1 } - Ω(output).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs - %d nodes •••• SUCCESS! [\d.mus]+`, nodes)) + Ω(output).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs - %d nodes •••• SUCCESS! [\d.µs]+`, nodes)) Ω(output).Should(ContainSubstring("Test Suite Passed")) }) }) @@ -272,8 +272,8 @@ var _ = Describe("Running Specs", func() { output := string(session.Out.Contents()) outputLines := strings.Split(output, "\n") - Ω(outputLines[0]).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs •••• SUCCESS! [\d.mus]+ PASS`)) - Ω(outputLines[1]).Should(MatchRegexp(`\[\d+\] More_ginkgo_tests Suite - 2/2 specs •• SUCCESS! [\d.mus]+ PASS`)) + Ω(outputLines[0]).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs •••• SUCCESS! [\d.µs]+ PASS`)) + Ω(outputLines[1]).Should(MatchRegexp(`\[\d+\] More_ginkgo_tests Suite - 2/2 specs •• SUCCESS! [\d.µs]+ PASS`)) Ω(output).Should(ContainSubstring("Test Suite Passed")) }) }) @@ -290,7 +290,7 @@ var _ = Describe("Running Specs", func() { output := string(session.Out.Contents()) outputLines := strings.Split(output, "\n") - Ω(outputLines[0]).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs •••• SUCCESS! [\d.mus]+ PASS`)) + Ω(outputLines[0]).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs •••• SUCCESS! [\d.µs]+ PASS`)) Ω(outputLines[1]).Should(MatchRegexp(`\[\d+\] Failing_ginkgo_tests Suite - 2/2 specs`)) Ω(output).Should(ContainSubstring("• Failure")) Ω(output).ShouldNot(ContainSubstring("More_ginkgo_tests Suite")) @@ -313,7 +313,7 @@ var _ = Describe("Running Specs", func() { output := string(session.Out.Contents()) outputLines := strings.Split(output, "\n") - Ω(outputLines[0]).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs •••• SUCCESS! [\d.mus]+ PASS`)) + Ω(outputLines[0]).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs •••• SUCCESS! [\d.µs]+ PASS`)) Ω(outputLines[1]).Should(ContainSubstring("Failed to compile C:")) Ω(output).ShouldNot(ContainSubstring("More_ginkgo_tests Suite")) Ω(output).Should(ContainSubstring("Test Suite Failed")) @@ -335,11 +335,11 @@ var _ = Describe("Running Specs", func() { output := string(session.Out.Contents()) outputLines := strings.Split(output, "\n") - Ω(outputLines[0]).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs •••• SUCCESS! [\d.mus]+ PASS`)) + Ω(outputLines[0]).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs •••• SUCCESS! [\d.µs]+ PASS`)) Ω(outputLines[1]).Should(ContainSubstring("Failed to compile B:")) Ω(output).Should(MatchRegexp(`\[\d+\] Failing_ginkgo_tests Suite - 2/2 specs`)) Ω(output).Should(ContainSubstring("• Failure")) - Ω(output).Should(MatchRegexp(`\[\d+\] More_ginkgo_tests Suite - 2/2 specs •• SUCCESS! [\d.mus]+ PASS`)) + Ω(output).Should(MatchRegexp(`\[\d+\] More_ginkgo_tests Suite - 2/2 specs •• SUCCESS! [\d.µs]+ PASS`)) Ω(output).Should(ContainSubstring("Test Suite Failed")) }) }) diff --git a/Godeps/_workspace/src/github.com/onsi/ginkgo/integration/subcommand_test.go b/Godeps/_workspace/src/github.com/onsi/ginkgo/integration/subcommand_test.go index 069bb30..0fb51a6 100644 --- a/Godeps/_workspace/src/github.com/onsi/ginkgo/integration/subcommand_test.go +++ b/Godeps/_workspace/src/github.com/onsi/ginkgo/integration/subcommand_test.go @@ -14,9 +14,13 @@ import ( var _ = Describe("Subcommand", func() { Describe("ginkgo bootstrap", func() { - It("should generate a bootstrap file, as long as one does not exist", func() { - pkgPath := tmpPath("foo") + 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() @@ -25,6 +29,7 @@ var _ = Describe("Subcommand", func() { 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")) @@ -39,8 +44,6 @@ var _ = Describe("Subcommand", func() { }) It("should import nodot declarations when told to", func() { - pkgPath := tmpPath("foo") - os.Mkdir(pkgPath, 0777) session := startGinkgo(pkgPath, "bootstrap", "--nodot") Eventually(session).Should(gexec.Exit(0)) output := session.Out.Contents() @@ -49,6 +52,7 @@ var _ = Describe("Subcommand", func() { 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")) @@ -61,8 +65,6 @@ var _ = Describe("Subcommand", func() { }) It("should generate an agouti bootstrap file when told to", func() { - pkgPath := tmpPath("foo") - os.Mkdir(pkgPath, 0777) session := startGinkgo(pkgPath, "bootstrap", "--agouti") Eventually(session).Should(gexec.Exit(0)) output := session.Out.Contents() @@ -71,6 +73,7 @@ var _ = Describe("Subcommand", func() { 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")) @@ -129,6 +132,7 @@ var _ = Describe("Subcommand", func() { 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"`)) @@ -151,6 +155,7 @@ var _ = Describe("Subcommand", func() { 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() {`)) }) }) @@ -165,6 +170,7 @@ var _ = Describe("Subcommand", func() { 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() {`)) }) @@ -180,6 +186,7 @@ var _ = Describe("Subcommand", func() { 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() {`)) }) }) @@ -194,6 +201,7 @@ var _ = Describe("Subcommand", func() { 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() {`)) }) }) @@ -209,10 +217,12 @@ var _ = Describe("Subcommand", func() { 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() {`)) }) }) @@ -227,6 +237,7 @@ var _ = Describe("Subcommand", func() { 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"`)) }) @@ -242,6 +253,7 @@ var _ = Describe("Subcommand", func() { 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/core"`)) @@ -251,6 +263,58 @@ var _ = Describe("Subcommand", func() { }) }) + 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") diff --git a/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/failer/failer.go b/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/failer/failer.go index 24bbfb2..4019666 100644 --- a/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/failer/failer.go +++ b/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/failer/failer.go @@ -1,8 +1,10 @@ package failer import ( - "github.com/onsi/ginkgo/types" + "fmt" "sync" + + "github.com/onsi/ginkgo/types" ) type Failer struct { @@ -27,7 +29,7 @@ func (f *Failer) Panic(location types.CodeLocation, forwardedPanic interface{}) f.failure = types.SpecFailure{ Message: "Test Panicked", Location: location, - ForwardedPanic: forwardedPanic, + ForwardedPanic: fmt.Sprintf("%v", forwardedPanic), } } } diff --git a/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/failer/failer_test.go b/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/failer/failer_test.go index 465b2cc..3da62db 100644 --- a/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/failer/failer_test.go +++ b/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/failer/failer_test.go @@ -37,7 +37,7 @@ var _ = Describe("Failer", func() { Ω(failure).Should(Equal(types.SpecFailure{ Message: "something failed", Location: codeLocationA, - ForwardedPanic: nil, + ForwardedPanic: "", ComponentType: types.SpecComponentTypeIt, ComponentIndex: 3, ComponentCodeLocation: codeLocationB, @@ -69,7 +69,7 @@ var _ = Describe("Failer", func() { Ω(failure).Should(Equal(types.SpecFailure{ Message: "Timed out", Location: codeLocationA, - ForwardedPanic: nil, + ForwardedPanic: "", ComponentType: types.SpecComponentTypeIt, ComponentIndex: 3, ComponentCodeLocation: codeLocationB, @@ -90,7 +90,7 @@ var _ = Describe("Failer", func() { Ω(failure).Should(Equal(types.SpecFailure{ Message: "something failed", Location: codeLocationA, - ForwardedPanic: nil, + ForwardedPanic: "", ComponentType: types.SpecComponentTypeIt, ComponentIndex: 3, ComponentCodeLocation: codeLocationB, @@ -107,7 +107,7 @@ var _ = Describe("Failer", func() { Ω(failure).Should(Equal(types.SpecFailure{ Message: "yet another thing failed", Location: codeLocationA, - ForwardedPanic: nil, + ForwardedPanic: "", ComponentType: types.SpecComponentTypeIt, ComponentIndex: 3, ComponentCodeLocation: codeLocationB, diff --git a/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/leafnodes/shared_runner_test.go b/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/leafnodes/shared_runner_test.go index 1293d24..9007d1b 100644 --- a/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/leafnodes/shared_runner_test.go +++ b/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/leafnodes/shared_runner_test.go @@ -72,7 +72,7 @@ func SynchronousSharedRunnerBehaviors(build func(body interface{}, timeout time. Ω(failure).Should(Equal(types.SpecFailure{ Message: "bam", Location: innerCodeLocation, - ForwardedPanic: nil, + ForwardedPanic: "", ComponentIndex: componentIndex, ComponentType: componentType, ComponentCodeLocation: componentCodeLocation, @@ -93,15 +93,7 @@ func SynchronousSharedRunnerBehaviors(build func(body interface{}, timeout time. Ω(didRun).Should(BeTrue()) Ω(outcome).Should(Equal(types.SpecStatePanicked)) - innerCodeLocation.LineNumber++ - Ω(failure).Should(Equal(types.SpecFailure{ - Message: "Test Panicked", - Location: innerCodeLocation, - ForwardedPanic: "ack!", - ComponentIndex: componentIndex, - ComponentType: componentType, - ComponentCodeLocation: componentCodeLocation, - })) + Ω(failure.ForwardedPanic).Should(Equal("ack!")) }) }) }) @@ -184,7 +176,7 @@ func AsynchronousSharedRunnerBehaviors(build func(body interface{}, timeout time Ω(failure).Should(Equal(types.SpecFailure{ Message: "bam", Location: innerCodeLocation, - ForwardedPanic: nil, + ForwardedPanic: "", ComponentIndex: componentIndex, ComponentType: componentType, ComponentCodeLocation: componentCodeLocation, @@ -214,7 +206,7 @@ func AsynchronousSharedRunnerBehaviors(build func(body interface{}, timeout time Ω(failure).Should(Equal(types.SpecFailure{ Message: "Timed out", Location: componentCodeLocation, - ForwardedPanic: nil, + ForwardedPanic: "", ComponentIndex: componentIndex, ComponentType: componentType, ComponentCodeLocation: componentCodeLocation, @@ -235,15 +227,7 @@ func AsynchronousSharedRunnerBehaviors(build func(body interface{}, timeout time Ω(didRun).Should(BeTrue()) Ω(outcome).Should(Equal(types.SpecStatePanicked)) - innerCodeLocation.LineNumber++ - Ω(failure).Should(Equal(types.SpecFailure{ - Message: "Test Panicked", - Location: innerCodeLocation, - ForwardedPanic: "ack!", - ComponentIndex: componentIndex, - ComponentType: componentType, - ComponentCodeLocation: componentCodeLocation, - })) + Ω(failure.ForwardedPanic).Should(Equal("ack!")) }) }) }) diff --git a/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/leafnodes/suite_nodes_test.go b/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/leafnodes/suite_nodes_test.go index 3341157..246b329 100644 --- a/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/leafnodes/suite_nodes_test.go +++ b/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/leafnodes/suite_nodes_test.go @@ -6,10 +6,11 @@ import ( . "github.com/onsi/ginkgo/internal/leafnodes" + "time" + "github.com/onsi/ginkgo/internal/codelocation" Failer "github.com/onsi/ginkgo/internal/failer" "github.com/onsi/ginkgo/types" - "time" ) var _ = Describe("SuiteNodes", func() { @@ -67,7 +68,7 @@ var _ = Describe("SuiteNodes", func() { Ω(summary.State).Should(Equal(types.SpecStateFailed)) Ω(summary.Failure.Message).Should(Equal("oops")) Ω(summary.Failure.Location).Should(Equal(innerCodeLocation)) - Ω(summary.Failure.ForwardedPanic).Should(BeNil()) + Ω(summary.Failure.ForwardedPanic).Should(BeEmpty()) Ω(summary.Failure.ComponentIndex).Should(Equal(0)) Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeBeforeSuite)) Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation)) @@ -89,7 +90,7 @@ var _ = Describe("SuiteNodes", func() { It("should have the correct summary", func() { summary := befSuite.Summary() Ω(summary.State).Should(Equal(types.SpecStateTimedOut)) - Ω(summary.Failure.ForwardedPanic).Should(BeNil()) + Ω(summary.Failure.ForwardedPanic).Should(BeEmpty()) Ω(summary.Failure.ComponentIndex).Should(Equal(0)) Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeBeforeSuite)) Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation)) @@ -174,7 +175,7 @@ var _ = Describe("SuiteNodes", func() { Ω(summary.State).Should(Equal(types.SpecStateFailed)) Ω(summary.Failure.Message).Should(Equal("oops")) Ω(summary.Failure.Location).Should(Equal(innerCodeLocation)) - Ω(summary.Failure.ForwardedPanic).Should(BeNil()) + Ω(summary.Failure.ForwardedPanic).Should(BeEmpty()) Ω(summary.Failure.ComponentIndex).Should(Equal(0)) Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeAfterSuite)) Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation)) @@ -196,7 +197,7 @@ var _ = Describe("SuiteNodes", func() { It("should have the correct summary", func() { summary := aftSuite.Summary() Ω(summary.State).Should(Equal(types.SpecStateTimedOut)) - Ω(summary.Failure.ForwardedPanic).Should(BeNil()) + Ω(summary.Failure.ForwardedPanic).Should(BeEmpty()) Ω(summary.Failure.ComponentIndex).Should(Equal(0)) Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeAfterSuite)) Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation)) diff --git a/Godeps/_workspace/src/github.com/onsi/ginkgo/reporters/stenographer/stenographer.go b/Godeps/_workspace/src/github.com/onsi/ginkgo/reporters/stenographer/stenographer.go index d56f193..d82cdb2 100644 --- a/Godeps/_workspace/src/github.com/onsi/ginkgo/reporters/stenographer/stenographer.go +++ b/Godeps/_workspace/src/github.com/onsi/ginkgo/reporters/stenographer/stenographer.go @@ -373,7 +373,7 @@ func (s *consoleStenographer) failureContext(failedComponentType types.SpecCompo func (s *consoleStenographer) printFailure(indentation int, state types.SpecState, failure types.SpecFailure, fullTrace bool) { if state == types.SpecStatePanicked { s.println(indentation, s.colorize(redColor+boldStyle, failure.Message)) - s.println(indentation, s.colorize(redColor, "%v", failure.ForwardedPanic)) + s.println(indentation, s.colorize(redColor, failure.ForwardedPanic)) s.println(indentation, failure.Location.String()) s.printNewLine() s.println(indentation, s.colorize(redColor, "Full Stack Trace")) diff --git a/Godeps/_workspace/src/github.com/onsi/ginkgo/types/types.go b/Godeps/_workspace/src/github.com/onsi/ginkgo/types/types.go index 4a3b213..583b347 100644 --- a/Godeps/_workspace/src/github.com/onsi/ginkgo/types/types.go +++ b/Godeps/_workspace/src/github.com/onsi/ginkgo/types/types.go @@ -1,8 +1,6 @@ package types -import ( - "time" -) +import "time" const GINKGO_FOCUS_EXIT_CODE = 197 @@ -79,7 +77,7 @@ type SetupSummary struct { type SpecFailure struct { Message string Location CodeLocation - ForwardedPanic interface{} + ForwardedPanic string ComponentIndex int ComponentType SpecComponentType diff --git a/Godeps/_workspace/src/github.com/onsi/gomega/gexec/prefixed_writer.go b/Godeps/_workspace/src/github.com/onsi/gomega/gexec/prefixed_writer.go index 556182b..05e695a 100644 --- a/Godeps/_workspace/src/github.com/onsi/gomega/gexec/prefixed_writer.go +++ b/Godeps/_workspace/src/github.com/onsi/gomega/gexec/prefixed_writer.go @@ -1,7 +1,6 @@ package gexec import ( - "bytes" "io" "sync" ) @@ -14,19 +13,18 @@ session by passing in a PrefixedWriter: gexec.Start(cmd, NewPrefixedWriter("[my-cmd] ", GinkgoWriter), NewPrefixedWriter("[my-cmd] ", GinkgoWriter)) */ type PrefixedWriter struct { - prefix []byte - writer io.Writer - lock *sync.Mutex - isNewLine bool - isFirstWrite bool + prefix []byte + writer io.Writer + lock *sync.Mutex + atStartOfLine bool } func NewPrefixedWriter(prefix string, writer io.Writer) *PrefixedWriter { return &PrefixedWriter{ - prefix: []byte(prefix), - writer: writer, - lock: &sync.Mutex{}, - isFirstWrite: true, + prefix: []byte(prefix), + writer: writer, + lock: &sync.Mutex{}, + atStartOfLine: true, } } @@ -34,46 +32,21 @@ func (w *PrefixedWriter) Write(b []byte) (int, error) { w.lock.Lock() defer w.lock.Unlock() - newLine := []byte("\n") - segments := bytes.Split(b, newLine) + toWrite := []byte{} - if len(segments) != 0 { - toWrite := []byte{} - if w.isFirstWrite { + for _, c := range b { + if w.atStartOfLine { toWrite = append(toWrite, w.prefix...) - toWrite = append(toWrite, segments[0]...) - w.isFirstWrite = false - } else if w.isNewLine { - toWrite = append(toWrite, newLine...) - toWrite = append(toWrite, w.prefix...) - toWrite = append(toWrite, segments[0]...) - } else { - toWrite = append(toWrite, segments[0]...) - } - - for i := 1; i < len(segments)-1; i++ { - toWrite = append(toWrite, newLine...) - toWrite = append(toWrite, w.prefix...) - toWrite = append(toWrite, segments[i]...) } - if len(segments) > 1 { - lastSegment := segments[len(segments)-1] + toWrite = append(toWrite, c) - if len(lastSegment) == 0 { - w.isNewLine = true - } else { - toWrite = append(toWrite, newLine...) - toWrite = append(toWrite, w.prefix...) - toWrite = append(toWrite, lastSegment...) - w.isNewLine = false - } - } + w.atStartOfLine = c == '\n' + } - _, err := w.writer.Write(toWrite) - if err != nil { - return 0, err - } + _, err := w.writer.Write(toWrite) + if err != nil { + return 0, err } return len(b), nil diff --git a/Godeps/_workspace/src/github.com/onsi/gomega/gexec/prefixed_writer_test.go b/Godeps/_workspace/src/github.com/onsi/gomega/gexec/prefixed_writer_test.go index 27f7487..8657d0c 100644 --- a/Godeps/_workspace/src/github.com/onsi/gomega/gexec/prefixed_writer_test.go +++ b/Godeps/_workspace/src/github.com/onsi/gomega/gexec/prefixed_writer_test.go @@ -2,6 +2,7 @@ package gexec_test import ( "bytes" + . "github.com/onsi/gomega/gexec" . "github.com/onsi/ginkgo" @@ -36,6 +37,7 @@ var _ = Describe("PrefixedWriter", func() { [p]nopqrs [p]tuv [p]wxyz -[p]`)) +[p] +`)) }) }) diff --git a/Godeps/_workspace/src/github.com/onsi/gomega/ghttp/test_server.go b/Godeps/_workspace/src/github.com/onsi/gomega/ghttp/test_server.go index 1e5afc8..4bbb2e4 100644 --- a/Godeps/_workspace/src/github.com/onsi/gomega/ghttp/test_server.go +++ b/Godeps/_workspace/src/github.com/onsi/gomega/ghttp/test_server.go @@ -182,6 +182,11 @@ func (s *Server) URL() string { return s.HTTPTestServer.URL } +//Addr() returns the address on which the server is listening. +func (s *Server) Addr() string { + return s.HTTPTestServer.Listener.Addr().String() +} + //Close() should be called at the end of each test. It spins down and cleans up the test server. func (s *Server) Close() { s.writeLock.Lock()