Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(return): error if return used outside sourced script or function #350

Merged
merged 1 commit into from
Jan 22, 2025

Conversation

reubeno
Copy link
Owner

@reubeno reubeno commented Jan 22, 2025

Resolves a TODO in the implementation of the return built-in to check for current function or sourced script. To do this, required tracking the distinction between a top-level executed script vs. a script sourced via source or ..

Adds some compat test cases too for these return uses, refactoring them out of the general function part of the test suite.

Resolves #338 (the rest of it not covered by previous fixes).

Copy link

github-actions bot commented Jan 22, 2025

Test Results

    3 files     14 suites   5m 33s ⏱️
  621 tests   621 ✅ 0 💤 0 ❌
1 849 runs  1 849 ✅ 0 💤 0 ❌

Results for commit 2b5bb75.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Jan 22, 2025

Performance Benchmark Report

Benchmark name Baseline (μs) Test/PR (μs) Delta (μs) Delta %
clone_shell_object 16.27 μs 16.18 μs -0.09 μs ⚪ Unchanged
eval_arithmetic 0.20 μs 0.19 μs -0.01 μs 🟢 -5.10%
expand_one_string 1.56 μs 1.53 μs -0.03 μs ⚪ Unchanged
for_loop 32.46 μs 32.32 μs -0.15 μs ⚪ Unchanged
function_call 3.33 μs 3.22 μs -0.10 μs ⚪ Unchanged
instantiate_shell 49.06 μs 48.48 μs -0.58 μs 🟢 -1.18%
instantiate_shell_with_init_scripts 21901.43 μs 21930.72 μs 29.29 μs ⚪ Unchanged
parse_bash_completion 1676.56 μs 1662.56 μs -14.00 μs ⚪ Unchanged
parse_sample_script 1.81 μs 1.76 μs -0.05 μs 🟢 -2.87%
run_echo_builtin_command 16.53 μs 16.27 μs -0.26 μs ⚪ Unchanged
run_one_external_command 4210.64 μs 2134.44 μs -2076.20 μs 🟢 -49.31%
tokenize_sample_script 2.78 μs 2.79 μs 0.01 μs 🟠 +0.47%

Code Coverage Report: Only Changed Files listed

Package Base Coverage New Coverage Difference
brush-core/src/builtins/dot.rs 🟢 91.67% 🟢 95.83% 🟢 4.16%
brush-core/src/builtins/return_.rs 🟢 81.82% 🟢 100% 🟢 18.18%
brush-core/src/shell.rs 🟢 77.62% 🟢 78.34% 🟢 0.72%
Overall Coverage 🟢 74.7% 🟢 74.77% 🟢 0.07%

Minimum allowed coverage is 70%, this run produced 74.77%

@reubeno reubeno merged commit acafe10 into main Jan 22, 2025
19 checks passed
@reubeno reubeno deleted the inapplicable-return branch January 22, 2025 02:46
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.

return in a subshell quietly exits the shell
1 participant