fix(test): parse BUILD_FLAGS and TEST_FLAGS#371
Merged
Conversation
Use read -ra to parse BUILD_FLAGS and TEST_FLAGS into arrays, so empty variables expand to zero arguments without needing eval. This avoids potential issues with shell metacharacter expansion. https://claude.ai/code/session_01L1fN5BiN9pbngSFbtEPRWL
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates test.sh to safely and correctly pass BUILD_FLAGS and TEST_FLAGS to Cargo by parsing them into bash arrays, avoiding eval and preventing unintended shell expansion.
Changes:
- Replaced
eval run_if ...with directrun_if ...invocations forclippy,doc,build, andtest. - Parsed
BUILD_FLAGSandTEST_FLAGSusingread -ainto arrays and expanded them as"...[@]"in Cargo commands.
Use ${arr[@]+"${arr[@]}"} pattern to safely expand potentially empty
arrays. Bash 3.2 (macOS default) treats empty array expansion as an
unbound variable error under set -o nounset.
https://claude.ai/code/session_01L1fN5BiN9pbngSFbtEPRWL
Performance Regression Reportscommit: c448f9d --quantity=block-size --max-depth=10 --min-ratio=0.01 --progress
LogsJSON{
"results": [
{
"command": "pdu",
"mean": 0.11581674255428567,
"stddev": 0.031782311958814785,
"median": 0.10501138684,
"user": 0.10371433285714285,
"system": 0.28786793,
"min": 0.10469134934,
"max": 0.20741691934000003,
"times": [
0.10480158734,
0.10535522434000001,
0.10526679734000001,
0.10521455234,
0.10469134934,
0.10498841734,
0.10501983834,
0.10521788734000001,
0.10494524434000001,
0.10495867334,
0.10473519134,
0.10482413934000001,
0.20741691934000003,
0.20508379634,
0.20521024134000002,
0.10502687834,
0.10516627034,
0.10480963234,
0.10499460934,
0.10500293534,
0.10485802434000001,
0.10470788434,
0.10478365434,
0.10508943634000001,
0.10534996534,
0.10479182934,
0.10533388534,
0.10522392734000001
],
"exit_codes": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
},
{
"command": "pdu-0.20.0",
"mean": 0.10503965437571426,
"stddev": 0.00027739239027954523,
"median": 0.10504920434000001,
"user": 0.10345422571428571,
"system": 0.2920466085714285,
"min": 0.10441367434,
"max": 0.10566772834,
"times": [
0.10493173134,
0.10451899634,
0.10480521434000001,
0.10485748234,
0.10530678434,
0.10485324134,
0.10441367434,
0.10512502034,
0.10506082334000001,
0.10492886934000001,
0.10512572534,
0.10509220134000001,
0.10477372534,
0.10485926734,
0.10521894734000001,
0.10498086334000001,
0.10520856834,
0.10502710934000001,
0.10503758534,
0.10494328534000001,
0.10520043034000001,
0.10543432234000001,
0.10566772834,
0.10525718334,
0.10539817434000001,
0.10521201534,
0.10525065434,
0.10462069834
],
"exit_codes": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
}
]
} |
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
Fixed improper handling of
BUILD_FLAGSandTEST_FLAGSenvironment variables in the test script by properly parsing them as arrays instead of passing them as raw strings.Key Changes
evalcalls fromrun_ifinvocations to avoid unintended shell expansion and improve securityBUILD_FLAGSandTEST_FLAGSusingread -rato properly handle multi-word flag strings"${build_flags[@]}"and"${test_flags[@]}") instead of unquoted variable substitutionImplementation Details
The previous implementation relied on
evalto expand variables, which could lead to unexpected behavior with complex flag strings containing spaces or special characters. The new approach:read -raevalThis ensures that flags like
BUILD_FLAGS="--release --verbose"are correctly split and passed as separate arguments to cargo.https://claude.ai/code/session_01L1fN5BiN9pbngSFbtEPRWL