summaryrefslogtreecommitdiffstats
path: root/third_party/rust/minidump-writer/tests/common/mod.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
commit8dd16259287f58f9273002717ec4d27e97127719 (patch)
tree3863e62a53829a84037444beab3abd4ed9dfc7d0 /third_party/rust/minidump-writer/tests/common/mod.rs
parentReleasing progress-linux version 126.0.1-1~progress7.99u1. (diff)
downloadfirefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz
firefox-8dd16259287f58f9273002717ec4d27e97127719.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/minidump-writer/tests/common/mod.rs')
-rw-r--r--third_party/rust/minidump-writer/tests/common/mod.rs67
1 files changed, 29 insertions, 38 deletions
diff --git a/third_party/rust/minidump-writer/tests/common/mod.rs b/third_party/rust/minidump-writer/tests/common/mod.rs
index bbb6abf35c..1d5497b3ba 100644
--- a/third_party/rust/minidump-writer/tests/common/mod.rs
+++ b/third_party/rust/minidump-writer/tests/common/mod.rs
@@ -8,21 +8,27 @@ type Error = Box<dyn error::Error + std::marker::Send + std::marker::Sync>;
#[allow(unused)]
pub type Result<T> = result::Result<T, Error>;
+fn build_command() -> Command {
+ let mut cmd = Command::new("cargo");
+
+ cmd.env("RUST_BACKTRACE", "1")
+ .args(["run", "-q", "--bin", "test"]);
+
+ // In normal cases where the host and target are the same this won't matter,
+ // but tests will fail if you are eg running in a cross container which will
+ // likely be x86_64 but may be targetting aarch64 or i686, which will result
+ // in tests failing, or at the least not testing what you think
+ cmd.args(["--target", current_platform::CURRENT_PLATFORM, "--"]);
+
+ cmd
+}
+
#[allow(unused)]
pub fn spawn_child(command: &str, args: &[&str]) {
- let mut cmd_object = Command::new("cargo");
- let mut cmd_ref = cmd_object
- .env("RUST_BACKTRACE", "1")
- .arg("run")
- .arg("-q")
- .arg("--bin")
- .arg("test")
- .arg("--")
- .arg(command);
- for arg in args {
- cmd_ref = cmd_ref.arg(arg);
- }
- let child = cmd_ref.output().expect("failed to execute child");
+ let mut cmd = build_command();
+ cmd.arg(command).args(args);
+
+ let child = cmd.output().expect("failed to execute child");
println!("Child output:");
std::io::stdout().write_all(&child.stdout).unwrap();
@@ -30,20 +36,12 @@ pub fn spawn_child(command: &str, args: &[&str]) {
assert_eq!(child.status.code().expect("No return value"), 0);
}
-fn start_child_and_wait_for_threads_helper(cmd: &str, num: usize) -> Child {
- let mut child = Command::new("cargo")
- .env("RUST_BACKTRACE", "1")
- .arg("run")
- .arg("-q")
- .arg("--bin")
- .arg("test")
- .arg("--")
- .arg(cmd)
- .arg(format!("{}", num))
- .stdout(Stdio::piped())
- .spawn()
- .expect("failed to execute child");
+fn start_child_and_wait_for_threads_helper(command: &str, num: usize) -> Child {
+ let mut cmd = build_command();
+ cmd.arg(command).arg(num.to_string());
+ cmd.stdout(Stdio::piped());
+ let mut child = cmd.spawn().expect("failed to spawn cargo");
wait_for_threads(&mut child, num);
child
}
@@ -84,17 +82,10 @@ pub fn wait_for_threads(child: &mut Child, num: usize) {
#[allow(unused)]
pub fn start_child_and_return(args: &[&str]) -> Child {
- let mut child = Command::new("cargo")
- .env("RUST_BACKTRACE", "1")
- .arg("run")
- .arg("-q")
- .arg("--bin")
- .arg("test")
- .arg("--")
- .args(args)
- .stdout(Stdio::piped())
- .spawn()
- .expect("failed to execute child");
+ let mut cmd = build_command();
+ cmd.args(args);
- child
+ cmd.stdout(Stdio::piped())
+ .spawn()
+ .expect("failed to execute child")
}