这是indexloc提供的服务,不要输入任何密码
Skip to content

chore: fix lints in tests #10707

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

Merged
merged 2 commits into from
Jul 22, 2025
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
7 changes: 3 additions & 4 deletions crates/turborepo-analytics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@

#[derive(Clone)]
struct ErrorClient {
tx: mpsc::UnboundedSender<()>,

Check warning on line 449 in crates/turborepo-analytics/src/lib.rs

View workflow job for this annotation

GitHub Actions / Turborepo Rust testing on windows

field `tx` is never read

Check warning on line 449 in crates/turborepo-analytics/src/lib.rs

View workflow job for this annotation

GitHub Actions / Turborepo Rust testing on macos

field `tx` is never read

Check warning on line 449 in crates/turborepo-analytics/src/lib.rs

View workflow job for this annotation

GitHub Actions / Turborepo Rust testing on ubuntu

field `tx` is never read
}

impl AnalyticsClient for ErrorClient {
Expand All @@ -456,10 +456,9 @@
_events: Vec<AnalyticsEvent>,
) -> Result<(), turborepo_api_client::Error> {
// Simulate an error using a simple error type
Err(turborepo_api_client::Error::ReadError(std::io::Error::new(
std::io::ErrorKind::Other,
"test error",
)))
Err(turborepo_api_client::Error::ReadError(
std::io::Error::other("test error"),
))
}
}
}
18 changes: 9 additions & 9 deletions crates/turborepo-api-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ mod test {
async fn test_do_preflight() -> Result<()> {
let port = port_scanner::request_open_port().unwrap();
let handle = tokio::spawn(start_test_server(port));
let base_url = format!("http://localhost:{}", port);
let base_url = format!("http://localhost:{port}");

let client = APIClient::new(
&base_url,
Expand All @@ -806,7 +806,7 @@ mod test {
let response = client
.do_preflight(
"",
Url::parse(&format!("{}/preflight/absolute-location", base_url)).unwrap(),
Url::parse(&format!("{base_url}/preflight/absolute-location")).unwrap(),
"GET",
"Authorization, User-Agent",
)
Expand All @@ -817,7 +817,7 @@ mod test {
let response = client
.do_preflight(
"",
Url::parse(&format!("{}/preflight/relative-location", base_url)).unwrap(),
Url::parse(&format!("{base_url}/preflight/relative-location")).unwrap(),
"GET",
"Authorization, User-Agent",
)
Expand All @@ -830,7 +830,7 @@ mod test {
let response = client
.do_preflight(
"",
Url::parse(&format!("{}/preflight/allow-auth", base_url)).unwrap(),
Url::parse(&format!("{base_url}/preflight/allow-auth")).unwrap(),
"GET",
"Authorization, User-Agent",
)
Expand All @@ -841,7 +841,7 @@ mod test {
let response = client
.do_preflight(
"",
Url::parse(&format!("{}/preflight/no-allow-auth", base_url)).unwrap(),
Url::parse(&format!("{base_url}/preflight/no-allow-auth")).unwrap(),
"GET",
"Authorization, User-Agent",
)
Expand Down Expand Up @@ -882,7 +882,7 @@ mod test {
async fn test_content_length() -> Result<()> {
let port = port_scanner::request_open_port().unwrap();
let handle = tokio::spawn(start_test_server(port));
let base_url = format!("http://localhost:{}", port);
let base_url = format!("http://localhost:{port}");

let client = APIClient::new(
&base_url,
Expand Down Expand Up @@ -917,7 +917,7 @@ mod test {
async fn test_record_telemetry_success() -> Result<()> {
let port = port_scanner::request_open_port().unwrap();
let handle = tokio::spawn(start_test_server(port));
let base_url = format!("http://localhost:{}", port);
let base_url = format!("http://localhost:{port}");

let client = AnonAPIClient::new(&base_url, 10, "2.0.0")?;

Expand Down Expand Up @@ -952,7 +952,7 @@ mod test {
async fn test_record_telemetry_empty_events() -> Result<()> {
let port = port_scanner::request_open_port().unwrap();
let handle = tokio::spawn(start_test_server(port));
let base_url = format!("http://localhost:{}", port);
let base_url = format!("http://localhost:{port}");

let client = AnonAPIClient::new(&base_url, 10, "2.0.0")?;

Expand All @@ -974,7 +974,7 @@ mod test {
async fn test_record_telemetry_with_different_event_types() -> Result<()> {
let port = port_scanner::request_open_port().unwrap();
let handle = tokio::spawn(start_test_server(port));
let base_url = format!("http://localhost:{}", port);
let base_url = format!("http://localhost:{port}");

let client = AnonAPIClient::new(&base_url, 10, "2.0.0")?;

Expand Down
3 changes: 1 addition & 2 deletions crates/turborepo-auth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,7 @@ mod tests {
assert_eq!(
is_token_active(&metadata, current_time),
expected,
"Test failed for active_at: {}",
active_at
"Test failed for active_at: {active_at}"
);
}
}
Expand Down
10 changes: 5 additions & 5 deletions crates/turborepo-cache/src/async_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ mod tests {
};

let api_client = APIClient::new(
format!("http://localhost:{}", port),
format!("http://localhost:{port}"),
Some(Duration::from_secs(200)),
None,
"2.0.0",
Expand Down Expand Up @@ -311,7 +311,7 @@ mod tests {
async_cache.wait().await.unwrap();

let fs_cache_path =
repo_root_path.join_components(&[".turbo", "cache", &format!("{}.tar.zst", hash)]);
repo_root_path.join_components(&[".turbo", "cache", &format!("{hash}.tar.zst")]);

// Confirm that fs cache file does *not* exist
assert!(!fs_cache_path.exists());
Expand Down Expand Up @@ -402,7 +402,7 @@ mod tests {
async_cache.wait().await.unwrap();

let fs_cache_path =
repo_root_path.join_components(&[".turbo", "cache", &format!("{}.tar.zst", hash)]);
repo_root_path.join_components(&[".turbo", "cache", &format!("{hash}.tar.zst")]);

// Confirm that fs cache file exists
assert!(fs_cache_path.exists());
Expand Down Expand Up @@ -462,7 +462,7 @@ mod tests {
};

let api_client = APIClient::new(
format!("http://localhost:{}", port),
format!("http://localhost:{port}"),
Some(Duration::from_secs(200)),
None,
"2.0.0",
Expand Down Expand Up @@ -499,7 +499,7 @@ mod tests {
async_cache.wait().await.unwrap();

let fs_cache_path =
repo_root_path.join_components(&[".turbo", "cache", &format!("{}.tar.zst", hash)]);
repo_root_path.join_components(&[".turbo", "cache", &format!("{hash}.tar.zst")]);

// Confirm that fs cache file exists
assert!(fs_cache_path.exists());
Expand Down
9 changes: 3 additions & 6 deletions crates/turborepo-cache/src/cache_archive/restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ mod tests {
fn compress_tar(archive_path: &AbsoluteSystemPathBuf) -> Result<AbsoluteSystemPathBuf> {
let mut input_file = File::open(archive_path)?;

let output_file_path = format!("{}.zst", archive_path);
let output_file_path = format!("{archive_path}.zst");
let output_file = File::create(&output_file_path)?;

let mut zw = zstd::stream::Encoder::new(output_file, 0)?;
Expand Down Expand Up @@ -883,10 +883,7 @@ mod tests {

match (cache_reader.restore(anchor), &test.expected_output) {
(Ok(restored_files), Err(expected_error)) => {
panic!(
"expected error: {:?}, received {:?}",
expected_error, restored_files
);
panic!("expected error: {expected_error:?}, received {restored_files:?}");
}
(Ok(restored_files), Ok(expected_files)) => {
assert_eq!(&restored_files, expected_files);
Expand All @@ -896,7 +893,7 @@ mod tests {
continue;
}
(Err(err), Ok(_)) => {
panic!("unexpected error: {:?}", err);
panic!("unexpected error: {err:?}");
}
};

Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-cache/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ mod test {
test_case.initialize(repo_root_path)?;

let api_client = APIClient::new(
format!("http://localhost:{}", port),
format!("http://localhost:{port}"),
Some(Duration::from_secs(200)),
None,
"2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-cache/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ mod test {
let duration = test_case.duration;

let api_client = APIClient::new(
format!("http://localhost:{}", port),
format!("http://localhost:{port}"),
Some(Duration::from_secs(200)),
None,
"2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions crates/turborepo-cache/src/test_cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ pub(crate) async fn validate_analytics(
source: analytics::CacheSource,
port: u16,
) -> Result<()> {
let response = reqwest::get(format!("http://localhost:{}/v8/artifacts/events", port)).await?;
let response = reqwest::get(format!("http://localhost:{port}/v8/artifacts/events")).await?;
assert_eq!(response.status(), 200);
let analytics_events: Vec<AnalyticsEvent> = response.json().await?;

assert_eq!(analytics_events.len(), test_cases.len() * 2);

println!("{:#?}", analytics_events);
println!("{analytics_events:#?}");
for test_case in test_cases {
println!("finding {}", test_case.hash);
// We should have a hit and a miss event for both test cases
Expand Down
6 changes: 3 additions & 3 deletions crates/turborepo-filewatch/src/fsevent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,11 +549,11 @@ unsafe fn callback_impl(
let raw_path = unsafe { CStr::from_ptr(*event_paths.add(p)) }
.to_str()
.expect("Invalid UTF8 string.");
let path = PathBuf::from(format!("/{}", raw_path));
let path = PathBuf::from(format!("/{raw_path}"));

let flag = unsafe { *event_flags.add(p) };
let flag = StreamFlags::from_bits(flag).unwrap_or_else(|| {
panic!("Unable to decode StreamFlags: {}", flag);
panic!("Unable to decode StreamFlags: {flag}");
});

let mut handle_event = false;
Expand Down Expand Up @@ -602,7 +602,7 @@ impl Watcher for FsEventWatcher {
let (tx, rx) = std::sync::mpsc::channel();
self.configure_raw_mode(config, tx);
rx.recv()
.map_err(|err| Error::generic(&format!("internal channel disconnect: {:?}", err)))?
.map_err(|err| Error::generic(&format!("internal channel disconnect: {err:?}")))?
}

fn kind() -> WatcherKind {
Expand Down
11 changes: 2 additions & 9 deletions crates/turborepo-filewatch/src/hash_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,11 +714,7 @@ mod tests {
&repo.signature().unwrap(),
"Commit",
&tree,
previous_commit
.as_ref()
.as_ref()
.map(std::slice::from_ref)
.unwrap_or_default(),
previous_commit.as_ref().as_slice(),
)
.unwrap();
}
Expand Down Expand Up @@ -1037,10 +1033,7 @@ mod tests {
}
tokio::time::sleep(Duration::from_millis(200)).await;
}
panic!(
"failed to get expected hashes. Error {:?}, last hashes: {:?}",
error, last_value
);
panic!("failed to get expected hashes. Error {error:?}, last hashes: {last_value:?}");
}

fn make_expected(expected: Vec<(&str, &str)>) -> GitHashes {
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-filewatch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ mod test {
) {
for dir in dirs {
let count = WATCH_COUNT.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
let filename = dir.join_component(format!("test-{}", count).as_str());
let filename = dir.join_component(format!("test-{count}").as_str());
filename.create_with_contents("hello").unwrap();

expect_filesystem_event!(recv, filename, EventKind::Create(_));
Expand Down
16 changes: 6 additions & 10 deletions crates/turborepo-globwalk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ mod test {
include_exp: Option<&[&str]>,
exclude_exp: Option<&[&str]>,
) {
let raw_path = format!("{}{}", ROOT, base_path);
let raw_path = format!("{ROOT}{base_path}");
let base_path = AbsoluteSystemPathBuf::new(raw_path).unwrap();
let include = include.iter().map(|s| s.to_string()).collect_vec();
let exclude = exclude.iter().map(|s| s.to_string()).collect_vec();
Expand All @@ -568,7 +568,7 @@ mod test {
include,
include_exp
.iter()
.map(|s| format!("{}{}", GLOB_ROOT, s))
.map(|s| format!("{GLOB_ROOT}{s}"))
.collect_vec()
.as_slice()
);
Expand All @@ -579,7 +579,7 @@ mod test {
exclude,
exclude_exp
.iter()
.map(|s| format!("{}{}", GLOB_ROOT, s))
.map(|s| format!("{GLOB_ROOT}{s}"))
.collect_vec()
.as_slice()
);
Expand Down Expand Up @@ -751,10 +751,7 @@ mod test {
assert_eq!(
success.len(),
result_count,
"{}: expected {} matches, but got {:#?}",
pattern,
result_count,
success
"{pattern}: expected {result_count} matches, but got {success:#?}"
);

None
Expand Down Expand Up @@ -1395,8 +1392,7 @@ mod test {

assert_eq!(
success, expected,
"\n\n{:?}: expected \n{:#?} but got \n{:#?}",
walk_type, expected, success
"\n\n{walk_type:?}: expected \n{expected:#?} but got \n{success:#?}"
);
}
}
Expand Down Expand Up @@ -1453,7 +1449,7 @@ mod test {
let path = tmp.path().join(file);
let parent = path.parent().unwrap();
std::fs::create_dir_all(parent)
.unwrap_or_else(|_| panic!("failed to create {:?}", parent));
.unwrap_or_else(|_| panic!("failed to create {parent:?}"));
std::fs::File::create(path).unwrap();
}
tmp
Expand Down
6 changes: 3 additions & 3 deletions crates/turborepo-graph-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ mod test {
g.add_edge(c, a, ());

let breaks = edges_to_break_cycle(&g);
assert_eq!(breaks.len(), 3, "{:?}", breaks);
assert_eq!(breaks.len(), 3, "{breaks:?}");
let mut edges_that_break = HashSet::new();
for brk in breaks {
assert_eq!(brk.len(), 1);
Expand Down Expand Up @@ -296,7 +296,7 @@ mod test {
g.add_edge(d, a, ());

let breaks = edges_to_break_cycle(&g);
assert_eq!(breaks.len(), 1, "{:?}", breaks);
assert_eq!(breaks.len(), 1, "{breaks:?}");
assert_eq!(
breaks.into_iter().flatten().exactly_one().unwrap(),
("a", "b")
Expand All @@ -320,7 +320,7 @@ mod test {
g.add_edge(c, b, ());

let breaks = edges_to_break_cycle(&g);
assert_eq!(breaks.len(), 3, "{:?}", breaks);
assert_eq!(breaks.len(), 3, "{breaks:?}");
let expected_1: HashSet<_> = [("b", "c"), ("a", "c")].iter().copied().collect();
let expected_2: HashSet<_> = [("b", "c"), ("c", "a")].iter().copied().collect();
let expected_3: HashSet<_> = [("c", "b"), ("c", "a")].iter().copied().collect();
Expand Down
8 changes: 1 addition & 7 deletions crates/turborepo-lib/src/microfrontends.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,7 @@ mod test {
let result = PackageGraphResult::new(
HashSet::default(),
vec![
(
"a",
Err(Error::Io(std::io::Error::new(
std::io::ErrorKind::Other,
"something",
))),
),
("a", Err(Error::Io(std::io::Error::other("something")))),
(
"b",
Err(Error::ChildConfig {
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-lib/src/shim/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ mod test {
color,
no_color,
root_turbo_json: relative_root_turbo_json
.map(|path| AbsoluteSystemPathBuf::from_unknown(&invocation_dir, path)),
.map(|path| AbsoluteSystemPathBuf::from_unknown(invocation_dir, path)),
}
}
}
Expand Down
Loading
Loading