Skip to content

[WIP] option for store dir relative to the target dir #2154

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 77 additions & 31 deletions cargo-nextest/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ use nextest_runner::{
errors::{TargetTripleError, WriteTestListError},
input::InputHandlerKind,
list::{
BinaryList, OutputFormat, RustTestArtifact, SerializableFormat, TestExecuteContext,
TestList,
BinaryList, OutputFormat, RustBuildMeta, RustTestArtifact, SerializableFormat,
TestExecuteContext, TestList, TestListState,
},
partition::PartitionerBuilder,
platform::{BuildPlatforms, HostPlatform, PlatformLibdir, TargetPlatform},
redact::Redactor,
reporter::{
events::{FinalRunStats, RunStatsFailureKind},
highlight_end, structured, FinalStatusLevel, ReporterBuilder, StatusLevel,
highlight_end, structured, EventAggregator, FinalStatusLevel, ReporterBuilder, StatusLevel,
TestOutputDisplay, TestOutputErrorSlice,
},
reuse_build::{archive_to_file, ArchiveReporter, PathMapper, ReuseBuildInfo},
Expand Down Expand Up @@ -611,20 +611,14 @@ impl TestBuildFilter {
test_filter_builder: TestFilterBuilder,
env: EnvironmentMap,
ecx: &EvalContext<'_>,
reuse_build: &ReuseBuildInfo,
rust_build_meta: RustBuildMeta<TestListState>,
path_mapper: &PathMapper,
) -> Result<TestList<'g>> {
let path_mapper = make_path_mapper(
reuse_build,
graph,
&binary_list.rust_build_meta.target_directory,
)?;

let rust_build_meta = binary_list.rust_build_meta.map_paths(&path_mapper);
let test_artifacts = RustTestArtifact::from_binary_list(
graph,
binary_list,
&rust_build_meta,
&path_mapper,
path_mapper,
self.platform_filter.into(),
)?;
TestList::new(
Expand Down Expand Up @@ -1420,12 +1414,11 @@ impl BaseApp {
let binary_list = self.build_binary_list()?;
let path_mapper = PathMapper::noop();

let build_platforms = binary_list.rust_build_meta.build_platforms.clone();
let pcx = ParseContext::new(self.graph());
let (_, config) = self.load_config(&pcx)?;
let profile = self
.load_profile(&config)?
.apply_build_platforms(&build_platforms);
.into_evaluatable(&binary_list.rust_build_meta.build_platforms);

let redactor = if should_redact() {
Redactor::build_active(&binary_list.rust_build_meta)
Expand Down Expand Up @@ -1502,11 +1495,6 @@ impl BaseApp {
let profile = config
.profile(profile_name)
.map_err(ExpectedError::profile_not_found)?;
let store_dir = profile.store_dir();
std::fs::create_dir_all(store_dir).map_err(|err| ExpectedError::StoreDirCreateError {
store_dir: store_dir.to_owned(),
err,
})?;
Ok(profile)
}
}
Expand Down Expand Up @@ -1569,6 +1557,8 @@ impl App {
binary_list: Arc<BinaryList>,
test_filter_builder: TestFilterBuilder,
ecx: &EvalContext<'_>,
rust_build_meta: RustBuildMeta<TestListState>,
path_mapper: &PathMapper,
) -> Result<TestList> {
let env = EnvironmentMap::new(&self.base.cargo_configs);
self.build_filter.compute_test_list(
Expand All @@ -1579,7 +1569,8 @@ impl App {
test_filter_builder,
env,
ecx,
&self.base.reuse_build,
rust_build_meta,
path_mapper,
)
}

Expand Down Expand Up @@ -1617,16 +1608,29 @@ impl App {
.base
.load_runner(&binary_list.rust_build_meta.build_platforms);
let profile =
profile.apply_build_platforms(&binary_list.rust_build_meta.build_platforms);
profile.into_evaluatable(&binary_list.rust_build_meta.build_platforms);
let ctx = TestExecuteContext {
profile_name: profile.name(),
double_spawn,
target_runner,
};
let ecx = profile.filterset_ecx();

let test_list =
self.build_test_list(&ctx, binary_list, test_filter_builder, &ecx)?;
let path_mapper = make_path_mapper(
&self.base.reuse_build,
self.base.graph(),
&binary_list.rust_build_meta.target_directory,
)?;
let rust_build_meta = binary_list.rust_build_meta.map_paths(&path_mapper);

let test_list = self.build_test_list(
&ctx,
binary_list,
test_filter_builder,
&ecx,
rust_build_meta,
&path_mapper,
)?;

let mut writer = output_writer.stdout_writer();
test_list.write(
Expand Down Expand Up @@ -1673,15 +1677,29 @@ impl App {

let double_spawn = self.base.load_double_spawn();
let target_runner = self.base.load_runner(&build_platforms);
let profile = profile.apply_build_platforms(&build_platforms);
let profile = profile.into_evaluatable(&build_platforms);
let ctx = TestExecuteContext {
profile_name: profile.name(),
double_spawn,
target_runner,
};
let ecx = profile.filterset_ecx();

let test_list = self.build_test_list(&ctx, binary_list, test_filter_builder, &ecx)?;
let path_mapper = make_path_mapper(
&self.base.reuse_build,
self.base.graph(),
&binary_list.rust_build_meta.target_directory,
)?;
let rust_build_meta = binary_list.rust_build_meta.map_paths(&path_mapper);

let test_list = self.build_test_list(
&ctx,
binary_list,
test_filter_builder,
&ecx,
rust_build_meta,
&path_mapper,
)?;

let mut writer = output_writer.stdout_writer();

Expand Down Expand Up @@ -1712,7 +1730,8 @@ impl App {
let (version_only_config, config) = self.base.load_config(&pcx)?;
let profile = self.base.load_profile(&config)?;

// Construct this here so that errors are reported before the build step.
// Construct this here so that errors are reported before the build
// step.
let mut structured_reporter = structured::StructuredReporter::new();
match reporter_opts.message_format {
MessageFormat::Human => {}
Expand Down Expand Up @@ -1752,19 +1771,40 @@ impl App {
let test_filter_builder = self.build_filter.make_test_filter_builder(filter_exprs)?;

let binary_list = self.base.build_binary_list()?;
let build_platforms = &binary_list.rust_build_meta.build_platforms.clone();
let path_mapper = make_path_mapper(
&self.base.reuse_build,
self.base.graph(),
&binary_list.rust_build_meta.target_directory,
)?;
let rust_build_meta = binary_list.rust_build_meta.map_paths(&path_mapper);

let profile = profile.into_evaluatable(&binary_list.rust_build_meta.build_platforms);

// This is the earliest point where we can create the aggregator, since
// we need the remapped target directory which is only available after
// the test list is built.
let aggregator = EventAggregator::new(&profile, &rust_build_meta.target_directory)?;

let double_spawn = self.base.load_double_spawn();
let target_runner = self.base.load_runner(build_platforms);
let target_runner = self
.base
.load_runner(&binary_list.rust_build_meta.build_platforms);

let profile = profile.apply_build_platforms(build_platforms);
let ctx = TestExecuteContext {
profile_name: profile.name(),
double_spawn,
target_runner,
};
let ecx = profile.filterset_ecx();

let test_list = self.build_test_list(&ctx, binary_list, test_filter_builder, &ecx)?;
let test_list = self.build_test_list(
&ctx,
binary_list,
test_filter_builder,
&ecx,
rust_build_meta,
&path_mapper,
)?;

let output = output_writer.reporter_output();
let should_colorize = self
Expand Down Expand Up @@ -1805,7 +1845,13 @@ impl App {
let mut reporter = reporter_opts
.to_builder(no_capture, should_colorize)
.set_verbose(self.base.output.verbose)
.build(&test_list, &profile, output, structured_reporter);
.build(
&test_list,
&profile,
output,
aggregator,
structured_reporter,
);

configure_handle_inheritance(no_capture)?;
let run_stats = runner.try_execute(|event| {
Expand Down
20 changes: 8 additions & 12 deletions cargo-nextest/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,10 @@
#[from]
err: ProfileNotFound,
},
#[error("failed to create store directory")]
StoreDirCreateError {
store_dir: Utf8PathBuf,
#[source]
err: std::io::Error,
#[error("junit setup error")]
JunitSetupError {
#[from]
err: JunitSetupError,
},
#[error("cargo config error")]
CargoConfigError {
Expand Down Expand Up @@ -395,7 +394,7 @@
| Self::SetCurrentDirFailed { .. }
| Self::GetCurrentExeFailed { .. }
| Self::ProfileNotFound { .. }
| Self::StoreDirCreateError { .. }
| Self::JunitSetupError { .. }
| Self::RootManifestNotFound { .. }
| Self::CargoConfigError { .. }
| Self::TestFilterBuilderError { .. }
Expand Down Expand Up @@ -521,12 +520,9 @@
);
None
}
Self::StoreDirCreateError { store_dir, err } => {
error!(
"failed to create store dir at `{}`",
store_dir.style(styles.bold)
);
Some(err as &dyn Error)
Self::JunitSetupError { err } => {
error!("{}", err);
err.source()

Check warning on line 525 in cargo-nextest/src/errors.rs

View check run for this annotation

Codecov / codecov/patch

cargo-nextest/src/errors.rs#L523-L525

Added lines #L523 - L525 were not covered by tests
}
Self::CargoConfigError { err } => {
error!("{}", err);
Expand Down
8 changes: 4 additions & 4 deletions nextest-runner/src/config/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ mod tests {
config
.profile("default")
.expect("default profile exists")
.apply_build_platforms(&build_platforms())
.into_evaluatable(&build_platforms())
.archive_config(),
&default_config,
"default matches"
Expand All @@ -317,7 +317,7 @@ mod tests {
config
.profile("profile1")
.expect("profile exists")
.apply_build_platforms(&build_platforms())
.into_evaluatable(&build_platforms())
.archive_config(),
&ArchiveConfig {
include: vec![ArchiveInclude {
Expand All @@ -334,7 +334,7 @@ mod tests {
config
.profile("profile2")
.expect("default profile exists")
.apply_build_platforms(&build_platforms())
.into_evaluatable(&build_platforms())
.archive_config(),
&ArchiveConfig { include: vec![] },
"profile2 matches"
Expand All @@ -344,7 +344,7 @@ mod tests {
config
.profile("profile3")
.expect("default profile exists")
.apply_build_platforms(&build_platforms())
.into_evaluatable(&build_platforms())
.archive_config(),
&default_config,
"profile3 matches"
Expand Down
Loading
Loading