Skip to content

fix(test): parse BUILD_FLAGS and TEST_FLAGS#371

Merged
KSXGitHub merged 2 commits intomasterfrom
claude/investigate-eval-usage-OjhAo
Mar 24, 2026
Merged

fix(test): parse BUILD_FLAGS and TEST_FLAGS#371
KSXGitHub merged 2 commits intomasterfrom
claude/investigate-eval-usage-OjhAo

Conversation

@KSXGitHub
Copy link
Owner

Summary

Fixed improper handling of BUILD_FLAGS and TEST_FLAGS environment variables in the test script by properly parsing them as arrays instead of passing them as raw strings.

Key Changes

  • Removed eval calls from run_if invocations to avoid unintended shell expansion and improve security
  • Added explicit array parsing for BUILD_FLAGS and TEST_FLAGS using read -ra to properly handle multi-word flag strings
  • Updated cargo invocations to use array expansion ("${build_flags[@]}" and "${test_flags[@]}") instead of unquoted variable substitution

Implementation Details

The previous implementation relied on eval to expand variables, which could lead to unexpected behavior with complex flag strings containing spaces or special characters. The new approach:

  1. Parses flag strings into proper bash arrays using read -ra
  2. Passes arrays to cargo commands using proper array expansion syntax
  3. Eliminates the security risk and unpredictability of eval

This ensures that flags like BUILD_FLAGS="--release --verbose" are correctly split and passed as separate arguments to cargo.

https://claude.ai/code/session_01L1fN5BiN9pbngSFbtEPRWL

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
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 direct run_if ... invocations for clippy, doc, build, and test.
  • Parsed BUILD_FLAGS and TEST_FLAGS using read -a into 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
@github-actions
Copy link

github-actions bot commented Mar 24, 2026

Performance Regression Reports

commit: c448f9d

--quantity=block-size --max-depth=10 --min-ratio=0.01 --progress
Command Mean [ms] Min [ms] Max [ms] Relative
pdu 115.8 ± 31.8 104.7 207.4 1.10 ± 0.30
pdu-0.20.0 105.0 ± 0.3 104.4 105.7 1.00
Logs
Benchmark 1: pdu
  Time (mean ± σ):     115.8 ms ±  31.8 ms    [User: 103.7 ms, System: 287.9 ms]
  Range (min … max):   104.7 ms … 207.4 ms    28 runs
 
  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.
 
Benchmark 2: pdu-0.20.0
  Time (mean ± σ):     105.0 ms ±   0.3 ms    [User: 103.5 ms, System: 292.0 ms]
  Range (min … max):   104.4 ms … 105.7 ms    28 runs
 
Summary
  pdu-0.20.0 ran
    1.10 ± 0.30 times faster than pdu
JSON
{
  "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
      ]
    }
  ]
}

@KSXGitHub KSXGitHub marked this pull request as ready for review March 24, 2026 03:14
@KSXGitHub KSXGitHub merged commit ba71d11 into master Mar 24, 2026
12 of 13 checks passed
@KSXGitHub KSXGitHub deleted the claude/investigate-eval-usage-OjhAo branch March 24, 2026 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants