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 exec_replace #658

Merged
merged 1 commit into from
Sep 23, 2023
Merged

Fix exec_replace #658

merged 1 commit into from
Sep 23, 2023

Conversation

MrDenkoV
Copy link
Contributor

@MrDenkoV MrDenkoV commented Sep 8, 2023

Fix #125, Fix #129

@maciektr maciektr marked this pull request as draft September 8, 2023 15:41
@MrDenkoV MrDenkoV marked this pull request as ready for review September 12, 2023 08:27
Copy link
Member

@mkaput mkaput left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am amazed that this fixes #129. Can you please properly link #129 to this issue? (you need to write fix #125, fix #129 in issue description)

Let's test this more thoroughly

scarb/tests/subcommand.rs Show resolved Hide resolved
scarb/src/process.rs Show resolved Hide resolved
scarb/src/process.rs Outdated Show resolved Hide resolved
scarb/src/process.rs Show resolved Hide resolved
scarb/src/process.rs Show resolved Hide resolved
@maciektr
Copy link
Contributor

maciektr commented Sep 15, 2023

👋
On the topic of our offline conversation about ctrl_c test on windows 🪟 :

The error you have been seeing seems to come from the subcommand spawn.

This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher. (os error 216)

It seems that the script definition used there is just not runnable on windows. (

formatdoc!(
)

After changing the script definition, I was able to run it successfully and ensure it has been killed by ctrl_c.
To test this, I have created a main.rs file in scarb-test-support crate with following content: https://gist.github.com/maciektr/6b6c18a358b5792912bc0d0261ef3ac2
Then I have used this in tests instead.

    let addr = {
        let addr = listener.local_addr().unwrap();
        addr.to_string()
    };

    let mut child = Scarb::new()
        .std()
        .arg("test-support")
        .arg("hang-on-tcp")
        .arg("--address")
        .arg(addr)

May not be the cleanest flow, but imho worth considering.

I have not been able to make this check work though. I do not understand what is the purpose of this.

    match sock.read(&mut [0; 10]) {
        Ok(n) => assert_eq!(n, 0),
        Err(e) => assert_eq!(e.kind(), io::ErrorKind::ConnectionReset),
    }

I know it has been copied from Cargo verbatim. Maybe it is enough for now to only check if the process has been killed? cc @mkaput

@mkaput
Copy link
Member

mkaput commented Sep 19, 2023

I have not been able to make this check work though. I do not understand what is the purpose of this.

    match sock.read(&mut [0; 10]) {
        Ok(n) => assert_eq!(n, 0),
        Err(e) => assert_eq!(e.kind(), io::ErrorKind::ConnectionReset),
    }

I know it has been copied from Cargo verbatim. Maybe it is enough for now to only check if the process has been killed? cc @mkaput

This check tests if the socket either closed successfully without any unread rubbish left in the buffer, or died by the second party being terminated.

It seems that the script definition used there is just not runnable on windows. (

formatdoc!(

)
After changing the script definition, I was able to run it successfully and ensure it has been killed by ctrl_c. To test this, I have created a main.rs file in scarb-test-support crate with following content: https://gist.github.com/maciektr/6b6c18a358b5792912bc0d0261ef3ac2 Then I have used this in tests instead.

    let addr = {
        let addr = listener.local_addr().unwrap();
        addr.to_string()
    };

    let mut child = Scarb::new()
        .std()
        .arg("test-support")
        .arg("hang-on-tcp")
        .arg("--address")
        .arg(addr)

May not be the cleanest flow, but imho worth considering.

I like this! I'd only rather use Command::new(cargo_bin!("scarb-test-support")) instead of Scarb::new().std(), seems more clear.

utils/scarb-test-support/src/main.rs Outdated Show resolved Hide resolved
utils/scarb-test-support/src/main.rs Outdated Show resolved Hide resolved
scarb/tests/subcommand.rs Outdated Show resolved Hide resolved
@MrDenkoV MrDenkoV added this pull request to the merge queue Sep 23, 2023
Merged via the queue into main with commit cc1711d Sep 23, 2023
11 checks passed
@MrDenkoV MrDenkoV deleted the mrdenkov/exec_replace branch September 23, 2023 11: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.

Fix subcommand CTRL+C test Properly implement scarb::process::exec_replace
3 participants