Repository navigation
Change from calling exit() to returning ExitCode from Rust executables - #1743
Steve Lee (SteveL-MSFT) wants to merge 4 commits into
Conversation
Return exit statuses through Rust main functions so normal process cleanup can flush code coverage data. Update resource authoring guidance to require the same pattern. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The environment-variable unit tests still expect Option and will not compile after parse_input_arg begins returning Result.
3 open findings
What changed in this PR
Migrates Rust executables from process::exit to returned ExitCode, enabling normal cleanup and coverage flushing.
Changes:
- Propagates exit codes through resource and test helper APIs.
- Restricts
dsctestexit-code inputs tou8. - Documents the pattern for newly created resources.
| File | Description |
|---|---|
y2j/src/main.rs |
Returns conversion failures through ExitCode. |
tools/dsctest/src/main.rs |
Propagates fixture failures from run. |
tools/dsctest/src/export_schema.rs |
Returns schema-export errors. |
tools/dsctest/src/exit_code.rs |
Restricts fixture codes to u8. |
tools/dsctest/src/adapter.rs |
Returns normally after streamed output. |
resources/WindowsUpdate/src/main.rs |
Returns operation status codes. |
resources/windows_service/src/main.rs |
Propagates helper failures. |
resources/windows_firewall/src/main.rs |
Propagates helper failures. |
resources/sshdconfig/src/main.rs |
Returns command status. |
resources/runcommandonset/src/utils.rs |
Makes helper failures recoverable. |
resources/runcommandonset/src/main.rs |
Converts helper errors to exit codes. |
resources/process/src/main.rs |
Returns operation status. |
resources/osinfo/src/main.rs |
Centralizes errors through run. |
resources/filecontent/src/main.rs |
Returns parsing and resource failures. |
resources/environment_variable/src/main.rs |
Propagates parsing and serialization failures. |
resources/dscecho/src/main.rs |
Returns schema or echo status. |
resources/dism_dsc/src/main.rs |
Returns dispatch status. |
adapters/group_policy_template/src/main.rs |
Returns adapter status codes. |
.github/skills/create-dsc-resource/SKILL.md |
Documents the ExitCode pattern. |
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
Update environment variable tests for Result-returning argument parsing and correct helper documentation to describe propagated exit codes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
😐 Code Coverage ReportChanged Code Coverage75% (70%+ coverage)
🔵 Full Codebase Coverage83% (good)
|
Exercise invalid input, missing instance, and command failure paths across dsctest and cross-platform Rust resources so changed-line coverage includes the new ExitCode propagation branches. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Copilot resolve the merge conflicts in this pull request |
…code-migration # Conflicts: # resources/dism_dsc/src/main.rs Co-authored-by: SteveL-MSFT <11859881+SteveL-MSFT@users.noreply.github.com>
Resolved the conflict in |


Rust executables that call
std::process::exitbypass normal process cleanup, preventing code coverage data from being flushed. This change returnsstd::process::ExitCodefrom executable entry points instead.The migration propagates failures through helper APIs to each
mainfunction while preserving existing status codes and output behavior. It also constrains thedsctestexit-code fixture to theu8range supported byExitCodeand updates the DSC resource creation skill to require this pattern for new Rust resources.Validated with the repository build and Clippy across the affected Rust projects.