Permalink
Browse files

Reorder test statements

This commit puts the func init() statement after the imports, but
before any other statements in a testfile. This should make it easier
to switch to using the var _ = Describe("test description here") syntax.
  • Loading branch information...
1 parent 0cccf6e commit b53974dfbe81ed13aa85c482003c61953ae82f39 @tjarratt tjarratt committed Feb 10, 2014
View
2 ginkgo/convert/testfile_rewriter.go
@@ -38,7 +38,7 @@ func rewriteTestsInFile(pathToFile string) {
rewriteTestFuncAsItStatement(testFunc, rootNode, describeBlock)
}
- rootNode.Decls = append(rootNode.Decls, topLevelInitFunc)
+ rootNode.Decls = append(rootNode.Decls[:1], append([]ast.Decl{topLevelInitFunc}, rootNode.Decls[1:]...)...)
rewriteOtherFuncsToUseGinkgoT(rootNode.Decls)
walkNodesInRootNodeReplacingTestingT(rootNode)
View
8 ginkgo/integration/_fixtures/convert_goldmasters/extra_functions_test.go
@@ -4,14 +4,16 @@ import (
. "github.com/onsi/ginkgo"
)
-func somethingImportant(t GinkgoTestingT, message *string) {
- t.Log("Something important happened in a test: " + *message)
-}
func init() {
Describe("Testing with Ginkgo", func() {
It("something less important", func() {
+
strp := "hello!"
somethingImportant(GinkgoT(), &strp)
})
})
}
+
+func somethingImportant(t GinkgoTestingT, message *string) {
+ t.Log("Something important happened in a test: " + *message)
+}
View
8 ginkgo/integration/_fixtures/convert_goldmasters/outside_package_test.go
@@ -4,10 +4,6 @@ import (
. "github.com/onsi/ginkgo"
)
-type UselessStruct struct {
- ImportantField string
-}
-
func init() {
Describe("Testing with Ginkgo", func() {
It("something important", func() {
@@ -19,3 +15,7 @@ func init() {
})
})
}
+
+type UselessStruct struct {
+ ImportantField string
+}
View
25 ginkgo/integration/_fixtures/convert_goldmasters/xunit_test.go
@@ -4,18 +4,6 @@ import (
. "github.com/onsi/ginkgo"
)
-type UselessStruct struct {
- ImportantField string
- T GinkgoTestingT
-}
-
-var testFunc = func(t GinkgoTestingT, arg *string) {}
-
-func assertEqual(t GinkgoTestingT, arg1, arg2 interface{}) {
- if arg1 != arg2 {
- t.Fail()
- }
-}
func init() {
Describe("Testing with Ginkgo", func() {
It("something important", func() {
@@ -37,3 +25,16 @@ func init() {
})
})
}
+
+type UselessStruct struct {
+ ImportantField string
+ T GinkgoTestingT
+}
+
+var testFunc = func(t GinkgoTestingT, arg *string) {}
+
+func assertEqual(t GinkgoTestingT, arg1, arg2 interface{}) {
+ if arg1 != arg2 {
+ t.Fail()
+ }
+}

0 comments on commit b53974d

Please sign in to comment.