mirror of
https://github.com/instructkr/claw-code.git
synced 2026-04-09 01:24:49 +08:00
fix(tools): serialize web_search env-var tests with env_lock to prevent race
web_search_extracts_and_filters_results set CLAWD_WEB_SEARCH_BASE_URL without holding env_lock(), while the sibling test web_search_handles_generic_links_and_invalid_base_url always held it. Under parallel test execution the two tests interleave set_var/remove_var calls, pointing the search client at the wrong mock server port and causing assertion failures. Fix: add env_lock() guard at the top of web_search_extracts_and_filters_results, matching the serialization pattern already used by every other env-mutating test in this module. Root cause of CI flake on run 24127551802. Identified and fixed during dogfood session.
This commit is contained in:
@@ -6249,6 +6249,14 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn web_search_extracts_and_filters_results() {
|
fn web_search_extracts_and_filters_results() {
|
||||||
|
// Serialize env-var mutation so this test cannot race with the sibling
|
||||||
|
// web_search_handles_generic_links_and_invalid_base_url test that also
|
||||||
|
// sets CLAWD_WEB_SEARCH_BASE_URL. Without the lock, parallel test
|
||||||
|
// runners can interleave the set/remove calls and cause assertion
|
||||||
|
// failures on the wrong port.
|
||||||
|
let _guard = env_lock()
|
||||||
|
.lock()
|
||||||
|
.unwrap_or_else(std::sync::PoisonError::into_inner);
|
||||||
let server = TestServer::spawn(Arc::new(|request_line: &str| {
|
let server = TestServer::spawn(Arc::new(|request_line: &str| {
|
||||||
assert!(request_line.contains("GET /search?q=rust+web+search "));
|
assert!(request_line.contains("GET /search?q=rust+web+search "));
|
||||||
HttpResponse::html(
|
HttpResponse::html(
|
||||||
|
|||||||
Reference in New Issue
Block a user