mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
tools/remote-test-server: make use of verbose option
There was an unused verbose command line argument. Add some prints if verbose is set.
This commit is contained in:
parent
1b7ec76c16
commit
9e137bb8b6
@ -41,6 +41,7 @@ macro_rules! t {
|
|||||||
|
|
||||||
static TEST: AtomicUsize = AtomicUsize::new(0);
|
static TEST: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
struct Config {
|
struct Config {
|
||||||
pub remote: bool,
|
pub remote: bool,
|
||||||
pub verbose: bool,
|
pub verbose: bool,
|
||||||
@ -71,6 +72,12 @@ impl Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn print_verbose(s: &str, conf: Config) {
|
||||||
|
if conf.verbose {
|
||||||
|
println!("{}", s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("starting test server");
|
println!("starting test server");
|
||||||
|
|
||||||
@ -92,7 +99,7 @@ fn main() {
|
|||||||
tmp_dir.push("tmp");
|
tmp_dir.push("tmp");
|
||||||
(work_dir, tmp_dir)
|
(work_dir, tmp_dir)
|
||||||
};
|
};
|
||||||
println!("listening!");
|
println!("listening on {}!", bind_addr);
|
||||||
|
|
||||||
t!(fs::create_dir_all(&work));
|
t!(fs::create_dir_all(&work));
|
||||||
t!(fs::create_dir_all(&tmp));
|
t!(fs::create_dir_all(&tmp));
|
||||||
@ -106,23 +113,25 @@ fn main() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if &buf[..] == b"ping" {
|
if &buf[..] == b"ping" {
|
||||||
|
print_verbose("Received ping", config);
|
||||||
t!(socket.write_all(b"pong"));
|
t!(socket.write_all(b"pong"));
|
||||||
} else if &buf[..] == b"push" {
|
} else if &buf[..] == b"push" {
|
||||||
handle_push(socket, &work);
|
handle_push(socket, &work, config);
|
||||||
} else if &buf[..] == b"run " {
|
} else if &buf[..] == b"run " {
|
||||||
let lock = lock.clone();
|
let lock = lock.clone();
|
||||||
let work = work.clone();
|
let work = work.clone();
|
||||||
let tmp = tmp.clone();
|
let tmp = tmp.clone();
|
||||||
thread::spawn(move || handle_run(socket, &work, &tmp, &lock));
|
thread::spawn(move || handle_run(socket, &work, &tmp, &lock, config));
|
||||||
} else {
|
} else {
|
||||||
panic!("unknown command {:?}", buf);
|
panic!("unknown command {:?}", buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_push(socket: TcpStream, work: &Path) {
|
fn handle_push(socket: TcpStream, work: &Path, config: Config) {
|
||||||
let mut reader = BufReader::new(socket);
|
let mut reader = BufReader::new(socket);
|
||||||
recv(&work, &mut reader);
|
let dst = recv(&work, &mut reader);
|
||||||
|
print_verbose(&format!("push {:#?}", dst), config);
|
||||||
|
|
||||||
let mut socket = reader.into_inner();
|
let mut socket = reader.into_inner();
|
||||||
t!(socket.write_all(b"ack "));
|
t!(socket.write_all(b"ack "));
|
||||||
@ -138,7 +147,7 @@ impl Drop for RemoveOnDrop<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_run(socket: TcpStream, work: &Path, tmp: &Path, lock: &Mutex<()>) {
|
fn handle_run(socket: TcpStream, work: &Path, tmp: &Path, lock: &Mutex<()>, config: Config) {
|
||||||
let mut arg = Vec::new();
|
let mut arg = Vec::new();
|
||||||
let mut reader = BufReader::new(socket);
|
let mut reader = BufReader::new(socket);
|
||||||
|
|
||||||
@ -205,6 +214,7 @@ fn handle_run(socket: TcpStream, work: &Path, tmp: &Path, lock: &Mutex<()>) {
|
|||||||
// binary is and then we'll download it all to the exe path we calculated
|
// binary is and then we'll download it all to the exe path we calculated
|
||||||
// earlier.
|
// earlier.
|
||||||
let exe = recv(&path, &mut reader);
|
let exe = recv(&path, &mut reader);
|
||||||
|
print_verbose(&format!("run {:#?}", exe), config);
|
||||||
|
|
||||||
let mut cmd = Command::new(&exe);
|
let mut cmd = Command::new(&exe);
|
||||||
cmd.args(args);
|
cmd.args(args);
|
||||||
|
Loading…
Reference in New Issue
Block a user