Skip to content

Change to Rust 2024 edition and remove unsafe environment var mutation#1712

Merged
jtran merged 5 commits into
mainfrom
jtran/rust-2024
Jul 7, 2026
Merged

Change to Rust 2024 edition and remove unsafe environment var mutation#1712
jtran merged 5 commits into
mainfrom
jtran/rust-2024

Conversation

@jtran

@jtran jtran commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

See each commit separately.

Environment variable mutation became unsafe in Rust 2024. Instead of using serial_test to run everything single-threaded or hacking around it and praying that we use it safely, I decided to remove it.

Some tests became unit tests (colors.rs). Some tests didn't actually need the environment variables set (cmd_user.rs). Some tests could have their variables injected (context.rs). But presumably we may need this in the future since kcl_lib may try to read environment variables, so I made kcl_process.rs that creates a child process where we can control its environment variables without mutating the current process's env.

Hopefully, in the future, we can remove serial_test. It's still used in a lot of places, but I didn't want to expand scope more.

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 59.66851% with 73 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.28%. Comparing base (48786c0) to head (11b3bfe).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/context.rs 52.21% 54 Missing ⚠️
src/cmd_ml/cmd_text_to_cad.rs 0.00% 6 Missing ⚠️
src/ml/copilot/run.rs 0.00% 4 Missing ⚠️
src/colors.rs 85.71% 3 Missing ⚠️
src/main.rs 0.00% 3 Missing ⚠️
src/cmd_api_call.rs 0.00% 2 Missing ⚠️
src/cmd_kcl.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1712      +/-   ##
==========================================
+ Coverage   65.21%   66.28%   +1.06%     
==========================================
  Files          44       44              
  Lines        8219     8476     +257     
==========================================
+ Hits         5360     5618     +258     
+ Misses       2859     2858       -1     
Flag Coverage Δ
unittests 66.28% <59.66%> (+1.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jtran jtran marked this pull request as ready for review July 7, 2026 19:47
@jtran jtran merged commit d038ace into main Jul 7, 2026
17 of 19 checks passed
@jtran jtran deleted the jtran/rust-2024 branch July 7, 2026 20:28
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.

2 participants