File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package main
33import (
44 "encoding/json"
55 "fmt"
6+ "io/ioutil"
67 "log"
78 "os"
89 "os/exec"
@@ -50,12 +51,22 @@ func regenerate(dir string) error {
5051 return nil
5152 }
5253
54+ var expectFailure bool
55+ if _ , err := os .Stat (filepath .Join (cwd , "stderr.txt" )); ! os .IsNotExist (err ) {
56+ expectFailure = true
57+ }
58+
5359 cmd := exec .Command ("sqlc-dev" , "generate" , "--experimental" )
5460 cmd .Dir = cwd
5561 out , failed := cmd .CombinedOutput ()
56- if _ , err := os . Stat ( filepath . Join ( cwd , "stderr.txt" )); os . IsNotExist ( err ) && failed != nil {
62+ if failed != nil && ! expectFailure {
5763 return fmt .Errorf ("%s: sqlc-dev generate failed\n %s" , cwd , out )
5864 }
65+ if expectFailure {
66+ if err := ioutil .WriteFile (filepath .Join (cwd , "stderr.txt" ), out , 0644 ); err != nil {
67+ return fmt .Errorf ("failed to update stderr.txt: %v" , err )
68+ }
69+ }
5970 }
6071 return nil
6172 })
You can’t perform that action at this time.
0 commit comments