Skip to content

Commit

Permalink
fix convert integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
onsi committed Apr 21, 2020
1 parent 1ea49cf commit 1f8ba69
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions ginkgo/convert/package_rewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ func RewritePackage(packageName string) {
*/
func findTestsInPackage(pkg *build.Package) (testfiles []string) {
for _, file := range append(pkg.TestGoFiles, pkg.XTestGoFiles...) {
testfiles = append(testfiles, filepath.Join(pkg.Dir, file))
testfile, _ := filepath.Abs(filepath.Join(pkg.Dir, file))
testfiles = append(testfiles, testfile)
}

dirFiles, err := ioutil.ReadDir(pkg.Dir)
Expand Down Expand Up @@ -103,10 +104,11 @@ func addGinkgoSuiteForPackage(pkg *build.Package) {
* Shells out to `go fmt` to format the package
*/
func goFmtPackage(pkg *build.Package) {
output, err := exec.Command("go", "fmt", pkg.ImportPath).Output()
path, _ := filepath.Abs(pkg.ImportPath)
output, err := exec.Command("go", "fmt", path).CombinedOutput()

if err != nil {
fmt.Printf("Warning: Error running 'go fmt %s'.\nstdout: %s\n%s\n", pkg.ImportPath, output, err.Error())
fmt.Printf("Warning: Error running 'go fmt %s'.\nstdout: %s\n%s\n", path, output, err.Error())
}
}

Expand Down
3 changes: 2 additions & 1 deletion ginkgo/convert/testfile_rewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ func rewriteTestsInFile(pathToFile string) {
}

fileInfo, err := os.Stat(pathToFile)

if err != nil {
panic(fmt.Sprintf("Error stat'ing file: %s\n", pathToFile))
}

ioutil.WriteFile(pathToFile, buffer.Bytes(), fileInfo.Mode())
err = ioutil.WriteFile(pathToFile, buffer.Bytes(), fileInfo.Mode())
}

/*
Expand Down

2 comments on commit 1f8ba69

@kevinmachstudio
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious how is the error being handled on line 64?

@onsi
Copy link
Owner Author

@onsi onsi commented on 1f8ba69 Apr 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

poorly!!

Please sign in to comment.