From 2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:50 +0200 Subject: Merging upstream version 1.69.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/jobserver/tests/client.rs | 3 +-- vendor/jobserver/tests/make-as-a-client.rs | 3 +-- vendor/jobserver/tests/server.rs | 29 ++++++++++++++++++++++++++--- 3 files changed, 28 insertions(+), 7 deletions(-) (limited to 'vendor/jobserver/tests') diff --git a/vendor/jobserver/tests/client.rs b/vendor/jobserver/tests/client.rs index 7f319c09c..2516b8ccf 100644 --- a/vendor/jobserver/tests/client.rs +++ b/vendor/jobserver/tests/client.rs @@ -10,7 +10,6 @@ use std::thread; use futures::future::{self, Future}; use futures::stream::{self, Stream}; use jobserver::Client; -use tempdir::TempDir; use tokio_core::reactor::Core; use tokio_process::CommandExt; @@ -128,7 +127,7 @@ fn main() { None => true, }) .map(|test| { - let td = t!(TempDir::new("foo")); + let td = t!(tempfile::tempdir()); let makefile = format!( "\ all: export TEST_TO_RUN={} diff --git a/vendor/jobserver/tests/make-as-a-client.rs b/vendor/jobserver/tests/make-as-a-client.rs index e530211b0..4faac5b88 100644 --- a/vendor/jobserver/tests/make-as-a-client.rs +++ b/vendor/jobserver/tests/make-as-a-client.rs @@ -5,7 +5,6 @@ use std::net::{TcpListener, TcpStream}; use std::process::Command; use jobserver::Client; -use tempdir::TempDir; macro_rules! t { ($e:expr) => { @@ -37,7 +36,7 @@ fn main() { } let c = t!(Client::new(1)); - let td = TempDir::new("foo").unwrap(); + let td = tempfile::tempdir().unwrap(); let prog = env::var("MAKE").unwrap_or_else(|_| "make".to_string()); diff --git a/vendor/jobserver/tests/server.rs b/vendor/jobserver/tests/server.rs index fcdd12ca2..70ea218fc 100644 --- a/vendor/jobserver/tests/server.rs +++ b/vendor/jobserver/tests/server.rs @@ -8,7 +8,6 @@ use std::sync::Arc; use std::thread; use jobserver::Client; -use tempdir::TempDir; macro_rules! t { ($e:expr) => { @@ -34,6 +33,30 @@ fn server_multiple() { drop((a, b)); } +#[test] +fn server_available() { + let c = t!(Client::new(10)); + assert_eq!(c.available().unwrap(), 10); + let a = c.acquire().unwrap(); + assert_eq!(c.available().unwrap(), 9); + drop(a); + assert_eq!(c.available().unwrap(), 10); +} + +#[test] +fn server_none_available() { + let c = t!(Client::new(2)); + assert_eq!(c.available().unwrap(), 2); + let a = c.acquire().unwrap(); + assert_eq!(c.available().unwrap(), 1); + let b = c.acquire().unwrap(); + assert_eq!(c.available().unwrap(), 0); + drop(a); + assert_eq!(c.available().unwrap(), 1); + drop(b); + assert_eq!(c.available().unwrap(), 2); +} + #[test] fn server_blocks() { let c = t!(Client::new(1)); @@ -56,7 +79,7 @@ fn server_blocks() { #[test] fn make_as_a_single_thread_client() { let c = t!(Client::new(1)); - let td = TempDir::new("foo").unwrap(); + let td = tempfile::tempdir().unwrap(); let prog = env::var("MAKE").unwrap_or_else(|_| "make".to_string()); let mut cmd = Command::new(prog); @@ -110,7 +133,7 @@ foo #[test] fn make_as_a_multi_thread_client() { let c = t!(Client::new(1)); - let td = TempDir::new("foo").unwrap(); + let td = tempfile::tempdir().unwrap(); let prog = env::var("MAKE").unwrap_or_else(|_| "make".to_string()); let mut cmd = Command::new(prog); -- cgit v1.2.3