feat(env): warn at runtime on deprecated forms#886
Merged
Conversation
Deprecations were recorded only in help text and docs, with no path out: the unprefixed aliases have been superseded since 0.15.0 and 'bashunit test --assert' since the assert subcommand landed, and neither ever told a user at runtime. Adds bashunit::env::warn_deprecated and wires it to both. The warning goes to stderr so it cannot corrupt a report on stdout, and BASHUNIT_NO_DEPRECATION_WARNINGS=true silences it. Detection for the unprefixed aliases runs before the ':=' block, because afterwards the prefixed name is set either way and the two cases are indistinguishable. It is pure bash: a 'compgen -v' capture would cost a fork on the budgeted cold-start path. The hand-maintained alias list is kept honest by an anti-drift test against env.sh. Documents the policy: a deprecated form warns for at least one minor before removal in a major. Note '-a/--assert' is NOT a pure rename -- it goes through cmd_test's parser so it also accepts --env/--no-parallel, which 'bashunit assert' forwards to the assertion instead. That gap must close before the form can be removed; recorded in the code.
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.
🤔 Background
Related #866
Deprecations were recorded only in help text and docs, with no path out. The unprefixed
settings have been superseded since 0.15.0 (~23 months) and
bashunit test --assertsincethe
assertsubcommand landed — neither ever told a user at runtime, which is how adeprecation stays in place indefinitely.
This adds the mechanism and the policy, without removing anything.
💡 Changes
bashunit::env::warn_deprecated, wired to the unprefixed settings and--assert. Output goes to stderr so it cannot corrupt a report on stdout;BASHUNIT_NO_DEPRECATION_WARNINGS=truesilences it:=block — afterwards the prefixed name is set either way and the two cases are indistinguishable — and is pure bash, since acompgen -vcapture would cost a fork on the budgeted cold-start pathenv.sh, matching the approach already used for the shell completions-a/--assertis not a pure rename. It goes throughcmd_test's parser, so it alsoaccepts
--envand--no-parallel;bashunit assertforwards everything to theassertion instead. I found this by migrating tests to the new form and watching them
fail. That gap has to close before the old form can actually be removed — recorded in the
code rather than left to be rediscovered.