Skip to content
Merged
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
4 changes: 2 additions & 2 deletions rust/delivery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1368,9 +1368,9 @@ impl<T: Transport, O: Observer> Driver<'_, T, O> {
})
.map(str::to_owned)
.collect::<Vec<_>>();
if inventory.len() > 4096 {
if inventory.len() > 32_768 {
return Err(Error::type_error(
"Local planning inventory exceeds 4096 files; a bounded host inventory is required",
"Local planning inventory exceeds 32768 files; a bounded host inventory is required",
));
}
let planning = Box::pin(driver.run_planner_session_owned_after_pre_plan(
Expand Down
158 changes: 130 additions & 28 deletions rust/execution/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2857,6 +2857,19 @@ impl Boundary {
extra_env: &BTreeMap<String, String>,
timeout: u64,
limit: usize,
) -> Result<ObservedProcess, Error> {
self.process_in_dir(&self.root, executable, args, extra_env, timeout, limit)
.await
}

pub(crate) async fn process_in_dir(
&self,
cwd: &Path,
executable: &Path,
args: &[String],
extra_env: &BTreeMap<String, String>,
timeout: u64,
limit: usize,
) -> Result<ObservedProcess, Error> {
self.check()?;
let family = if self.host.node20.as_deref() == Some(executable) {
Expand Down Expand Up @@ -2885,7 +2898,7 @@ impl Boundary {
};
let scope = family.and_then(|label| self.span(label));
let run = backend::Owner::Execution(self)
.run(&self.root, executable, args, extra_env, timeout, limit)
.run(cwd, executable, args, extra_env, timeout, limit)
.await;
super::timing::finish(scope, run.as_ref().err());
pending.settled = true;
Expand All @@ -2909,7 +2922,7 @@ impl Boundary {
stderr: run.stderr,
});
}
let mut command = self.host.command(&self.root, executable, args, extra_env);
let mut command = self.host.command(cwd, executable, args, extra_env);
let scope = family.and_then(|label| self.span(label));
let output = process::execute_timed(
&mut command,
Expand Down Expand Up @@ -3431,10 +3444,12 @@ impl Boundary {
"no:cacheprovider".to_owned(),
"-o".to_owned(),
"addopts=".to_owned(),
"-W".to_owned(),
"default".to_owned(),
];
noadd_args.extend(test_files.clone());
result.commands.push(format!(
"python3 -B -m pytest -o addopts= {}",
"python3 -B -m pytest -o addopts= -W default {}",
test_files.join(" ")
));
active_out = self
Expand All @@ -3448,6 +3463,8 @@ impl Boundary {
.await?;
extra_pytest_flags.push("-o".to_owned());
extra_pytest_flags.push("addopts=".to_owned());
extra_pytest_flags.push("-W".to_owned());
extra_pytest_flags.push("default".to_owned());
pytest_combined = format!(
"{}\n{}",
String::from_utf8_lossy(&active_out.stdout),
Expand Down Expand Up @@ -3534,6 +3551,7 @@ impl Boundary {

pub(crate) fn is_pytest_addopts_plugin_error(output: &str) -> bool {
output.contains("Error importing plugin \"")
|| output.contains("PytestConfigWarning: Unknown config option:")
|| (output.contains("unrecognized arguments:")
&& (output.contains("--cov")
|| output.contains("--numprocesses")
Expand Down Expand Up @@ -3639,15 +3657,34 @@ impl Boundary {
environment.insert(var.to_owned(), val);
}
}
let version = self
.process(
let mut dotnet_cwd = self.root.clone();
let mut version = self
.process_in_dir(
&dotnet_cwd,
&dotnet,
&["--version".to_owned()],
&environment,
15_000,
4096,
)
.await?;
if version.exit != 0 && self.root.join("global.json").is_file() {
let fallback_cwd = std::env::temp_dir();
let retry_version = self
.process_in_dir(
&fallback_cwd,
&dotnet,
&["--version".to_owned()],
&environment,
15_000,
4096,
)
.await?;
if retry_version.exit == 0 {
dotnet_cwd = fallback_cwd;
version = retry_version;
}
}
if version.exit != 0 {
let message = format!(
"dotnet SDK preflight failed in worktree (check global.json): {}",
Expand Down Expand Up @@ -3709,6 +3746,11 @@ impl Boundary {
));
};
let proj_path = self.root.join(&test_proj);
let proj_arg = if dotnet_cwd == self.root {
test_proj.clone()
} else {
proj_path.display().to_string()
};
let proj_text = fs::read_to_string(&proj_path).unwrap_or_default();
let mut props_text = proj_text.clone();
let mut scan_dir = proj_path.parent();
Expand Down Expand Up @@ -3786,7 +3828,7 @@ impl Boundary {
.map(|h| PathBuf::from(h).join(".nuget").join("packages"))
})
.filter(|p| p.is_dir());
let mut online_restore_args = vec!["restore".to_owned(), test_proj.clone()];
let mut online_restore_args = vec!["restore".to_owned(), proj_arg.clone()];
if needs_tfm_override && let Some(framework) = tfm {
online_restore_args.push(format!("-p:TargetFrameworks={framework}"));
}
Expand All @@ -3802,7 +3844,8 @@ impl Boundary {
restore_args.push(cache.display().to_string());
}
let mut restore_out = self
.process(
.process_in_dir(
&dotnet_cwd,
&dotnet,
&restore_args,
&environment,
Expand All @@ -3821,7 +3864,8 @@ impl Boundary {
&& restore_args != online_restore_args
{
let retry = self
.process(
.process_in_dir(
&dotnet_cwd,
&dotnet,
&online_restore_args,
&environment,
Expand All @@ -3847,7 +3891,7 @@ impl Boundary {
let _ = fs::remove_file(&trx_path);
let mut args = vec![
"test".to_owned(),
test_proj.clone(),
proj_arg.clone(),
"--no-restore".to_owned(),
];
if use_artifacts {
Expand Down Expand Up @@ -3877,7 +3921,8 @@ impl Boundary {
args.push(format!("trx;LogFileName={}", trx_path.display()));
commands.push(format!("dotnet {}", args.join(" ")));
let mut output = self
.process(
.process_in_dir(
&dotnet_cwd,
&dotnet,
&args,
&environment,
Expand All @@ -3901,7 +3946,7 @@ impl Boundary {
let _ = fs::remove_file(&trx_path);
let mut unfiltered_args = vec![
"test".to_owned(),
test_proj.clone(),
proj_arg.clone(),
"--no-restore".to_owned(),
];
if use_artifacts {
Expand All @@ -3919,7 +3964,8 @@ impl Boundary {
unfiltered_args.push(format!("trx;LogFileName={}", trx_path.display()));
commands.push(format!("dotnet {}", unfiltered_args.join(" ")));
output = self
.process(
.process_in_dir(
&dotnet_cwd,
&dotnet,
&unfiltered_args,
&environment,
Expand Down Expand Up @@ -4834,14 +4880,22 @@ impl Boundary {
let mut completed = 0;
let mut integration_stems = Vec::new();
for file in requirements.files.iter().chain(self.written.iter()) {
if let Some(rest) = file.strip_prefix("tests/")
&& !rest.contains('/')
&& let Some(stem) = rest.strip_suffix(".rs")
&& !integration_stems
.iter()
.any(|existing: &String| existing == stem)
{
integration_stems.push(stem.to_owned());
if let Some(rest) = file.strip_prefix("tests/") {
if !rest.contains('/')
&& let Some(stem) = rest.strip_suffix(".rs")
&& !integration_stems
.iter()
.any(|existing: &String| existing == stem)
{
integration_stems.push(stem.to_owned());
} else if let Some((dir, _)) = rest.split_once('/')
&& self.root.join("tests").join(dir).join("main.rs").is_file()
&& !integration_stems
.iter()
.any(|existing: &String| existing == dir)
{
integration_stems.push(dir.to_owned());
}
}
}
let has_integration_test = !integration_stems.is_empty()
Expand All @@ -4855,14 +4909,28 @@ impl Boundary {
let sub_tests_prefix = format!("{sc}/tests/");
let mut sub_integration_stems = Vec::new();
for file in requirements.files.iter().chain(self.written.iter()) {
if let Some(rest) = file.strip_prefix(&sub_tests_prefix)
&& !rest.contains('/')
&& let Some(stem) = rest.strip_suffix(".rs")
&& !sub_integration_stems
.iter()
.any(|existing: &String| existing == stem)
{
sub_integration_stems.push(stem.to_owned());
if let Some(rest) = file.strip_prefix(&sub_tests_prefix) {
if !rest.contains('/')
&& let Some(stem) = rest.strip_suffix(".rs")
&& !sub_integration_stems
.iter()
.any(|existing: &String| existing == stem)
{
sub_integration_stems.push(stem.to_owned());
} else if let Some((dir, _)) = rest.split_once('/')
&& self
.root
.join(sc)
.join("tests")
.join(dir)
.join("main.rs")
.is_file()
&& !sub_integration_stems
.iter()
.any(|existing: &String| existing == dir)
{
sub_integration_stems.push(dir.to_owned());
}
}
}
let target_flag = if self.root.join(sc).join("src").join("lib.rs").is_file() {
Expand Down Expand Up @@ -5242,6 +5310,40 @@ impl Boundary {
output.stdout.clear();
}
}
if is_test
&& !is_roster_self
&& !args.iter().any(|a| a == "--all-features")
&& (output.exit == 0
&& String::from_utf8_lossy(&output.stdout).contains("running 0 tests"))
{
let mut feat_args = Vec::with_capacity(args.len() + 1);
let mut inserted = false;
for a in &args {
if !inserted && a == "--" {
feat_args.push("--all-features".to_owned());
inserted = true;
}
feat_args.push(a.clone());
}
if !inserted {
feat_args.push("--all-features".to_owned());
}
commands.push(format!("cargo {}", feat_args.join(" ")));
let feat_out = self
.process(
&approved.executable,
&feat_args,
&environment,
policy::FULL_TEST_TIMEOUT_MS,
4 * 1024 * 1024,
)
.await?;
if feat_out.exit == 0
&& !String::from_utf8_lossy(&feat_out.stdout).contains("running 0 tests")
{
output = feat_out;
}
}
if !(is_metadata && output.exit == 0) {
stdout.push_str(&bytes_text(&output.stdout)?);
}
Expand Down
4 changes: 2 additions & 2 deletions rust/planning/grounding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,9 @@ pub fn related_exports(
}

pub fn read_context(root: &Path, files: &[String], ask: &str) -> Result<Context, Error> {
if files.len() > 4096 {
if files.len() > 32_768 {
return Err(Error::type_error(
"Planning repository inventory exceeds 4096 files",
"Planning repository inventory exceeds 32768 files",
));
}
let mut sources = Vec::new();
Expand Down
4 changes: 2 additions & 2 deletions rust/planning/lifecycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,9 +1011,9 @@ pub async fn tracked_files(
})
.map(str::to_owned)
.collect::<Vec<_>>();
if files.len() > 4096 {
if files.len() > 32_768 {
return Err(Error::type_error(
"Planning repository inventory exceeds 4096 files; provide a bounded relevant inventory",
"Planning repository inventory exceeds 32768 files; provide a bounded relevant inventory",
));
}
for file in &files {
Expand Down
3 changes: 3 additions & 0 deletions rust/seats/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2385,6 +2385,9 @@ fn pytest_missing_fixture_detector_distinguishes_plugin_errors_from_real_failure
assert!(tools::Boundary::is_pytest_addopts_plugin_error(
"ERROR: Error importing plugin \"pytest_cov\": No module named 'pytest_cov'"
));
assert!(tools::Boundary::is_pytest_addopts_plugin_error(
"pytest.PytestConfigWarning: Unknown config option: timeout"
));
assert!(!tools::Boundary::is_pytest_addopts_plugin_error(
normal_fail
));
Expand Down
Loading