Skip to content

Commit

Permalink
prevent doing multiple ranges if we have range not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
fokion committed Aug 4, 2023
1 parent a8d42f0 commit 6bfca73
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions process_testcase.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,10 +483,17 @@ func parseRanged(ctx context.Context, rawStep []byte, stepVars H) (Range, error)
return ranged, fmt.Errorf("unable to parse range expression: %v", err)
}

if !ranged.Enabled {
ranged.Items = []RangeData{}
ranged.Items = append(ranged.Items, RangeData{})
return ranged, nil
}

switch ranged.RawContent.(type) {

//Nil means this is not a ranged data, append an empty item to force at least one iteration and exit
case nil:
ranged.Items = []RangeData{}
ranged.Items = append(ranged.Items, RangeData{})
return ranged, nil

Expand Down
6 changes: 5 additions & 1 deletion process_teststep.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (v *Venom) RunTestStep(ctx context.Context, e ExecutorRunner, tc *TestCase,
tsResult.ComputedVars.Add(k, value)
newVars.Add(k, value)
}
tsResult.ComputedVars.AddAll(AllVarsFromCtx(ctx))

if v.Verbose >= 2 {
fdump := dumpFile{
Result: result,
Expand Down Expand Up @@ -82,6 +82,10 @@ func (v *Venom) RunTestStep(ctx context.Context, e ExecutorRunner, tc *TestCase,
tc.computedVerbose = append(tc.computedVerbose, fmt.Sprintf("writing %s", filename))
}
allvars, _ := DumpStringPreserveCase(tsResult.ComputedVars)
inputVars, _ := DumpStringPreserveCase(tsResult.InputVars)
for k, value := range inputVars {
allvars[k] = value
}
for ninfo, i := range e.Info() {
info, err := interpolate.Do(i, allvars)
if err != nil {
Expand Down

0 comments on commit 6bfca73

Please sign in to comment.