Skip to content

Add process-utils for testing process execution#17047

Open
straight-shoota wants to merge 18 commits into
crystal-lang:masterfrom
straight-shoota:spec/crystal-test-utils
Open

Add process-utils for testing process execution#17047
straight-shoota wants to merge 18 commits into
crystal-lang:masterfrom
straight-shoota:spec/crystal-test-utils

Conversation

@straight-shoota

@straight-shoota straight-shoota commented Jun 5, 2026

Copy link
Copy Markdown
Member

process_spec needs some example programs to test the behaviour of Process.run etc.
Previously, it used several platform-specific commands and shell scripts to do that.

This patch introduces a portable implementation of helper programs in Crystal. They are compiled directly into the spec executable and can be called like spec_binary pu cat (this happens implicitly via Process.executable_path).

As a result, the same helper commands work across all platforms and the only requirement is the spec executable. The commands are much cleaner which makes it easier to understand the specs.
We can drop a lot of platform-specific details in the spec code.

I'm leaving print_env_shell_command for now because it's used in a shell: true spec which probably needs a different refactor.

We've been discussed this idea for a long time, I was finally reminded of it by https://log.pfad.fr/2026/self-calling-executable/ and https://abhinavg.net/2022/05/15/hijack-testmain/

Comment thread spec/std/process_spec.cr Outdated
@straight-shoota straight-shoota marked this pull request as ready for review June 11, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants