Skip to content

Test: SIGINT should be able to interrupt non-terminating goals on linux#3299

Open
danilp-id wants to merge 12 commits into
mthom:masterfrom
danilp-id:interrupt_test
Open

Test: SIGINT should be able to interrupt non-terminating goals on linux#3299
danilp-id wants to merge 12 commits into
mthom:masterfrom
danilp-id:interrupt_test

Conversation

@danilp-id
Copy link
Copy Markdown
Contributor

@danilp-id danilp-id commented Apr 19, 2026

Test for #3290.

Currently fails, but passes if that PR is applied.

Works by creating a child scryer process wrapped in script to simulate a terminal and then sending INT signals to it. (If terminal is not simulated, bug will not appear.)

Also reworked tests to use #[tokio::test(flavor = "multi_thread")] instead of custom tokio initialization code.

TODO (in a different PR): currently, there is no way to detect if test encounters a deadlock. We need to decide how to test for timeouts as cargo test doesn't seem to support this out of the box.

TODO: this test uses script which is part of util-linux and thus not available on MacOS. Need to restrict this test just to linux or find a way to simulate terminal on MacOS.

@danilp-id
Copy link
Copy Markdown
Contributor Author

@Skgland

This comment was marked as resolved.

@danilp-id danilp-id marked this pull request as ready for review April 22, 2026 23:52
@danilp-id danilp-id changed the title TEST: SIGINT should be able to interrupt non-terminating goals on linux (WIP) Test: SIGINT should be able to interrupt non-terminating goals on linux Apr 22, 2026
@danilp-id
Copy link
Copy Markdown
Contributor Author

See https://unix.stackexchange.com/questions/249723/how-to-trick-a-command-into-thinking-its-output-is-going-to-a-terminal for ways to simulate terminal. It also includes a way to make it work on all unixes by injecting a dummy shared library.

@danilp-id
Copy link
Copy Markdown
Contributor Author

@danilp-id
Copy link
Copy Markdown
Contributor Author

Huh, that's really weird. Why does it now pass on everything except for macos and ubuntu x86? It still fails if I run the test locally. Can someone check?

@triska
Copy link
Copy Markdown
Contributor

triska commented Apr 23, 2026

I don't know why it fails on these systems, but one general comment: The Python script looks so small that maybe it could become a Scryer program? Is there anything we need for example in librayr(os) so that Scryer can express this?

@danilp-id
Copy link
Copy Markdown
Contributor Author

@triska we can do it like exec:run/2 from https://hexdocs.pm/erlexec/exec.html#t:cmd_option/0 and add a pty option for process_create to wrap launched process with a pseudoterminal.

@Skgland
Copy link
Copy Markdown
Contributor

Skgland commented Apr 23, 2026

@triska we can do it like exec:run/2 from https://hexdocs.pm/erlexec/exec.html#t:cmd_option/0 and add a pty option for process_create to wrap launched process with a pseudoterminal.

I don't think it's currently possible to configure that using the underlying rust API.

@danilp-id
Copy link
Copy Markdown
Contributor Author

Yes, but we can use something like portable_pty. As a bonus, it also supports windows.

@abmclin
Copy link
Copy Markdown
Contributor

abmclin commented May 2, 2026

@danilp-id thanks for this test case! It's great to be testing Scryer's REPL behavior across multiple platforms. It would be beneficial to have a complete test suite for as much of REPL's user interaction as possible to detect future regressions like the one caused by updating rustyline I had trouble adding test cases for Windows tty issues so it'll be interesting for me to see if the approach you used translates well to Windows.

@danilp-id
Copy link
Copy Markdown
Contributor Author

@abmclin Thanks! The rustyline issue is unix-only, but on windows there is ConPTY which I think can be tested using pywinpty for example. I think for now it's ok to just make a small python wrapper script to test issues like these instead of adding pseudoterminal support directly to process library (and I am not sure if it would really be that useful to add it there since anyone can just use a wrapper script if the need arises).

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.

4 participants