From 50063749e2b52098136df47dd22f7edd2b26ee5b Mon Sep 17 00:00:00 2001 From: David Sherret Date: Tue, 8 Jun 2021 17:56:54 -0400 Subject: chore(tests): Friendlier message when running the tests and forgetting to run `cargo build` first. (#10901) --- test_util/src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test_util/src') diff --git a/test_util/src/lib.rs b/test_util/src/lib.rs index 4cfc5cc9c..db0114b8c 100644 --- a/test_util/src/lib.rs +++ b/test_util/src/lib.rs @@ -132,6 +132,15 @@ pub fn test_server_path() -> PathBuf { p } +fn ensure_test_server_built() { + // if the test server doesn't exist then remind the developer to build first + if !test_server_path().exists() { + panic!( + "Test server not found. Please cargo build before running the tests." + ); + } +} + /// Benchmark server that just serves "hello world" responses. async fn hyper_hello(port: u16) { println!("hyper hello"); @@ -1043,6 +1052,7 @@ impl Drop for HttpServerGuard { /// last instance of the HttpServerGuard is dropped, the subprocess will be /// killed. pub fn http_server() -> HttpServerGuard { + ensure_test_server_built(); let mut g = lock_http_server(); g.inc(); HttpServerGuard {} -- cgit v1.2.3