diff --git a/Cargo.lock b/Cargo.lock index efd7bd7..18325fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,38 +8,11 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5cde24d1b2e2216a726368b2363a273739c91f4e3eb4e0dd12d672d396ad989" -[[package]] -name = "byteorder" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c40977b0ee6b9885c9013cd41d9feffdd22deb3bb4dc3a71d901cc7a77de18c8" - -[[package]] -name = "bytes" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86503b85bb937cbdf6e63f0e9d0b7ec3bbe1b40041865bdab199d33ddb03a18a" -dependencies = [ - "byteorder", -] - -[[package]] -name = "cfg-if" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de1e760d7b6535af4241fca8bd8adf68e2e7edacc6b29f5d399050c5e48cf88c" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - [[package]] name = "fuchsia-zircon" -version = "0.3.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd510087c325af53ba24f3be8f1c081b0982319adcb8b03cad764512923ccc19" +checksum = "3b5365afd01fdf916e775a224e844f80b3b9710d0f4f00903e219e859474d7ae" dependencies = [ "bitflags", "fuchsia-zircon-sys", @@ -47,176 +20,23 @@ dependencies = [ [[package]] name = "fuchsia-zircon-sys" -version = "0.3.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08b3a6f13ad6b96572b53ce7af74543132f1a7055ccceb6d073dd36c54481859" - -[[package]] -name = "futures" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bab5b5e94f5c31fc764ba5dd9ad16568aae5d4825538c01d6bca680c9bf94a7" - -[[package]] -name = "iovec" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6e8b9c2247fcf6c6a1151f1156932be5606c9fd6f55a2d7f9fc1cb29386b2f7" -dependencies = [ - "libc 0.2.54", - "winapi 0.2.4", -] +checksum = "069def9a0e5feb7e9120635f6ebad24d853a6affbb077fec84d0888316cf9ae6" [[package]] name = "jobserver" version = "0.1.28" dependencies = [ - "futures", - "libc 0.2.54", - "num_cpus", + "libc", "tempfile", - "tokio-core", - "tokio-process", -] - -[[package]] -name = "kernel32-sys" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1ca084b49bfd975182288e1a5f1d27ea34ff2d6ae084ae5e66e1652427eada" -dependencies = [ - "winapi 0.2.4", - "winapi-build", ] -[[package]] -name = "lazycell" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec38a5c22f1ef3e30d2642aa875620d60edeef36cef43c4739d86215ce816331" - -[[package]] -name = "lazycell" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6f08839bc70ef4a3fe1d566d5350f519c5912ea86be0df1740a7d247c7fc0ef" - [[package]] name = "libc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "367f169cc2ae9afbe5c7309b3d5c34dced82e9da121104d2b826cf2aee3502ae" - -[[package]] -name = "libc" -version = "0.2.54" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6785aa7dd976f5fbf3b71cfd9cd49d7f783c1ff565a858d71031c6c313aa5c6" - -[[package]] -name = "log" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b2b224ebf7a4745d17092755d196ea731205e68d6d8e9987015131434725594" -dependencies = [ - "libc 0.1.0", -] - -[[package]] -name = "log" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "mio" -version = "0.6.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d771e3ef92d58a8da8df7d6976bfca9371ed1de6619d9d5a5ce5b1f29b85bfe" -dependencies = [ - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec", - "kernel32-sys", - "lazycell 0.6.0", - "libc 0.2.54", - "log 0.4.14", - "miow 0.2.2", - "net2", - "slab 0.4.0", - "winapi 0.2.4", -] - -[[package]] -name = "mio-named-pipes" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea8f1e005b1f0cddae23d34af820144bf3785623e3dd3bee23dc08fd913830e8" -dependencies = [ - "kernel32-sys", - "lazycell 0.5.0", - "log 0.3.0", - "mio", - "miow 0.1.4", - "winapi 0.2.4", -] - -[[package]] -name = "mio-uds" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b6bd83b05675b13929d3c3add6c8cabf0067a63e8bb56bf231b8203946e0aa7" -dependencies = [ - "libc 0.2.54", - "mio", -] - -[[package]] -name = "miow" -version = "0.1.4" +version = "0.2.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6b54090eaa23880441a80c4adec5fd6b4af1152a49c5e78f96a82469abc6942" -dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.4", - "ws2_32-sys", -] - -[[package]] -name = "miow" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" -dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.4", - "ws2_32-sys", -] - -[[package]] -name = "net2" -version = "0.2.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7cf75f38f16cb05ea017784dc6dbfd354f76c223dba37701734c4f5a9337d02" -dependencies = [ - "cfg-if 0.1.0", - "libc 0.2.54", - "winapi 0.3.0", -] - -[[package]] -name = "num_cpus" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a859041cbf7a70ea1ece4b87d1a2c6ef364dcb68749c88db1f97304b9ec09d5f" -dependencies = [ - "libc 0.2.54", -] +checksum = "aab692d7759f5cd8c859e169db98ae5b52c924add2af5fbbca11d12fefb567c1" [[package]] name = "rand" @@ -225,7 +45,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d5f78082e6a6d042862611e9640cf20776185fee506cf6cf67e93c6225cee31" dependencies = [ "fuchsia-zircon", - "libc 0.2.54", + "libc", ] [[package]] @@ -240,125 +60,22 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfc5b3ce5d5ea144bb04ebd093a9e14e9765bcfec866aecda9b6dec43b3d1e24" dependencies = [ - "winapi 0.3.0", + "winapi", ] -[[package]] -name = "scoped-tls" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f417c22df063e9450888a7561788e9bd46d3bb3c1466435b4eccb903807f147d" - -[[package]] -name = "slab" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b4fcaed89ab08ef143da37bc52adbcc04d4a69014f4c1208d6b51f0c47bc23" - -[[package]] -name = "slab" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdeff4cd9ecff59ec7e3744cbca73dfe5ac35c2aedb2cfba8a1c715a18912e9d" - [[package]] name = "tempfile" version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47776f63b85777d984a50ce49d6b9e58826b6a3766a449fc95bc66cd5663c15b" dependencies = [ - "libc 0.2.54", + "libc", "rand", "redox_syscall", "remove_dir_all", - "winapi 0.3.0", -] - -[[package]] -name = "tokio-core" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "659cbae6c954dee37352853816c6a52180e47feb70be73bbfeec6d58c4da4a71" -dependencies = [ - "futures", - "log 0.3.0", - "mio", - "scoped-tls", - "slab 0.3.0", -] - -[[package]] -name = "tokio-executor" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46108c2aca0eb4b9a883bf37a28d122ca70f5318446f59f729cd1ff78a0bb5fb" -dependencies = [ - "futures", -] - -[[package]] -name = "tokio-io" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6af9eb326f64b2d6b68438e1953341e00ab3cf54de7e35d92bfc73af8555313a" -dependencies = [ - "bytes", - "futures", - "log 0.4.14", + "winapi", ] -[[package]] -name = "tokio-process" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81de38febefe683adab7070c0f705afd6247582d0b1780d9eb745c77a0d4e88b" -dependencies = [ - "futures", - "libc 0.2.54", - "mio", - "mio-named-pipes", - "tokio-io", - "tokio-reactor", - "tokio-signal", - "winapi 0.3.0", -] - -[[package]] -name = "tokio-reactor" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f21d00eb356854d502b81776cec931d12771e4ed6d198478d23ffd38c19279af" -dependencies = [ - "futures", - "log 0.4.14", - "mio", - "slab 0.4.0", - "tokio-executor", - "tokio-io", -] - -[[package]] -name = "tokio-signal" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6a5bf935a0151cc8899aa806ce6a425bdaec79ed4034de1a1e6bfa247e2def" -dependencies = [ - "futures", - "libc 0.2.54", - "mio", - "mio-uds", - "tokio-executor", - "tokio-io", - "tokio-reactor", - "winapi 0.3.0", -] - -[[package]] -name = "winapi" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5350e40d908c7e8b9e5c9edb541ca47cc617c6229d3575a46da6f550f36c96fd" - [[package]] name = "winapi" version = "0.3.0" @@ -369,12 +86,6 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu", ] -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.3.0" @@ -386,13 +97,3 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ca29cb03c8ceaf20f8224a18a530938305e9872b1478ea24ff44b4f503a1d1d" - -[[package]] -name = "ws2_32-sys" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee5f6c385b5f769b6e6104dce4d46dbb582d4bca1e7db77157766381636ee9d8" -dependencies = [ - "winapi 0.2.4", - "winapi-build", -] diff --git a/Cargo.toml b/Cargo.toml index 9e94b53..b4cdcda 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,11 +16,7 @@ rust-version = "1.63" libc = "0.2.50" [dev-dependencies] -futures = "0.1" -num_cpus = "1.0" tempfile = "3" -tokio-core = "0.1" -tokio-process = "0.2" [[test]] name = "client" diff --git a/tests/client.rs b/tests/client.rs index 2516b8c..f10a10c 100644 --- a/tests/client.rs +++ b/tests/client.rs @@ -7,11 +7,7 @@ use std::sync::mpsc; use std::sync::Arc; use std::thread; -use futures::future::{self, Future}; -use futures::stream::{self, Stream}; use jobserver::Client; -use tokio_core::reactor::Core; -use tokio_process::CommandExt; macro_rules! t { ($e:expr) => { @@ -24,9 +20,9 @@ macro_rules! t { struct Test { name: &'static str, - f: &'static dyn Fn(), + f: &'static (dyn Fn() + Send + Sync), make_args: &'static [&'static str], - rule: &'static dyn Fn(&str) -> String, + rule: &'static (dyn Fn(&str) -> String + Send + Sync), } const TESTS: &[Test] = &[ @@ -118,9 +114,7 @@ fn main() { let me = me.to_str().unwrap(); let filter = env::args().nth(1); - let mut core = t!(Core::new()); - - let futures = TESTS + let join_handles = TESTS .iter() .filter(|test| match filter { Some(ref s) => test.name.contains(s), @@ -138,33 +132,33 @@ all: (test.rule)(me) ); t!(t!(File::create(td.path().join("Makefile"))).write_all(makefile.as_bytes())); - let prog = env::var("MAKE").unwrap_or_else(|_| "make".to_string()); - let mut cmd = Command::new(prog); - cmd.args(test.make_args); - cmd.current_dir(td.path()); - future::lazy(move || { - cmd.output_async().map(move |e| { - drop(td); - (test, e) - }) + thread::spawn(move || { + let prog = env::var("MAKE").unwrap_or_else(|_| "make".to_string()); + let mut cmd = Command::new(prog); + cmd.args(test.make_args); + cmd.current_dir(td.path()); + + (test, cmd.output().unwrap()) }) }) .collect::>(); - println!("\nrunning {} tests\n", futures.len()); + println!("\nrunning {} tests\n", join_handles.len()); - let stream = stream::iter(futures.into_iter().map(Ok)).buffer_unordered(num_cpus::get()); + let failures = join_handles + .into_iter() + .filter_map(|join_handle| { + let (test, output) = join_handle.join().unwrap(); - let mut failures = Vec::new(); - t!(core.run(stream.for_each(|(test, output)| { - if output.status.success() { - println!("test {} ... ok", test.name); - } else { - println!("test {} ... FAIL", test.name); - failures.push((test, output)); - } - Ok(()) - }))); + if output.status.success() { + println!("test {} ... ok", test.name); + None + } else { + println!("test {} ... FAIL", test.name); + Some((test, output)) + } + }) + .collect::>(); if failures.is_empty() { println!("\ntest result: ok\n");