test work

This commit is contained in:
John Smith 2022-12-01 10:46:52 -05:00
parent b6c446cd39
commit 9a4ab59ed6
10 changed files with 248 additions and 150 deletions

125
Cargo.lock generated
View File

@ -561,7 +561,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd4865004a46a0aafb2a0a5eb19d3c9fc46ee5f063a6cfc605c69ac9ecf5263d" checksum = "fd4865004a46a0aafb2a0a5eb19d3c9fc46ee5f063a6cfc605c69ac9ecf5263d"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cexpr", "cexpr 0.4.0",
"clang-sys", "clang-sys",
"lazy_static", "lazy_static",
"lazycell", "lazycell",
@ -570,7 +570,30 @@ dependencies = [
"quote", "quote",
"regex", "regex",
"rustc-hash", "rustc-hash",
"shlex", "shlex 0.1.1",
]
[[package]]
name = "bindgen"
version = "0.59.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8"
dependencies = [
"bitflags",
"cexpr 0.6.0",
"clang-sys",
"clap 2.34.0",
"env_logger 0.9.3",
"lazy_static",
"lazycell",
"log",
"peeking_take_while",
"proc-macro2",
"quote",
"regex",
"rustc-hash",
"shlex 1.1.0",
"which",
] ]
[[package]] [[package]]
@ -798,6 +821,15 @@ dependencies = [
"nom 5.1.2", "nom 5.1.2",
] ]
[[package]]
name = "cexpr"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
dependencies = [
"nom 7.1.1",
]
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
version = "0.1.10" version = "0.1.10"
@ -918,6 +950,21 @@ dependencies = [
"libloading", "libloading",
] ]
[[package]]
name = "clap"
version = "2.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
dependencies = [
"ansi_term",
"atty",
"bitflags",
"strsim 0.8.0",
"textwrap 0.11.0",
"unicode-width",
"vec_map",
]
[[package]] [[package]]
name = "clap" name = "clap"
version = "3.2.23" version = "3.2.23"
@ -928,9 +975,9 @@ dependencies = [
"bitflags", "bitflags",
"clap_lex", "clap_lex",
"indexmap", "indexmap",
"strsim", "strsim 0.10.0",
"termcolor", "termcolor",
"textwrap", "textwrap 0.16.0",
] ]
[[package]] [[package]]
@ -1140,7 +1187,7 @@ dependencies = [
"atty", "atty",
"cast", "cast",
"ciborium", "ciborium",
"clap", "clap 3.2.23",
"criterion-plot", "criterion-plot",
"itertools", "itertools",
"lazy_static", "lazy_static",
@ -1471,7 +1518,7 @@ dependencies = [
"ident_case", "ident_case",
"proc-macro2", "proc-macro2",
"quote", "quote",
"strsim", "strsim 0.10.0",
"syn", "syn",
] ]
@ -1710,8 +1757,11 @@ version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7"
dependencies = [ dependencies = [
"atty",
"humantime",
"log", "log",
"regex", "regex",
"termcolor",
] ]
[[package]] [[package]]
@ -2135,7 +2185,7 @@ version = "0.9.1+1.38.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9447d1a926beeef466606cc45717f80897998b548e7dc622873d453e1ecb4be4" checksum = "9447d1a926beeef466606cc45717f80897998b548e7dc622873d453e1ecb4be4"
dependencies = [ dependencies = [
"bindgen", "bindgen 0.57.0",
"boringssl-src", "boringssl-src",
"cc", "cc",
"cmake", "cmake",
@ -3478,6 +3528,17 @@ version = "6.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee"
[[package]]
name = "oslog"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80d2043d1f61d77cb2f4b1f7b7b2295f40507f5f8e9d1c8bf10a1ca5f97a3969"
dependencies = [
"cc",
"dashmap",
"log",
]
[[package]] [[package]]
name = "overload" name = "overload"
version = "0.1.1" version = "0.1.1"
@ -4664,6 +4725,12 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
[[package]]
name = "shlex"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
[[package]] [[package]]
name = "signal-hook" name = "signal-hook"
version = "0.3.14" version = "0.3.14"
@ -4866,6 +4933,12 @@ dependencies = [
"pin-project-lite 0.2.9", "pin-project-lite 0.2.9",
] ]
[[package]]
name = "strsim"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]] [[package]]
name = "strsim" name = "strsim"
version = "0.10.0" version = "0.10.0"
@ -4957,6 +5030,15 @@ dependencies = [
"winapi-util", "winapi-util",
] ]
[[package]]
name = "textwrap"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
dependencies = [
"unicode-width",
]
[[package]] [[package]]
name = "textwrap" name = "textwrap"
version = "0.16.0" version = "0.16.0"
@ -5417,6 +5499,22 @@ dependencies = [
"tracing-subscriber", "tracing-subscriber",
] ]
[[package]]
name = "tracing-oslog"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9bc58223383423483e4bc056c7e7b3f77bdee924a9d33834112c69ead06dc847"
dependencies = [
"bindgen 0.59.2",
"cc",
"cfg-if 1.0.0",
"fnv",
"once_cell",
"parking_lot 0.11.2",
"tracing-core",
"tracing-subscriber",
]
[[package]] [[package]]
name = "tracing-subscriber" name = "tracing-subscriber"
version = "0.3.16" version = "0.3.16"
@ -5665,6 +5763,12 @@ version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "vec_map"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]] [[package]]
name = "veilid-cli" name = "veilid-cli"
version = "0.1.0" version = "0.1.0"
@ -5676,7 +5780,7 @@ dependencies = [
"capnp-rpc", "capnp-rpc",
"capnpc", "capnpc",
"cfg-if 1.0.0", "cfg-if 1.0.0",
"clap", "clap 3.2.23",
"config", "config",
"crossbeam-channel", "crossbeam-channel",
"cursive", "cursive",
@ -5778,6 +5882,7 @@ dependencies = [
"tracing", "tracing",
"tracing-android", "tracing-android",
"tracing-error", "tracing-error",
"tracing-oslog",
"tracing-subscriber", "tracing-subscriber",
"tracing-wasm", "tracing-wasm",
"trust-dns-resolver", "trust-dns-resolver",
@ -5839,7 +5944,7 @@ dependencies = [
"capnp-rpc", "capnp-rpc",
"capnpc", "capnpc",
"cfg-if 1.0.0", "cfg-if 1.0.0",
"clap", "clap 3.2.23",
"color-eyre", "color-eyre",
"config", "config",
"console-subscriber", "console-subscriber",
@ -5900,6 +6005,7 @@ dependencies = [
"ndk-glue", "ndk-glue",
"nix 0.26.1", "nix 0.26.1",
"once_cell", "once_cell",
"oslog",
"owo-colors", "owo-colors",
"parking_lot 0.11.2", "parking_lot 0.11.2",
"rand 0.7.3", "rand 0.7.3",
@ -5914,6 +6020,7 @@ dependencies = [
"tokio-util", "tokio-util",
"tracing", "tracing",
"tracing-android", "tracing-android",
"tracing-oslog",
"tracing-subscriber", "tracing-subscriber",
"tracing-wasm", "tracing-wasm",
"wasm-bindgen", "wasm-bindgen",

View File

@ -14,8 +14,8 @@ default = []
rt-async-std = [ "async-std", "async-std-resolver", "async_executors/async_std", "rtnetlink?/smol_socket", "veilid-tools/rt-async-std" ] rt-async-std = [ "async-std", "async-std-resolver", "async_executors/async_std", "rtnetlink?/smol_socket", "veilid-tools/rt-async-std" ]
rt-tokio = [ "tokio", "tokio-util", "tokio-stream", "trust-dns-resolver/tokio-runtime", "async_executors/tokio_tp", "async_executors/tokio_io", "async_executors/tokio_timer", "rtnetlink?/tokio_socket", "veilid-tools/rt-tokio" ] rt-tokio = [ "tokio", "tokio-util", "tokio-stream", "trust-dns-resolver/tokio-runtime", "async_executors/tokio_tp", "async_executors/tokio_io", "async_executors/tokio_timer", "rtnetlink?/tokio_socket", "veilid-tools/rt-tokio" ]
veilid_core_android_tests = [] veilid_core_android_tests = [ "dep:tracing-android" ]
veilid_core_ios_tests = [ "simplelog" ] veilid_core_ios_tests = [ "dep:tracing-oslog" ]
tracking = [] tracking = []
[dependencies] [dependencies]
@ -130,7 +130,7 @@ jni = "^0"
jni-sys = "^0" jni-sys = "^0"
ndk = { version = "^0.7" } ndk = { version = "^0.7" }
ndk-glue = { version = "^0.7", features = ["logger"] } ndk-glue = { version = "^0.7", features = ["logger"] }
tracing-android = { version = "^0" } tracing-android = { version = "^0", optional = true }
# Dependenices for all Unix (Linux, Android, MacOS, iOS) # Dependenices for all Unix (Linux, Android, MacOS, iOS)
[target.'cfg(unix)'.dependencies] [target.'cfg(unix)'.dependencies]
@ -148,7 +148,7 @@ windows-permissions = "^0"
# Dependencies for iOS # Dependencies for iOS
[target.'cfg(target_os = "ios")'.dependencies] [target.'cfg(target_os = "ios")'.dependencies]
simplelog = { version = "^0", optional = true } tracing-oslog = { version = "^0", optional = true }
# Rusqlite configuration to ensure platforms that don't come with sqlite get it bundled # Rusqlite configuration to ensure platforms that don't come with sqlite get it bundled
# Except WASM which doesn't use sqlite # Except WASM which doesn't use sqlite

View File

@ -16,7 +16,9 @@ pub extern "system" fn Java_com_veilid_veilid_1core_1android_1tests_MainActivity
ctx: JObject, ctx: JObject,
) { ) {
crate::intf::utils::android::veilid_core_setup_android_tests(env, ctx); crate::intf::utils::android::veilid_core_setup_android_tests(env, ctx);
run_all_tests(); block_on(async {
run_all_tests().await;
})
} }
pub fn veilid_core_setup_android_tests(env: JNIEnv, ctx: JObject) { pub fn veilid_core_setup_android_tests(env: JNIEnv, ctx: JObject) {

View File

@ -22,7 +22,6 @@ public class MainActivity extends AppCompatActivity {
} }
public void run() { public void run() {
run_tests(this.context);
} }
} }
@ -31,7 +30,6 @@ public class MainActivity extends AppCompatActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
this.testThread = new TestThread(this); run_tests(this.context);
this.testThread.start();
} }
} }

View File

@ -7,15 +7,20 @@ use tracing_subscriber::{fmt, prelude::*};
#[no_mangle] #[no_mangle]
#[allow(dead_code)] #[allow(dead_code)]
pub extern "C" fn run_veilid_core_tests() { pub extern "C" fn run_veilid_core_tests() {
std::thread::spawn(|| {
block_on(async {
veilid_core_setup_ios_tests(); veilid_core_setup_ios_tests();
run_all_tests(); run_all_tests().await;
})
});
} }
pub fn veilid_core_setup_ios_tests() { pub fn veilid_core_setup_ios_tests() {
// Set up subscriber and layers // Set up subscriber and layers
let filter = VeilidLayerFilter::new(VeilidConfigLogLevel::Trace, None); let filter = VeilidLayerFilter::new(VeilidConfigLogLevel::Trace, None);
let fmt_layer = fmt::layer().with_filter(filter); tracing_subscriber::registry()
tracing_subscriber::registry().with(fmt_layer).init(); .with(OsLogger::new("com.veilid.veilidtools-tests", "default").with_filter(filter))
.init();
panic::set_hook(Box::new(|panic_info| { panic::set_hook(Box::new(|panic_info| {
let bt = Backtrace::new(); let bt = Backtrace::new();

View File

@ -8,84 +8,40 @@ use crate::*;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#[allow(dead_code)] #[allow(dead_code)]
pub fn run_all_tests() { pub async fn run_all_tests() {
info!("TEST: exec_test_host_interface"); info!("TEST: test_host_interface");
exec_test_host_interface(); test_host_interface::test_all().await;
info!("TEST: exec_test_dht_key"); info!("TEST: test_dht_key");
exec_test_dht_key(); test_dht_key::test_all().await;
info!("TEST: exec_test_veilid_core"); info!("TEST: test_veilid_core");
exec_test_veilid_core(); test_veilid_core::test_all().await;
info!("TEST: exec_test_veilid_config"); info!("TEST: test_veilid_config");
exec_test_veilid_config(); test_veilid_config::test_all().await;
info!("TEST: exec_test_connection_table"); info!("TEST: test_connection_table");
exec_test_connection_table(); test_connection_table::test_all().await;
info!("TEST: exec_test_table_store"); info!("TEST: test_table_store");
exec_test_table_store(); test_table_store::test_all().await;
info!("TEST: exec_test_protected_store"); info!("TEST: test_protected_store");
exec_test_protected_store(); test_protected_store::test_all().await;
info!("TEST: exec_test_crypto"); info!("TEST: test_crypto");
exec_test_crypto(); test_crypto::test_all().await;
info!("TEST: exec_test_envelope_receipt"); info!("TEST: test_envelope_receipt");
exec_test_envelope_receipt(); test_envelope_receipt::test_all().await;
info!("Finished unit tests"); info!("Finished unit tests");
} }
#[allow(dead_code)]
#[cfg(feature = "rt-tokio")] #[cfg(feature = "rt-tokio")]
fn block_on<F: Future<Output = T>, T>(f: F) -> T { pub fn block_on<F: Future<Output = T>, T>(f: F) -> T {
let rt = tokio::runtime::Runtime::new().unwrap(); let rt = tokio::runtime::Runtime::new().unwrap();
let local = tokio::task::LocalSet::new(); rt.block_on(f)
local.block_on(&rt, f)
}
#[cfg(feature = "rt-async-std")]
fn block_on<F: Future<Output = T>, T>(f: F) -> T {
async_std::task::block_on(f)
} }
fn exec_test_host_interface() { #[cfg(feature = "rt-async-std")]
block_on(async { #[allow(dead_code)]
test_host_interface::test_all().await; pub fn block_on<F: Future<Output = T>, T>(f: F) -> T {
}); async_std::task::block_on(f)
}
fn exec_test_dht_key() {
block_on(async {
test_dht_key::test_all().await;
});
}
fn exec_test_veilid_core() {
block_on(async {
test_veilid_core::test_all().await;
});
}
fn exec_test_veilid_config() {
block_on(async {
test_veilid_config::test_all().await;
})
}
fn exec_test_connection_table() {
block_on(async {
test_connection_table::test_all().await;
})
}
fn exec_test_table_store() {
block_on(async {
test_table_store::test_all().await;
})
}
fn exec_test_protected_store() {
block_on(async {
test_protected_store::test_all().await;
})
}
fn exec_test_crypto() {
block_on(async {
test_crypto::test_all().await;
})
}
fn exec_test_envelope_receipt() {
block_on(async {
test_envelope_receipt::test_all().await;
})
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -119,63 +75,81 @@ cfg_if! {
#[serial] #[serial]
fn run_test_host_interface() { fn run_test_host_interface() {
setup(); setup();
exec_test_host_interface(); block_on(async {
test_host_interface::test_all().await;
});
} }
#[test] #[test]
#[serial] #[serial]
fn run_test_dht_key() { fn run_test_dht_key() {
setup(); setup();
exec_test_dht_key(); block_on(async {
test_dht_key::test_all().await;
});
} }
#[test] #[test]
#[serial] #[serial]
fn run_test_veilid_core() { fn run_test_veilid_core() {
setup(); setup();
exec_test_veilid_core(); block_on(async {
test_veilid_core::test_all().await;
});
} }
#[test] #[test]
#[serial] #[serial]
fn run_test_veilid_config() { fn run_test_veilid_config() {
setup(); setup();
exec_test_veilid_config(); block_on(async {
test_veilid_config::test_all().await;
})
} }
#[test] #[test]
#[serial] #[serial]
fn run_test_connection_table() { fn run_test_connection_table() {
setup(); setup();
exec_test_connection_table(); block_on(async {
test_connection_table::test_all().await;
})
} }
#[test] #[test]
#[serial] #[serial]
fn run_test_table_store() { fn run_test_table_store() {
setup(); setup();
exec_test_table_store(); block_on(async {
test_table_store::test_all().await;
})
} }
#[test] #[test]
#[serial] #[serial]
fn run_test_protected_store() { fn run_test_protected_store() {
setup(); setup();
exec_test_protected_store(); block_on(async {
test_protected_store::test_all().await;
})
} }
#[test] #[test]
#[serial] #[serial]
fn run_test_crypto() { fn run_test_crypto() {
setup(); setup();
exec_test_crypto(); block_on(async {
test_crypto::test_all().await;
})
} }
#[test] #[test]
#[serial] #[serial]
fn run_test_envelope_receipt() { fn run_test_envelope_receipt() {
setup(); setup();
exec_test_envelope_receipt(); block_on(async {
test_envelope_receipt::test_all().await;
})
} }
} }

View File

@ -15,7 +15,7 @@ rt-async-std = [ "async-std", "async_executors/async_std", ]
rt-tokio = [ "tokio", "tokio-util", "async_executors/tokio_tp", "async_executors/tokio_io", "async_executors/tokio_timer", ] rt-tokio = [ "tokio", "tokio-util", "async_executors/tokio_tp", "async_executors/tokio_io", "async_executors/tokio_timer", ]
veilid_tools_android_tests = [ "dep:tracing-android" ] veilid_tools_android_tests = [ "dep:tracing-android" ]
veilid_tools_ios_tests = [] veilid_tools_ios_tests = [ "dep:oslog", "dep:tracing-oslog" ]
tracing = [ "dep:tracing", "dep:tracing-subscriber" ] tracing = [ "dep:tracing", "dep:tracing-subscriber" ]
[dependencies] [dependencies]
@ -72,7 +72,8 @@ android-logd-logger = "0.2.1"
# Dependencies for iOS # Dependencies for iOS
[target.'cfg(target_os = "ios")'.dependencies] [target.'cfg(target_os = "ios")'.dependencies]
simplelog = { version = "^0.12", features = [ "test" ] } oslog = { version = "^0", optional = true }
tracing-oslog = { version = "^0", optional = true }
### DEV DEPENDENCIES ### DEV DEPENDENCIES

View File

@ -15,8 +15,10 @@ pub extern "system" fn Java_com_veilid_veilid_1tools_1android_1tests_MainActivit
_class: JClass, _class: JClass,
_ctx: JObject, _ctx: JObject,
) { ) {
crate::tests::android::veilid_tools_setup_android_tests(); veilid_tools_setup_android_tests();
run_all_tests(); block_on(async {
run_all_tests().await;
})
} }
pub fn veilid_tools_setup_android_tests() { pub fn veilid_tools_setup_android_tests() {

View File

@ -6,38 +6,55 @@ use std::panic;
#[no_mangle] #[no_mangle]
pub extern "C" fn run_veilid_tools_tests() { pub extern "C" fn run_veilid_tools_tests() {
crate::tests::ios::veilid_tools_setup_ios_tests(); veilid_tools_setup_ios_tests();
run_all_tests(); block_on(async {
run_all_tests().await;
})
} }
pub fn veilid_tools_setup_ios_tests() { pub fn veilid_tools_setup_ios_tests() {
cfg_if! { cfg_if! {
if #[cfg(feature = "tracing")] { if #[cfg(feature = "tracing")] {
use tracing_subscriber::{filter, fmt, prelude::*}; // use tracing_subscriber::{filter, fmt, prelude::*};
// let mut filters = filter::Targets::new();
// for ig in DEFAULT_LOG_IGNORE_LIST {
// filters = filters.with_target(ig, filter::LevelFilter::OFF);
// }
// let fmt_layer = fmt::layer();
// tracing_subscriber::registry()
// .with(filters)
// .with(filter::LevelFilter::TRACE)
// .with(fmt_layer)
// .init();
let mut filters = filter::Targets::new(); let mut filters = filter::Targets::new();
for ig in DEFAULT_LOG_IGNORE_LIST { for ig in DEFAULT_LOG_IGNORE_LIST {
filters = filters.with_target(ig, filter::LevelFilter::OFF); filters = filters.with_target(ig, filter::LevelFilter::OFF);
} }
let fmt_layer = fmt::layer();
tracing_subscriber::registry() tracing_subscriber::registry()
.with(filters) .with(filters)
.with(filter::LevelFilter::TRACE) .with(filter::LevelFilter::TRACE)
.with(fmt_layer) .with(OsLogger::new("com.veilid.veilidtools-tests", "default"))
.init(); .init();
} else { } else {
use simplelog::*; // use simplelog::*;
let mut logs: Vec<Box<dyn SharedLogger>> = Vec::new(); // let mut logs: Vec<Box<dyn SharedLogger>> = Vec::new();
let mut cb = ConfigBuilder::new(); // let mut cb = ConfigBuilder::new();
for ig in DEFAULT_LOG_IGNORE_LIST { // for ig in DEFAULT_LOG_IGNORE_LIST {
cb.add_filter_ignore_str(ig); // cb.add_filter_ignore_str(ig);
} // }
logs.push(TermLogger::new( // logs.push(TermLogger::new(
LevelFilter::Trace, // LevelFilter::Trace,
cb.build(), // cb.build(),
TerminalMode::Mixed, // TerminalMode::Mixed,
ColorChoice::Auto, // ColorChoice::Auto,
)); // ));
CombinedLogger::init(logs).expect("logger init error"); // CombinedLogger::init(logs).expect("logger init error");
OsLogger::new("com.veilid.veilidtools-tests", "default")
.level_filter(LevelFilter::Trace)
.init()
.unwrap();
} }
} }

View File

@ -9,42 +9,28 @@ use super::*;
// Allow access to tests from non cfg(test), as required for android and ios tests // Allow access to tests from non cfg(test), as required for android and ios tests
#[allow(dead_code)] #[allow(dead_code)]
pub fn run_all_tests() { pub async fn run_all_tests() {
info!("TEST: exec_test_host_interface"); info!("TEST: exec_test_host_interface");
exec_test_host_interface(); test_host_interface::test_all().await;
info!("TEST: exec_test_async_peek_stream"); info!("TEST: exec_test_async_peek_stream");
exec_test_async_peek_stream(); test_async_peek_stream::test_all().await;
info!("TEST: exec_test_async_tag_lock"); info!("TEST: exec_test_async_tag_lock");
exec_test_async_tag_lock(); test_async_tag_lock::test_all().await;
info!("Finished unit tests"); info!("Finished unit tests");
} }
#[cfg(feature = "rt-tokio")] #[cfg(feature = "rt-tokio")]
fn block_on<F: Future<Output = T>, T>(f: F) -> T { #[allow(dead_code)]
pub fn block_on<F: Future<Output = T>, T>(f: F) -> T {
let rt = tokio::runtime::Runtime::new().unwrap(); let rt = tokio::runtime::Runtime::new().unwrap();
let local = tokio::task::LocalSet::new(); rt.block_on(f)
local.block_on(&rt, f)
}
#[cfg(feature = "rt-async-std")]
fn block_on<F: Future<Output = T>, T>(f: F) -> T {
async_std::task::block_on(f)
} }
fn exec_test_host_interface() { #[cfg(feature = "rt-async-std")]
block_on(async { #[allow(dead_code)]
test_host_interface::test_all().await; pub fn block_on<F: Future<Output = T>, T>(f: F) -> T {
}); async_std::task::block_on(f)
}
fn exec_test_async_peek_stream() {
block_on(async {
test_async_peek_stream::test_all().await;
})
}
fn exec_test_async_tag_lock() {
block_on(async {
test_async_tag_lock::test_all().await;
})
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -88,21 +74,27 @@ cfg_if! {
#[serial] #[serial]
fn run_test_host_interface() { fn run_test_host_interface() {
setup(); setup();
exec_test_host_interface(); block_on(async {
test_host_interface::test_all().await;
});
} }
#[test] #[test]
#[serial] #[serial]
fn run_test_async_peek_stream() { fn run_test_async_peek_stream() {
setup(); setup();
exec_test_async_peek_stream(); block_on(async {
test_async_peek_stream::test_all().await;
});
} }
#[test] #[test]
#[serial] #[serial]
fn run_test_async_tag_lock() { fn run_test_async_tag_lock() {
setup(); setup();
exec_test_async_tag_lock(); block_on(async {
test_async_tag_lock::test_all().await;
});
} }
} }
} }