style: removed unneccessary path prefixes and organized imports
This commit is contained in:
3 files changed
+25
-21
No files matched your search
@@ -5268,6 +5268,7 @@ mod tests {
|
|||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
use std::fs::{create_dir_all, remove_dir_all, write};
|
use std::fs::{create_dir_all, remove_dir_all, write};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::process::Command;
|
||||||
use std::time::{Instant, SystemTime, UNIX_EPOCH};
|
use std::time::{Instant, SystemTime, UNIX_EPOCH};
|
||||||
use std::{env, mem};
|
use std::{env, mem};
|
||||||
|
|
||||||
@@ -8505,7 +8506,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn review_gauntlet_readme_states_retry_and_incomplete_contract() {
|
fn review_gauntlet_readme_states_retry_and_incomplete_contract() {
|
||||||
let readmes = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("assets/agents");
|
let readmes = Path::new(env!("CARGO_MANIFEST_DIR")).join("assets/agents");
|
||||||
// Windows checkouts carry CRLF; the paragraph assertion below spans line breaks.
|
// Windows checkouts carry CRLF; the paragraph assertion below spans line breaks.
|
||||||
let gauntlet = read_to_string(readmes.join("review-gauntlet/README.md"))
|
let gauntlet = read_to_string(readmes.join("review-gauntlet/README.md"))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@@ -9050,11 +9051,11 @@ mod tests {
|
|||||||
|
|
||||||
// Scripts' load_state() prefers GRAPH_STATE_FILE over GRAPH_STATE, so an
|
// Scripts' load_state() prefers GRAPH_STATE_FILE over GRAPH_STATE, so an
|
||||||
// inherited live state file (adversary verifying this repo) must not win.
|
// inherited live state file (adversary verifying this repo) must not win.
|
||||||
fn adversary_script_command(script: &str, state: &serde_json::Value) -> std::process::Command {
|
fn adversary_script_command(script: &str, state: &serde_json::Value) -> Command {
|
||||||
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||||
.join("assets/agents/adversary/scripts")
|
.join("assets/agents/adversary/scripts")
|
||||||
.join(script);
|
.join(script);
|
||||||
let mut cmd = std::process::Command::new("python3");
|
let mut cmd = Command::new("python3");
|
||||||
cmd.arg(&path)
|
cmd.arg(&path)
|
||||||
.env("GRAPH_STATE", state.to_string())
|
.env("GRAPH_STATE", state.to_string())
|
||||||
.env_remove("GRAPH_STATE_FILE");
|
.env_remove("GRAPH_STATE_FILE");
|
||||||
@@ -9591,7 +9592,7 @@ mod tests {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let alive = |pid: &str| {
|
let alive = |pid: &str| {
|
||||||
std::process::Command::new("kill")
|
Command::new("kill")
|
||||||
.args(["-0", pid])
|
.args(["-0", pid])
|
||||||
.output()
|
.output()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@@ -10950,7 +10951,7 @@ mod tests {
|
|||||||
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||||
.join("assets/agents/review-gauntlet/scripts")
|
.join("assets/agents/review-gauntlet/scripts")
|
||||||
.join(script);
|
.join(script);
|
||||||
let out = std::process::Command::new("python3")
|
let out = Command::new("python3")
|
||||||
.arg(&path)
|
.arg(&path)
|
||||||
.env("GRAPH_STATE", state.to_string())
|
.env("GRAPH_STATE", state.to_string())
|
||||||
.env_remove("GRAPH_STATE_FILE")
|
.env_remove("GRAPH_STATE_FILE")
|
||||||
@@ -13246,7 +13247,7 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
let adversary_verdict = read_to_string(
|
let adversary_verdict = read_to_string(
|
||||||
std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||||
.join("assets/agents/adversary/scripts/verdict.py"),
|
.join("assets/agents/adversary/scripts/verdict.py"),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -13403,11 +13404,11 @@ mod tests {
|
|||||||
eprintln!("skipping: python3 not available");
|
eprintln!("skipping: python3 not available");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
let path = Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||||
.join("assets/agents/review-gauntlet/scripts/build_items.py");
|
.join("assets/agents/review-gauntlet/scripts/build_items.py");
|
||||||
let state =
|
let state =
|
||||||
json!({"forced_lanes": ["code-review", "adversary"], "gauntlet_started_at": 5.0});
|
json!({"forced_lanes": ["code-review", "adversary"], "gauntlet_started_at": 5.0});
|
||||||
let out = std::process::Command::new("python3")
|
let out = Command::new("python3")
|
||||||
.arg(&path)
|
.arg(&path)
|
||||||
.env("GRAPH_STATE", state.to_string())
|
.env("GRAPH_STATE", state.to_string())
|
||||||
.env_remove("GRAPH_STATE_FILE")
|
.env_remove("GRAPH_STATE_FILE")
|
||||||
@@ -13459,7 +13460,7 @@ mod tests {
|
|||||||
eprintln!("skipping: python3 not available");
|
eprintln!("skipping: python3 not available");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let dir = utils::temp_file("-gauntlet-signals-", "");
|
let dir = temp_file("-gauntlet-signals-", "");
|
||||||
create_dir_all(&dir).unwrap();
|
create_dir_all(&dir).unwrap();
|
||||||
let project_dir = dir.to_string_lossy().to_string();
|
let project_dir = dir.to_string_lossy().to_string();
|
||||||
let out = run_gauntlet_script(
|
let out = run_gauntlet_script(
|
||||||
@@ -13585,7 +13586,7 @@ mod tests {
|
|||||||
fn gauntlet_retry_budget_fits_inside_graph_timeout() {
|
fn gauntlet_retry_budget_fits_inside_graph_timeout() {
|
||||||
use crate::graph::NodeType;
|
use crate::graph::NodeType;
|
||||||
const OTHER_STAGES_MARGIN_SECS: u64 = 1200;
|
const OTHER_STAGES_MARGIN_SECS: u64 = 1200;
|
||||||
let script = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
let script = Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||||
.join("assets/agents/review-gauntlet/scripts/retry_gate.py");
|
.join("assets/agents/review-gauntlet/scripts/retry_gate.py");
|
||||||
let source = read_to_string(&script).unwrap();
|
let source = read_to_string(&script).unwrap();
|
||||||
let line = source
|
let line = source
|
||||||
@@ -13707,7 +13708,7 @@ mod tests {
|
|||||||
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||||
.join("assets/agents/code-reviewer/scripts")
|
.join("assets/agents/code-reviewer/scripts")
|
||||||
.join(script);
|
.join(script);
|
||||||
let out = std::process::Command::new("python3")
|
let out = Command::new("python3")
|
||||||
.arg(&path)
|
.arg(&path)
|
||||||
.env("GRAPH_STATE", raw_state)
|
.env("GRAPH_STATE", raw_state)
|
||||||
.env_remove("GRAPH_STATE_FILE")
|
.env_remove("GRAPH_STATE_FILE")
|
||||||
@@ -14517,7 +14518,7 @@ mod tests {
|
|||||||
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||||
.join("assets/agents/finding-verifier/scripts")
|
.join("assets/agents/finding-verifier/scripts")
|
||||||
.join(script);
|
.join(script);
|
||||||
let out = std::process::Command::new("python3")
|
let out = Command::new("python3")
|
||||||
.arg(&path)
|
.arg(&path)
|
||||||
.env("GRAPH_STATE", raw_state)
|
.env("GRAPH_STATE", raw_state)
|
||||||
.env_remove("GRAPH_STATE_FILE")
|
.env_remove("GRAPH_STATE_FILE")
|
||||||
@@ -14819,7 +14820,7 @@ mod tests {
|
|||||||
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||||
.join("assets/agents/step-runner/scripts")
|
.join("assets/agents/step-runner/scripts")
|
||||||
.join(script);
|
.join(script);
|
||||||
let out = std::process::Command::new("bash")
|
let out = Command::new("bash")
|
||||||
.arg(&path)
|
.arg(&path)
|
||||||
.env("GRAPH_STATE", state.to_string())
|
.env("GRAPH_STATE", state.to_string())
|
||||||
.env_remove("GRAPH_STATE_FILE")
|
.env_remove("GRAPH_STATE_FILE")
|
||||||
@@ -15123,7 +15124,7 @@ mod tests {
|
|||||||
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||||
.join("assets/agents/deep-research/scripts")
|
.join("assets/agents/deep-research/scripts")
|
||||||
.join(script);
|
.join(script);
|
||||||
let out = std::process::Command::new("python3")
|
let out = Command::new("python3")
|
||||||
.arg(&path)
|
.arg(&path)
|
||||||
.env("GRAPH_STATE", raw_state)
|
.env("GRAPH_STATE", raw_state)
|
||||||
.env_remove("GRAPH_STATE_FILE")
|
.env_remove("GRAPH_STATE_FILE")
|
||||||
|
|||||||
@@ -346,6 +346,8 @@ fn parse_options(args: &Value) -> Result<Vec<String>> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use std::fs;
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn headless_select_returns_structured_json() {
|
fn headless_select_returns_structured_json() {
|
||||||
@@ -431,9 +433,9 @@ mod tests {
|
|||||||
concat!("escalation_timeout:", " 300"),
|
concat!("escalation_timeout:", " 300"),
|
||||||
concat!("default:", " 5 minutes"),
|
concat!("default:", " 5 minutes"),
|
||||||
];
|
];
|
||||||
let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
|
let root = Path::new(env!("CARGO_MANIFEST_DIR"));
|
||||||
let example = root.join("config.agent.example.yaml");
|
let example = root.join("config.agent.example.yaml");
|
||||||
let example_text = std::fs::read_to_string(&example).unwrap();
|
let example_text = fs::read_to_string(&example).unwrap();
|
||||||
for needle in ["escalation_timeout: 0", "0 = wait indefinitely"] {
|
for needle in ["escalation_timeout: 0", "0 = wait indefinitely"] {
|
||||||
assert!(
|
assert!(
|
||||||
example_text.contains(needle),
|
example_text.contains(needle),
|
||||||
@@ -454,7 +456,7 @@ mod tests {
|
|||||||
|
|
||||||
let mut hits = Vec::new();
|
let mut hits = Vec::new();
|
||||||
for path in &files {
|
for path in &files {
|
||||||
let text = String::from_utf8_lossy(&std::fs::read(path).unwrap()).into_owned();
|
let text = String::from_utf8_lossy(&fs::read(path).unwrap()).into_owned();
|
||||||
for needle in needles {
|
for needle in needles {
|
||||||
if text.contains(needle) {
|
if text.contains(needle) {
|
||||||
hits.push(format!("{}: {needle:?}", path.display()));
|
hits.push(format!("{}: {needle:?}", path.display()));
|
||||||
@@ -468,8 +470,8 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collect_files(dir: &std::path::Path, out: &mut Vec<std::path::PathBuf>) {
|
fn collect_files(dir: &Path, out: &mut Vec<PathBuf>) {
|
||||||
for entry in std::fs::read_dir(dir).unwrap().flatten() {
|
for entry in fs::read_dir(dir).unwrap().flatten() {
|
||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
if path.is_dir() {
|
if path.is_dir() {
|
||||||
collect_files(&path, out);
|
collect_files(&path, out);
|
||||||
|
|||||||
+3
-2
@@ -2281,6 +2281,7 @@ where
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::sync::atomic::{AtomicU64, Ordering};
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
struct TempDir {
|
struct TempDir {
|
||||||
@@ -2293,12 +2294,12 @@ mod tests {
|
|||||||
// (coarse clocks hand the same tick to concurrent callers, so two
|
// (coarse clocks hand the same tick to concurrent callers, so two
|
||||||
// tests would share a directory and overwrite each other's files);
|
// tests would share a directory and overwrite each other's files);
|
||||||
// a process-wide counter makes every name distinct.
|
// a process-wide counter makes every name distinct.
|
||||||
static SEQ: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
|
static SEQ: AtomicU64 = AtomicU64::new(0);
|
||||||
let nanos = SystemTime::now()
|
let nanos = SystemTime::now()
|
||||||
.duration_since(UNIX_EPOCH)
|
.duration_since(UNIX_EPOCH)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.as_nanos();
|
.as_nanos();
|
||||||
let seq = SEQ.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
let seq = SEQ.fetch_add(1, Ordering::Relaxed);
|
||||||
let unique = format!("{nanos}-{seq}");
|
let unique = format!("{nanos}-{seq}");
|
||||||
let path = env::temp_dir().join(format!("coyote-rag-{tag}-{unique}"));
|
let path = env::temp_dir().join(format!("coyote-rag-{tag}-{unique}"));
|
||||||
fs::create_dir_all(&path).unwrap();
|
fs::create_dir_all(&path).unwrap();
|
||||||
|
|||||||
Reference in new issue
Block a user