Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Onsi Fakhouri
committed
Feb 7, 2014
1 parent
2c5f638
commit c8efbb9
Showing
18 changed files
with
146 additions
and
208 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
ginkgo/integration/_fixtures/convert_goldmasters/suite_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package convert_fixtures_test | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
"testing" | ||
) | ||
|
||
func TestConvert_fixtures(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Convert_fixtures Suite") | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package integration_test | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
"io/ioutil" | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
) | ||
|
||
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()) | ||
|
||
err = exec.Command("ginkgo", "convert", relPath).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! | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package integration_test | ||
|
||
import ( | ||
"fmt" | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
"os/exec" | ||
|
||
"testing" | ||
) | ||
|
||
func TestIntegration(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
|
||
installGinkgoCommand := exec.Command("go", "install", "github.com/onsi/ginkgo/ginkgo") | ||
err := installGinkgoCommand.Run() | ||
if err != nil { | ||
fmt.Printf("Failed to compile Ginkgo\n\t%s", err.Error()) | ||
} | ||
|
||
RunSpecs(t, "Integration Suite") | ||
} |