Skip to content

Commit

Permalink
Merge pull request #87 from bouskaJ/fix_script
Browse files Browse the repository at this point in the history
Fix script
  • Loading branch information
nicolaferraro authored Apr 23, 2020
2 parents 5bc1ea8 + 35c108e commit d862b6e
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions pkg/cmd/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,15 +544,7 @@ func isDir(fileName string) bool {
func runSteps(steps []config.StepConfig, namespace, baseDir string) error {
for idx, step := range steps {
if len(step.Script) > 0 {
var scriptFile string

if len(baseDir) > 0 && !path.IsAbs(step.Script) {
scriptFile = path.Join(baseDir, step.Script)
} else {
scriptFile = step.Script
}

if err := runScript(scriptFile, fmt.Sprintf("script %s", scriptFile), namespace, baseDir); err != nil {
if err := runScript(step.Script, fmt.Sprintf("script %s", step.Script), namespace, baseDir); err != nil {
return err
}
}
Expand Down Expand Up @@ -601,9 +593,11 @@ func runScript(scriptFile, desc, namespace, baseDir string) error {

command.Dir = baseDir

if out, err := command.Output(); err == nil {
fmt.Printf("Running %s: \n%s\n", desc, out)
} else {
command.Stderr = os.Stderr
command.Stdout = os.Stdout

fmt.Printf("Running %s: \n", desc)
if err := command.Run(); err != nil {
fmt.Printf("Failed to run %s: \n%v\n", desc, err)
return err
}
Expand Down

0 comments on commit d862b6e

Please sign in to comment.