Skip to content

Commit

Permalink
u
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Jan 27, 2025
1 parent ee9612a commit 875cf74
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
7 changes: 6 additions & 1 deletion tasks/common/src/request.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::time::Duration;

use ureq::{Agent, Proxy};

/// detect proxy from environment variable in following order:
Expand All @@ -16,6 +18,9 @@ fn detect_proxy() -> Option<Proxy> {

/// build a agent with proxy automatically detected
pub fn agent() -> Agent {
let config = Agent::config_builder().proxy(detect_proxy()).build();
let config = Agent::config_builder()
.proxy(detect_proxy())
.timeout_global(Some(Duration::from_secs(5)))
.build();
Agent::new_with_config(config)
}
8 changes: 2 additions & 6 deletions tasks/coverage/src/runtime/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use std::{
path::{Path, PathBuf},
time::Duration,
};
use std::path::{Path, PathBuf};

use serde_json::json;

Expand Down Expand Up @@ -274,10 +271,9 @@ async fn request_run_code(json: impl serde::Serialize + Send + 'static) -> Resul
tokio::spawn(async move {
agent()
.post("http://localhost:32055/run")
.timeout(Duration::from_secs(4))
.send_json(json)
.map_err(|err| err.to_string())
.and_then(|res| res.into_string().map_err(|err| err.to_string()))
.and_then(|mut res| res.body_mut().read_to_string().map_err(|err| err.to_string()))
})
.await
.map_err(|err| err.to_string())?
Expand Down
6 changes: 3 additions & 3 deletions tasks/coverage/src/runtime/test262_status.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{fs, sync::OnceLock, time::Duration};
use std::{fs, sync::OnceLock};

use oxc_tasks_common::agent;
use regex::Regex;
Expand All @@ -19,10 +19,10 @@ pub fn get_v8_test262_failure_paths() -> &'static Vec<String> {
} else {
let res = agent()
.get("http://raw.githubusercontent.com/v8/v8/main/test/test262/test262.status")
.timeout(Duration::from_secs(10))
.call()
.unwrap()
.into_string()
.body_mut()
.read_to_string()
.unwrap();
let mut tests = Regex::new(r"'(.+)': \[(FAIL|SKIP)\]")
.unwrap()
Expand Down

0 comments on commit 875cf74

Please sign in to comment.