//! `toolkit egress-proxy` takes exactly `--socket --allow `: with anything after //! them it is not the proxy, and exits 2 at once rather than listening (M3b review). Do not edit. #[path = "support/mod.rs"] mod support; use std::process::{Command, Stdio}; use std::time::{Duration, Instant}; #[test] fn trailing_arguments_are_not_the_proxy_form() { let dir = support::TempDir::new("egress-form"); let socket = dir.path().join("egress.sock"); let mut child = Command::new(env!("CARGO_BIN_EXE_toolkit")) .args([ "egress-proxy", "--socket", socket.to_str().unwrap(), "--allow", "example.com", "extra", ]) .stdin(Stdio::null()) .stdout(Stdio::null()) .stderr(Stdio::null()) .spawn() .unwrap(); let until = Instant::now() + Duration::from_secs(3); let status = loop { if let Some(status) = child.try_wait().unwrap() { break status; } if Instant::now() > until { let _ = child.kill(); let _ = child.wait(); panic!("it is listening: trailing arguments were accepted"); } std::thread::sleep(Duration::from_millis(20)); }; assert_eq!(status.code(), Some(2)); assert!(!socket.exists(), "no socket was made"); }