当前位置: 首页>>代码示例>>Golang>>正文


Golang codelocation.New函数代码示例

本文整理汇总了Golang中github.com/zerobotlabs/relax/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/codelocation.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了New函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Fail

//Fail notifies Ginkgo that the current spec has failed. (Gomega will call Fail for you automatically when an assertion fails.)
func Fail(message string, callerSkip ...int) {
	skip := 0
	if len(callerSkip) > 0 {
		skip = callerSkip[0]
	}

	globalFailer.Fail(message, codelocation.New(skip+1))
	panic(GINKGO_PANIC)
}
开发者ID:keydunov,项目名称:relax,代码行数:10,代码来源:ginkgo_dsl.go

示例2: SynchronizedAfterSuite

//SynchronizedAfterSuite blocks complement the SynchronizedBeforeSuite blocks in solving the problem of setting up
//external singleton resources shared across nodes when running tests in parallel.
//
//SynchronizedAfterSuite accomplishes this by taking *two* function arguments.  The first runs on all nodes.  The second runs only on parallel node #1
//and *only* after all other nodes have finished and exited.  This ensures that node 1, and any resources it is running, remain alive until
//all other nodes are finished.
//
//Both functions have the same signature: either func() or func(done Done) to run asynchronously.
//
//Here's a pseudo-code example that complements that given in SynchronizedBeforeSuite.  Here, SynchronizedAfterSuite is used to tear down the shared database
//only after all nodes have finished:
//
//	var _ = SynchronizedAfterSuite(func() {
//		dbClient.Cleanup()
//	}, func() {
//		dbRunner.Stop()
//	})
func SynchronizedAfterSuite(allNodesBody interface{}, node1Body interface{}, timeout ...float64) bool {
	globalSuite.SetSynchronizedAfterSuiteNode(
		allNodesBody,
		node1Body,
		codelocation.New(1),
		parseTimeout(timeout...),
	)
	return true
}
开发者ID:keydunov,项目名称:relax,代码行数:26,代码来源:ginkgo_dsl.go

示例3: InvalidSharedRunnerBehaviors

func InvalidSharedRunnerBehaviors(build func(body interface{}, timeout time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable, componentType types.SpecComponentType) {
	var (
		failer                *Failer.Failer
		componentCodeLocation types.CodeLocation
		innerCodeLocation     types.CodeLocation
	)

	BeforeEach(func() {
		failer = Failer.New()
		componentCodeLocation = codelocation.New(0)
		innerCodeLocation = codelocation.New(0)
	})

	Describe("invalid functions", func() {
		Context("when passed something that's not a function", func() {
			It("should panic", func() {
				Ω(func() {
					build("not a function", 0, failer, componentCodeLocation)
				}).Should(Panic())
			})
		})

		Context("when the function takes the wrong kind of argument", func() {
			It("should panic", func() {
				Ω(func() {
					build(func(oops string) {}, 0, failer, componentCodeLocation)
				}).Should(Panic())
			})
		})

		Context("when the function takes more than one argument", func() {
			It("should panic", func() {
				Ω(func() {
					build(func(done Done, oops string) {}, 0, failer, componentCodeLocation)
				}).Should(Panic())
			})
		})
	})
}
开发者ID:keydunov,项目名称:relax,代码行数:39,代码来源:shared_runner_test.go

示例4: XMeasure

//You can mark Maeasurements as pending using XMeasure
func XMeasure(text string, _ ...interface{}) bool {
	globalSuite.PushMeasureNode(text, func(b Benchmarker) {}, types.FlagTypePending, codelocation.New(1), 0)
	return true
}
开发者ID:keydunov,项目名称:relax,代码行数:5,代码来源:ginkgo_dsl.go

示例5: FMeasure

//You can focus individual Measures using FMeasure
func FMeasure(text string, body interface{}, samples int) bool {
	globalSuite.PushMeasureNode(text, body, types.FlagTypeFocused, codelocation.New(1), samples)
	return true
}
开发者ID:keydunov,项目名称:relax,代码行数:5,代码来源:ginkgo_dsl.go

示例6: XIt

//You can mark Its as pending using XIt
func XIt(text string, _ ...interface{}) bool {
	globalSuite.PushItNode(text, func() {}, types.FlagTypePending, codelocation.New(1), 0)
	return true
}
开发者ID:keydunov,项目名称:relax,代码行数:5,代码来源:ginkgo_dsl.go

示例7: FIt

//You can focus individual Its using FIt
func FIt(text string, body interface{}, timeout ...float64) bool {
	globalSuite.PushItNode(text, body, types.FlagTypeFocused, codelocation.New(1), parseTimeout(timeout...))
	return true
}
开发者ID:keydunov,项目名称:relax,代码行数:5,代码来源:ginkgo_dsl.go

示例8:

		reporter1 *reporters.FakeReporter
		reporter2 *reporters.FakeReporter
		failer    *Failer.Failer
		writer    *Writer.FakeGinkgoWriter

		thingsThatRan []string

		runner *SpecRunner
	)

	newBefSuite := func(text string, fail bool) leafnodes.SuiteNode {
		return leafnodes.NewBeforeSuiteNode(func() {
			writer.AddEvent(text)
			thingsThatRan = append(thingsThatRan, text)
			if fail {
				failer.Fail(text, codelocation.New(0))
			}
		}, codelocation.New(0), 0, failer)
	}

	newAftSuite := func(text string, fail bool) leafnodes.SuiteNode {
		return leafnodes.NewAfterSuiteNode(func() {
			writer.AddEvent(text)
			thingsThatRan = append(thingsThatRan, text)
			if fail {
				failer.Fail(text, codelocation.New(0))
			}
		}, codelocation.New(0), 0, failer)
	}

	newSpec := func(text string, flag types.FlagType, fail bool) *spec.Spec {
开发者ID:keydunov,项目名称:relax,代码行数:31,代码来源:spec_runner_test.go

示例9:

	"github.com/zerobotlabs/relax/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/codelocation"
	Failer "github.com/zerobotlabs/relax/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/failer"
	"github.com/zerobotlabs/relax/Godeps/_workspace/src/github.com/onsi/ginkgo/types"
)

var _ = Describe("SuiteNodes", func() {
	Describe("BeforeSuite nodes", func() {
		var befSuite SuiteNode
		var failer *Failer.Failer
		var codeLocation types.CodeLocation
		var innerCodeLocation types.CodeLocation
		var outcome bool

		BeforeEach(func() {
			failer = Failer.New()
			codeLocation = codelocation.New(0)
			innerCodeLocation = codelocation.New(0)
		})

		Context("when the body passes", func() {
			BeforeEach(func() {
				befSuite = NewBeforeSuiteNode(func() {
					time.Sleep(10 * time.Millisecond)
				}, codeLocation, 0, failer)
				outcome = befSuite.Run(0, 0, "")
			})

			It("should return true when run and report as passed", func() {
				Ω(outcome).Should(BeTrue())
				Ω(befSuite.Passed()).Should(BeTrue())
			})
开发者ID:keydunov,项目名称:relax,代码行数:31,代码来源:suite_nodes_test.go

示例10: SynchronousSharedRunnerBehaviors

func SynchronousSharedRunnerBehaviors(build func(body interface{}, timeout time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable, componentType types.SpecComponentType, componentIndex int) {
	var (
		outcome types.SpecState
		failure types.SpecFailure

		failer *Failer.Failer

		componentCodeLocation types.CodeLocation
		innerCodeLocation     types.CodeLocation

		didRun bool
	)

	BeforeEach(func() {
		failer = Failer.New()
		componentCodeLocation = codelocation.New(0)
		innerCodeLocation = codelocation.New(0)

		didRun = false
	})

	Describe("synchronous functions", func() {
		Context("when the function passes", func() {
			BeforeEach(func() {
				outcome, failure = build(func() {
					didRun = true
				}, 0, failer, componentCodeLocation).Run()
			})

			It("should have a succesful outcome", func() {
				Ω(didRun).Should(BeTrue())

				Ω(outcome).Should(Equal(types.SpecStatePassed))
				Ω(failure).Should(BeZero())
			})
		})

		Context("when a failure occurs", func() {
			BeforeEach(func() {
				outcome, failure = build(func() {
					didRun = true
					failer.Fail("bam", innerCodeLocation)
					panic("should not matter")
				}, 0, failer, componentCodeLocation).Run()
			})

			It("should return the failure", func() {
				Ω(didRun).Should(BeTrue())

				Ω(outcome).Should(Equal(types.SpecStateFailed))
				Ω(failure).Should(Equal(types.SpecFailure{
					Message:               "bam",
					Location:              innerCodeLocation,
					ForwardedPanic:        "",
					ComponentIndex:        componentIndex,
					ComponentType:         componentType,
					ComponentCodeLocation: componentCodeLocation,
				}))
			})
		})

		Context("when a panic occurs", func() {
			BeforeEach(func() {
				outcome, failure = build(func() {
					didRun = true
					innerCodeLocation = codelocation.New(0)
					panic("ack!")
				}, 0, failer, componentCodeLocation).Run()
			})

			It("should return the panic", func() {
				Ω(didRun).Should(BeTrue())

				Ω(outcome).Should(Equal(types.SpecStatePanicked))
				Ω(failure.ForwardedPanic).Should(Equal("ack!"))
			})
		})

		Context("when a panic occurs with a nil value", func() {
			BeforeEach(func() {
				outcome, failure = build(func() {
					didRun = true
					innerCodeLocation = codelocation.New(0)
					panic(nil)
				}, 0, failer, componentCodeLocation).Run()
			})

			It("should return the nil-valued panic", func() {
				Ω(didRun).Should(BeTrue())

				Ω(outcome).Should(Equal(types.SpecStatePanicked))
				Ω(failure.ForwardedPanic).Should(Equal("<nil>"))
			})
		})

	})
}
开发者ID:keydunov,项目名称:relax,代码行数:97,代码来源:shared_runner_test.go

示例11: AfterEach

//AfterEach blocks are run after It blocks.   When multiple AfterEach blocks are defined in nested
//Describe and Context blocks the innermost AfterEach blocks are run first.
//
//Like It blocks, AfterEach blocks can be made asynchronous by providing a body function that accepts
//a Done channel
func AfterEach(body interface{}, timeout ...float64) bool {
	globalSuite.PushAfterEachNode(body, codelocation.New(1), parseTimeout(timeout...))
	return true
}
开发者ID:keydunov,项目名称:relax,代码行数:9,代码来源:ginkgo_dsl.go

示例12:

	. "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/ginkgo/internal/codelocation"
	. "github.com/zerobotlabs/relax/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/containernode"
	"github.com/zerobotlabs/relax/Godeps/_workspace/src/github.com/onsi/ginkgo/types"
)

var _ = Describe("Container Node", func() {
	var (
		codeLocation types.CodeLocation
		container    *ContainerNode
	)

	BeforeEach(func() {
		codeLocation = codelocation.New(0)
		container = New("description text", types.FlagTypeFocused, codeLocation)
	})

	Describe("creating a container node", func() {
		It("can answer questions about itself", func() {
			Ω(container.Text()).Should(Equal("description text"))
			Ω(container.Flag()).Should(Equal(types.FlagTypeFocused))
			Ω(container.CodeLocation()).Should(Equal(codeLocation))
		})
	})

	Describe("pushing setup nodes", func() {
		It("can append setup nodes of various types and fetch them by type", func() {
			befA := leafnodes.NewBeforeEachNode(func() {}, codelocation.New(0), 0, nil, 0)
			befB := leafnodes.NewBeforeEachNode(func() {}, codelocation.New(0), 0, nil, 0)
开发者ID:keydunov,项目名称:relax,代码行数:31,代码来源:container_node_test.go

示例13:

package leafnodes_test

import (
	. "github.com/zerobotlabs/relax/Godeps/_workspace/src/github.com/onsi/ginkgo"
	"github.com/zerobotlabs/relax/Godeps/_workspace/src/github.com/onsi/ginkgo/types"
	. "github.com/zerobotlabs/relax/Godeps/_workspace/src/github.com/onsi/gomega"

	. "github.com/zerobotlabs/relax/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/leafnodes"

	"github.com/zerobotlabs/relax/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/codelocation"
)

var _ = Describe("Setup Nodes", func() {
	Describe("BeforeEachNodes", func() {
		It("should report the correct type and code location", func() {
			codeLocation := codelocation.New(0)
			beforeEach := NewBeforeEachNode(func() {}, codeLocation, 0, nil, 3)
			Ω(beforeEach.Type()).Should(Equal(types.SpecComponentTypeBeforeEach))
			Ω(beforeEach.CodeLocation()).Should(Equal(codeLocation))
		})
	})

	Describe("AfterEachNodes", func() {
		It("should report the correct type and code location", func() {
			codeLocation := codelocation.New(0)
			afterEach := NewAfterEachNode(func() {}, codeLocation, 0, nil, 3)
			Ω(afterEach.Type()).Should(Equal(types.SpecComponentTypeAfterEach))
			Ω(afterEach.CodeLocation()).Should(Equal(codeLocation))
		})
	})
开发者ID:keydunov,项目名称:relax,代码行数:30,代码来源:setup_nodes_test.go

示例14:

	. "github.com/zerobotlabs/relax/Godeps/_workspace/src/github.com/onsi/ginkgo"
	"github.com/zerobotlabs/relax/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/codelocation"
	"github.com/zerobotlabs/relax/Godeps/_workspace/src/github.com/onsi/ginkgo/types"
	. "github.com/zerobotlabs/relax/Godeps/_workspace/src/github.com/onsi/gomega"
	"runtime"
)

var _ = Describe("CodeLocation", func() {
	var (
		codeLocation       types.CodeLocation
		expectedFileName   string
		expectedLineNumber int
	)

	caller0 := func() {
		codeLocation = codelocation.New(1)
	}

	caller1 := func() {
		_, expectedFileName, expectedLineNumber, _ = runtime.Caller(0)
		expectedLineNumber += 2
		caller0()
	}

	BeforeEach(func() {
		caller1()
	})

	It("should use the passed in skip parameter to pick out the correct file & line number", func() {
		Ω(codeLocation.FileName).Should(Equal(expectedFileName))
		Ω(codeLocation.LineNumber).Should(Equal(expectedLineNumber))
开发者ID:keydunov,项目名称:relax,代码行数:31,代码来源:code_location_test.go

示例15:

	. "github.com/zerobotlabs/relax/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/failer"
	. "github.com/zerobotlabs/relax/Godeps/_workspace/src/github.com/onsi/gomega"

	"github.com/zerobotlabs/relax/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/codelocation"
	"github.com/zerobotlabs/relax/Godeps/_workspace/src/github.com/onsi/ginkgo/types"
)

var _ = Describe("Failer", func() {
	var (
		failer        *Failer
		codeLocationA types.CodeLocation
		codeLocationB types.CodeLocation
	)

	BeforeEach(func() {
		codeLocationA = codelocation.New(0)
		codeLocationB = codelocation.New(0)
		failer = New()
	})

	Context("with no failures", func() {
		It("should return success when drained", func() {
			failure, state := failer.Drain(types.SpecComponentTypeIt, 3, codeLocationB)
			Ω(failure).Should(BeZero())
			Ω(state).Should(Equal(types.SpecStatePassed))
		})
	})

	Describe("Skip", func() {
		It("should handle failures", func() {
			failer.Skip("something skipped", codeLocationA)
开发者ID:keydunov,项目名称:relax,代码行数:31,代码来源:failer_test.go


注:本文中的github.com/zerobotlabs/relax/Godeps/_workspace/src/github.com/onsi/ginkgo/internal/codelocation.New函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。