Skip to content

Commit f21bf29

Browse files
committed
misc changes
1 parent bb61566 commit f21bf29

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

stage/map.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@ func ParseStage(stage *Stage, stages Map) (*Stage, error) {
9494
nextStagePath = filepath.Join(stage.BaseDir, nextStagePath)
9595
stage.NextStagePaths[i] = nextStagePath
9696
}
97-
if _, err := os.Stat(nextStagePath); err != nil {
97+
if fileInfo, err := os.Stat(nextStagePath); err != nil {
9898
return nil, fmt.Errorf("%s links to an invalid next stage file %s: %w", stage.Id, nextStagePath, err)
99+
} else if fileInfo.IsDir() {
100+
return nil, fmt.Errorf("%s links to a directory as next stage: %s", stage.Id, nextStagePath)
99101
}
100102
}
101103
stages[stage.Id] = stage

stage/stage.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func (s *Stage) run(ctx context.Context) (returnErr error) {
225225
s.prepareClient()
226226
s.propagateStates()
227227
if len(s.Queries)+len(s.QueryFiles) > 0 {
228-
if s.RandomExecution != nil && *s.RandomExecution {
228+
if *s.RandomExecution {
229229
returnErr = s.runRandomly(ctx)
230230
} else {
231231
returnErr = s.runSequentially(ctx)
@@ -271,7 +271,7 @@ func (s *Stage) runSequentially(ctx context.Context) (returnErr error) {
271271
}
272272

273273
func (s *Stage) runQueryFile(ctx context.Context, queryFile string, expectedRowCountStartIndex *int, fileAlias *string) error {
274-
file, err := os.Open(queryFile)
274+
// fileAlias is the query file name we will report. We try to make it short, so try to use relative path when possible.
275275
if fileAlias == nil {
276276
if relPath, relErr := filepath.Rel(s.BaseDir, queryFile); relErr == nil {
277277
fileAlias = &relPath
@@ -280,6 +280,7 @@ func (s *Stage) runQueryFile(ctx context.Context, queryFile string, expectedRowC
280280
}
281281
}
282282

283+
file, err := os.Open(queryFile)
283284
var queries []string
284285
if err == nil {
285286
queries, err = presto.SplitQueries(file)
@@ -320,7 +321,7 @@ func (s *Stage) runRandomly(ctx context.Context) error {
320321
} else {
321322
err := fmt.Errorf("failed to parse randomly_execute_until %s", *s.RandomlyExecuteUntil)
322323
if *s.AbortOnError {
323-
s.States.exitCode.CompareAndSwap(0, 5)
324+
s.States.exitCode.CompareAndSwap(0, 2) // syntax error
324325
return err
325326
} else {
326327
log.Error().Err(err).Send()

stage/stage_utils.go

+3
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ func (s *Stage) prepareClient() {
179179

180180
func (s *Stage) setDefaults() {
181181
falseValue := false
182+
if s.RandomExecution == nil {
183+
s.RandomExecution = &falseValue
184+
}
182185
if s.AbortOnError == nil {
183186
s.AbortOnError = &falseValue
184187
}

0 commit comments

Comments
 (0)