Resolve {{ index }} in a plain request (fixes #186)#231
Closed
fcsonline wants to merge 1 commit into
Closed
Conversation
Seed `index` with the iteration counter when building each iteration's
context, so `{{ index }}` resolves in a plain request instead of panicking
with "Unknown 'index' variable" in strict mode (or interpolating to an empty
string under --relaxed-interpolations).
with_items / csv / file / range expansions still override `index` with the
item's list position at execute time, so their semantics are unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem (#186)
{{ index }}only existed insidewith_items/with_items_range/with_items_from_csv/with_items_from_fileexpansions, where it is the item's position in the list. In a plain request the variable was never set, so a plan referencing{{ index }}:Unknown 'index' variable), or--relaxed-interpolations.Fix
Seed
indexwith the iteration counter when each iteration's context is built inrun_iteration, so a plain request resolves{{ index }}to the iteration number. Expanded requests still overrideindexwith their list position at execute time, sowith_itemssemantics are unchanged.Notes
Minimal change (2 lines). Verified against the exact repro from #186 (previously panicked, now runs clean) and
cargo fmt/cargo clippy -- -D warnings/cargo test(61) all pass.Inspired by zoosky/driller#26, trimmed to just the core fix.