fix(codegen): emit no-op in teardown when every step is skipped#190
Merged
Conversation
Buildkite GCP agents don't ship nvm, so `nvm install` failed with `command not found`. Move the Node setup into a repository pre-command hook that auto-installs nvm when missing and runs before every step automatically when NODE_VERSION is set.
The generated ES test scripts invoke `elastic` as a global command (per README dev setup). CI was missing `npm link`, causing every script to fail with `elastic: command not found`.
Bash requires a function body to contain at least one executable
statement. When every teardown step maps to an unregistered CLI
action, the generator produced a `teardown() { # SKIPPED ... }`
body that was comments-only, failing with
`syntax error near unexpected token '}'` on startup.
Detect the all-comments case and append `:` so the function is
syntactically valid. Added a fixture (skipped-teardown.yml) and two
tests: one asserts the no-op is present, and one pipes the generated
script through `bash -n` to guarantee it parses.
Closes #188
✅MegaLinter analysis: Success
See detailed reports in MegaLinter artifacts MegaLinter is graciously provided by OX Security |
3 tasks
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.
Summary
syntax error near unexpected token '}'failures in the ES functional matrix. When every teardown step maps to an unregistered CLI action (# SKIPPED: action "..." not registered), the generatedteardown()body contained only comments — bash rejects a comment-only function body with that error.generator.tsnow detects the all-comments case and appends a:no-op so the function body is syntactically valid.skipped-teardown.ymlfixture plus two generator tests: one asserts the no-op is present, the other pipes the generated script throughbash -nto guarantee it parses.Closes #188.
Scripts previously failing, now syntactically valid
test/functional/es/indices/data_stream_mappings.shtest/functional/es/indices/data_streams_options.shtest/functional/es/indices/migrate_modify_data_stream.shtest/functional/es/machine_learning/buckets_serverless.shtest/functional/es/query_rules/30_test.shVerified locally with
bash -nagainst all 78 regenerated scripts — zero failures.Stack
Based on #187. Merge that first, this second.
Test plan
npm run test:unitgreen (hasExecutableLinehelper +bash -nround-trip test)