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

Support rust-cross #51

Open
epage opened this issue Dec 22, 2021 · 3 comments
Open

Support rust-cross #51

epage opened this issue Dec 22, 2021 · 3 comments
Labels
A-trycmd Area: trycmd package enhancement Improve the expected

Comments

@epage
Copy link
Contributor

epage commented Dec 22, 2021

From assert-rs/assert_cmd#139

It would be nice to mention that when running tests in cross, one needs to prepend their command with the value contained in CARGO_TARGET_*_RUNNER i.e qemu-aarch64 xh

fn find_runner() -> Option<String> {
    for (key, value) in std::env::vars() {
        if key.starts_with("CARGO_TARGET_") && key.ends_with("_RUNNER") && value.contains("qemu") {
            return Some(value);
        }
    }
    None
}

fn get_base_command() -> Command {
    let mut cmd;
    let path = assert_cmd::cargo::cargo_bin("xh");
    if let Some(runner) = find_runner() {
        cmd = Command::new(runner);
        cmd.arg(path);
    } else {
        cmd = Command::new(path);
    }
    cmd
}

Also, see ducaale/xh#190 (comment)

@tmatilai
Copy link

tmatilai commented Jan 9, 2023

How could this be used with TestCases? There is default_bin_path(), but no way to push args, as far as I see.

@epage epage changed the title Document how to use trycmd with rust-cross Support rust-cross Jan 10, 2023
@epage
Copy link
Contributor Author

epage commented Jan 10, 2023

I've fixed the title to better reflect the situation. I don't use cross, so I don't have test cases or have a feel for what all the needs are.

@tmatilai
Copy link

So when running with cross, the tested command should be in the form like :

/linux-runner armv7 /target/armv7-unknown-linux-gnueabihf/debug/command --some args

The "wrapper" prefix is taken from the CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_RUNNER env variable.

I'm not very experienced with Rust, and not familiar with the trycmd code base, so I might have hard times figuring out a way to add ability to optionally prepend commands. But I can take a look later if you give some hints. 🙂

@settings settings bot removed the A-trycmd label Aug 14, 2023
@epage epage added the A-trycmd Area: trycmd package label Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trycmd Area: trycmd package enhancement Improve the expected
Projects
None yet
Development

No branches or pull requests

2 participants