Skip to content

Commit 9d58554

Browse files
committed
Move RemoteCopyLibs to test_helpers
1 parent 34a1749 commit 9d58554

File tree

2 files changed

+58
-59
lines changed

2 files changed

+58
-59
lines changed

src/bootstrap/src/core/build_steps/test/mod.rs

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::{env, fs, iter};
1313

1414
use clap_complete::shells;
1515

16-
use self::test_helpers::{prepare_cargo_test, run_cargo_test};
16+
use self::test_helpers::{RemoteCopyLibs, prepare_cargo_test, run_cargo_test};
1717
use crate::core::build_steps::compile::run_cargo;
1818
use crate::core::build_steps::doc::DocumentationFormat;
1919
use crate::core::build_steps::llvm::get_llvm_version;
@@ -1723,60 +1723,6 @@ impl Step for Crate {
17231723
}
17241724
}
17251725

1726-
/// Some test suites are run inside emulators or on remote devices, and most
1727-
/// of our test binaries are linked dynamically which means we need to ship
1728-
/// the standard library and such to the emulator ahead of time. This step
1729-
/// represents this and is a dependency of all test suites.
1730-
///
1731-
/// Most of the time this is a no-op. For some steps such as shipping data to
1732-
/// QEMU we have to build our own tools so we've got conditional dependencies
1733-
/// on those programs as well. Note that the remote test client is built for
1734-
/// the build target (us) and the server is built for the target.
1735-
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1736-
pub struct RemoteCopyLibs {
1737-
compiler: Compiler,
1738-
target: TargetSelection,
1739-
}
1740-
1741-
impl Step for RemoteCopyLibs {
1742-
type Output = ();
1743-
1744-
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1745-
run.never()
1746-
}
1747-
1748-
fn run(self, builder: &Builder<'_>) {
1749-
let compiler = self.compiler;
1750-
let target = self.target;
1751-
if !builder.remote_tested(target) {
1752-
return;
1753-
}
1754-
1755-
builder.ensure(compile::Std::new(compiler, target));
1756-
1757-
builder.info(&format!("REMOTE copy libs to emulator ({target})"));
1758-
1759-
let server = builder.ensure(tool::RemoteTestServer { compiler, target });
1760-
1761-
// Spawn the emulator and wait for it to come online
1762-
let tool = builder.tool_exe(Tool::RemoteTestClient);
1763-
let mut cmd = command(&tool);
1764-
cmd.arg("spawn-emulator").arg(target.triple).arg(&server).arg(builder.tempdir());
1765-
if let Some(rootfs) = builder.qemu_rootfs(target) {
1766-
cmd.arg(rootfs);
1767-
}
1768-
cmd.run(builder);
1769-
1770-
// Push all our dylibs to the emulator
1771-
for f in t!(builder.sysroot_target_libdir(compiler, target).read_dir()) {
1772-
let f = t!(f);
1773-
if helpers::is_dylib(&f.path()) {
1774-
command(&tool).arg("push").arg(f.path()).run(builder);
1775-
}
1776-
}
1777-
}
1778-
}
1779-
17801726
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
17811727
pub struct Distcheck;
17821728

src/bootstrap/src/core/build_steps/test/test_helpers.rs

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
use std::env;
22
use std::path::PathBuf;
33

4-
use crate::core::build_steps::tool::Tool;
5-
use crate::core::builder::{self, Builder, Kind};
4+
use crate::core::build_steps::compile;
5+
use crate::core::build_steps::tool::{self, Tool};
6+
use crate::core::builder::{self, Builder, Compiler, Kind, ShouldRun, Step};
67
use crate::core::config::TargetSelection;
7-
use crate::utils::exec::BootstrapCommand;
8-
use crate::utils::helpers::{self, dylib_path, dylib_path_var};
8+
use crate::utils::exec::{BootstrapCommand, command};
9+
use crate::utils::helpers::{self, dylib_path, dylib_path_var, t};
910
use crate::utils::render_tests::add_flags_and_try_run_tests;
1011
use crate::{DocTests, envify};
1112

@@ -122,3 +123,55 @@ pub(super) fn prepare_cargo_test(
122123

123124
cargo
124125
}
126+
127+
/// Some test suites are run inside emulators or on remote devices, and most of our test binaries
128+
/// are linked dynamically which means we need to ship the standard library and such to the emulator
129+
/// ahead of time. This step represents this and is a dependency of all test suites.
130+
///
131+
/// Most of the time this is a no-op. For some steps such as shipping data to QEMU we have to build
132+
/// our own tools so we've got conditional dependencies on those programs as well. Note that the
133+
/// remote test client is built for the build target (us) and the server is built for the target.
134+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
135+
pub(super) struct RemoteCopyLibs {
136+
pub(super) compiler: Compiler,
137+
pub(super) target: TargetSelection,
138+
}
139+
140+
impl Step for RemoteCopyLibs {
141+
type Output = ();
142+
143+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
144+
run.never()
145+
}
146+
147+
fn run(self, builder: &Builder<'_>) {
148+
let compiler = self.compiler;
149+
let target = self.target;
150+
if !builder.remote_tested(target) {
151+
return;
152+
}
153+
154+
builder.ensure(compile::Std::new(compiler, target));
155+
156+
builder.info(&format!("REMOTE copy libs to emulator ({target})"));
157+
158+
let server = builder.ensure(tool::RemoteTestServer { compiler, target });
159+
160+
// Spawn the emulator and wait for it to come online
161+
let tool = builder.tool_exe(Tool::RemoteTestClient);
162+
let mut cmd = command(&tool);
163+
cmd.arg("spawn-emulator").arg(target.triple).arg(&server).arg(builder.tempdir());
164+
if let Some(rootfs) = builder.qemu_rootfs(target) {
165+
cmd.arg(rootfs);
166+
}
167+
cmd.run(builder);
168+
169+
// Push all our dylibs to the emulator
170+
for f in t!(builder.sysroot_target_libdir(compiler, target).read_dir()) {
171+
let f = t!(f);
172+
if helpers::is_dylib(&f.path()) {
173+
command(&tool).arg("push").arg(f.path()).run(builder);
174+
}
175+
}
176+
}
177+
}

0 commit comments

Comments
 (0)