print MDTEST_TEST_FILTER value in single-quotes (and escaped) #16548
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
If an mdtest fails, the error output will include an example command that can be run to re-run just the failing test, e.g
This is very helpful, but because we're printing the envvar value surrounded in double-quotes, the bits between backticks in this example get interpreted as a shell interpolation. When running this in zsh, for example, I see
1
This is a minor annoyance which we can solve by using single-quotes instead of double-quotes for this string. To do so safely, we also escape single-quotes possibly contained within the string.
There is a shell-quote crate, which seems to handle all this escaping stuff for you but fixing this issue perfectly isn't a big deal (if there are more things to escape we can deal with it then), so adding a new dependency (even a dev one) seemed overkill.
Test Plan
I broke the
## Context manager with non-callable `__exit__` attribute
test by deleting the error assertion, then successfully ran the new command it printed out.Footnotes
The filter does still work---it turns out that the filter
MDTEST_TEST_FILTER="sync.md - With statements - Context manager with non-callable attribute"
(what you get after the failed interpolation) is still good enough ↩