Simplify make_run
for test::Crate
by introducing crate_paths
instead of calculating them after the fact
This commit is contained in:
parent
11909e3588
commit
400f23e04b
3 changed files with 14 additions and 31 deletions
|
@ -301,7 +301,9 @@ pub struct Build {
|
||||||
ar: HashMap<TargetSelection, PathBuf>,
|
ar: HashMap<TargetSelection, PathBuf>,
|
||||||
ranlib: HashMap<TargetSelection, PathBuf>,
|
ranlib: HashMap<TargetSelection, PathBuf>,
|
||||||
// Miscellaneous
|
// Miscellaneous
|
||||||
|
// allow bidirectional lookups: both name -> path and path -> name
|
||||||
crates: HashMap<Interned<String>, Crate>,
|
crates: HashMap<Interned<String>, Crate>,
|
||||||
|
crate_paths: HashMap<PathBuf, Interned<String>>,
|
||||||
is_sudo: bool,
|
is_sudo: bool,
|
||||||
ci_env: CiEnv,
|
ci_env: CiEnv,
|
||||||
delayed_failures: RefCell<Vec<String>>,
|
delayed_failures: RefCell<Vec<String>>,
|
||||||
|
@ -491,6 +493,7 @@ impl Build {
|
||||||
ar: HashMap::new(),
|
ar: HashMap::new(),
|
||||||
ranlib: HashMap::new(),
|
ranlib: HashMap::new(),
|
||||||
crates: HashMap::new(),
|
crates: HashMap::new(),
|
||||||
|
crate_paths: HashMap::new(),
|
||||||
is_sudo,
|
is_sudo,
|
||||||
ci_env: CiEnv::current(),
|
ci_env: CiEnv::current(),
|
||||||
delayed_failures: RefCell::new(Vec::new()),
|
delayed_failures: RefCell::new(Vec::new()),
|
||||||
|
|
|
@ -49,7 +49,11 @@ pub fn build(build: &mut Build) {
|
||||||
.filter(|dep| dep.source.is_none())
|
.filter(|dep| dep.source.is_none())
|
||||||
.map(|dep| INTERNER.intern_string(dep.name))
|
.map(|dep| INTERNER.intern_string(dep.name))
|
||||||
.collect();
|
.collect();
|
||||||
build.crates.insert(name, Crate { name, deps, path });
|
let krate = Crate { name, deps, path };
|
||||||
|
let relative_path = krate.local_path(build);
|
||||||
|
build.crates.insert(name, krate);
|
||||||
|
let existing_path = build.crate_paths.insert(relative_path, name);
|
||||||
|
assert!(existing_path.is_none(), "multiple crates with the same path");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ use crate::native;
|
||||||
use crate::tool::{self, SourceType, Tool};
|
use crate::tool::{self, SourceType, Tool};
|
||||||
use crate::toolstate::ToolState;
|
use crate::toolstate::ToolState;
|
||||||
use crate::util::{self, add_link_lib_path, dylib_path, dylib_path_var, output, t};
|
use crate::util::{self, add_link_lib_path, dylib_path, dylib_path_var, output, t};
|
||||||
use crate::Crate as CargoCrate;
|
|
||||||
use crate::{envify, CLang, DocTests, GitRepo, Mode};
|
use crate::{envify, CLang, DocTests, GitRepo, Mode};
|
||||||
|
|
||||||
const ADB_TEST_DIR: &str = "/data/tmp/work";
|
const ADB_TEST_DIR: &str = "/data/tmp/work";
|
||||||
|
@ -1901,19 +1900,10 @@ impl Step for CrateLibrustc {
|
||||||
fn make_run(run: RunConfig<'_>) {
|
fn make_run(run: RunConfig<'_>) {
|
||||||
let builder = run.builder;
|
let builder = run.builder;
|
||||||
let compiler = builder.compiler(builder.top_stage, run.build_triple());
|
let compiler = builder.compiler(builder.top_stage, run.build_triple());
|
||||||
|
let krate = builder.crate_paths[&run.path];
|
||||||
for krate in builder.in_tree_crates("rustc-main", Some(run.target)) {
|
|
||||||
if krate.path.ends_with(&run.path) {
|
|
||||||
let test_kind = builder.kind.into();
|
let test_kind = builder.kind.into();
|
||||||
|
|
||||||
builder.ensure(CrateLibrustc {
|
builder.ensure(CrateLibrustc { compiler, target: run.target, test_kind, krate });
|
||||||
compiler,
|
|
||||||
target: run.target,
|
|
||||||
test_kind,
|
|
||||||
krate: krate.name,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run(self, builder: &Builder<'_>) {
|
fn run(self, builder: &Builder<'_>) {
|
||||||
|
@ -1947,24 +1937,10 @@ impl Step for Crate {
|
||||||
fn make_run(run: RunConfig<'_>) {
|
fn make_run(run: RunConfig<'_>) {
|
||||||
let builder = run.builder;
|
let builder = run.builder;
|
||||||
let compiler = builder.compiler(builder.top_stage, run.build_triple());
|
let compiler = builder.compiler(builder.top_stage, run.build_triple());
|
||||||
|
|
||||||
let make = |mode: Mode, krate: &CargoCrate| {
|
|
||||||
let test_kind = builder.kind.into();
|
let test_kind = builder.kind.into();
|
||||||
|
let krate = builder.crate_paths[&run.path];
|
||||||
|
|
||||||
builder.ensure(Crate {
|
builder.ensure(Crate { compiler, target: run.target, mode: Mode::Std, test_kind, krate });
|
||||||
compiler,
|
|
||||||
target: run.target,
|
|
||||||
mode,
|
|
||||||
test_kind,
|
|
||||||
krate: krate.name,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
for krate in builder.in_tree_crates("test", Some(run.target)) {
|
|
||||||
if krate.path.ends_with(&run.path) {
|
|
||||||
make(Mode::Std, krate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Runs all unit tests plus documentation tests for a given crate defined
|
/// Runs all unit tests plus documentation tests for a given crate defined
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue