test work
This commit is contained in:
parent
b6c446cd39
commit
9a4ab59ed6
125
Cargo.lock
generated
125
Cargo.lock
generated
@ -561,7 +561,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd4865004a46a0aafb2a0a5eb19d3c9fc46ee5f063a6cfc605c69ac9ecf5263d"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cexpr",
|
||||
"cexpr 0.4.0",
|
||||
"clang-sys",
|
||||
"lazy_static",
|
||||
"lazycell",
|
||||
@ -570,7 +570,30 @@ dependencies = [
|
||||
"quote",
|
||||
"regex",
|
||||
"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]]
|
||||
@ -798,6 +821,15 @@ dependencies = [
|
||||
"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]]
|
||||
name = "cfg-if"
|
||||
version = "0.1.10"
|
||||
@ -918,6 +950,21 @@ dependencies = [
|
||||
"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]]
|
||||
name = "clap"
|
||||
version = "3.2.23"
|
||||
@ -928,9 +975,9 @@ dependencies = [
|
||||
"bitflags",
|
||||
"clap_lex",
|
||||
"indexmap",
|
||||
"strsim",
|
||||
"strsim 0.10.0",
|
||||
"termcolor",
|
||||
"textwrap",
|
||||
"textwrap 0.16.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1140,7 +1187,7 @@ dependencies = [
|
||||
"atty",
|
||||
"cast",
|
||||
"ciborium",
|
||||
"clap",
|
||||
"clap 3.2.23",
|
||||
"criterion-plot",
|
||||
"itertools",
|
||||
"lazy_static",
|
||||
@ -1471,7 +1518,7 @@ dependencies = [
|
||||
"ident_case",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"strsim",
|
||||
"strsim 0.10.0",
|
||||
"syn",
|
||||
]
|
||||
|
||||
@ -1710,8 +1757,11 @@ version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"humantime",
|
||||
"log",
|
||||
"regex",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2135,7 +2185,7 @@ version = "0.9.1+1.38.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9447d1a926beeef466606cc45717f80897998b548e7dc622873d453e1ecb4be4"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"bindgen 0.57.0",
|
||||
"boringssl-src",
|
||||
"cc",
|
||||
"cmake",
|
||||
@ -3478,6 +3528,17 @@ version = "6.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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]]
|
||||
name = "overload"
|
||||
version = "0.1.1"
|
||||
@ -4664,6 +4725,12 @@ version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook"
|
||||
version = "0.3.14"
|
||||
@ -4866,6 +4933,12 @@ dependencies = [
|
||||
"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]]
|
||||
name = "strsim"
|
||||
version = "0.10.0"
|
||||
@ -4957,6 +5030,15 @@ dependencies = [
|
||||
"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]]
|
||||
name = "textwrap"
|
||||
version = "0.16.0"
|
||||
@ -5417,6 +5499,22 @@ dependencies = [
|
||||
"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]]
|
||||
name = "tracing-subscriber"
|
||||
version = "0.3.16"
|
||||
@ -5665,6 +5763,12 @@ version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
||||
|
||||
[[package]]
|
||||
name = "vec_map"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
||||
|
||||
[[package]]
|
||||
name = "veilid-cli"
|
||||
version = "0.1.0"
|
||||
@ -5676,7 +5780,7 @@ dependencies = [
|
||||
"capnp-rpc",
|
||||
"capnpc",
|
||||
"cfg-if 1.0.0",
|
||||
"clap",
|
||||
"clap 3.2.23",
|
||||
"config",
|
||||
"crossbeam-channel",
|
||||
"cursive",
|
||||
@ -5778,6 +5882,7 @@ dependencies = [
|
||||
"tracing",
|
||||
"tracing-android",
|
||||
"tracing-error",
|
||||
"tracing-oslog",
|
||||
"tracing-subscriber",
|
||||
"tracing-wasm",
|
||||
"trust-dns-resolver",
|
||||
@ -5839,7 +5944,7 @@ dependencies = [
|
||||
"capnp-rpc",
|
||||
"capnpc",
|
||||
"cfg-if 1.0.0",
|
||||
"clap",
|
||||
"clap 3.2.23",
|
||||
"color-eyre",
|
||||
"config",
|
||||
"console-subscriber",
|
||||
@ -5900,6 +6005,7 @@ dependencies = [
|
||||
"ndk-glue",
|
||||
"nix 0.26.1",
|
||||
"once_cell",
|
||||
"oslog",
|
||||
"owo-colors",
|
||||
"parking_lot 0.11.2",
|
||||
"rand 0.7.3",
|
||||
@ -5914,6 +6020,7 @@ dependencies = [
|
||||
"tokio-util",
|
||||
"tracing",
|
||||
"tracing-android",
|
||||
"tracing-oslog",
|
||||
"tracing-subscriber",
|
||||
"tracing-wasm",
|
||||
"wasm-bindgen",
|
||||
|
@ -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-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_ios_tests = [ "simplelog" ]
|
||||
veilid_core_android_tests = [ "dep:tracing-android" ]
|
||||
veilid_core_ios_tests = [ "dep:tracing-oslog" ]
|
||||
tracking = []
|
||||
|
||||
[dependencies]
|
||||
@ -130,7 +130,7 @@ jni = "^0"
|
||||
jni-sys = "^0"
|
||||
ndk = { version = "^0.7" }
|
||||
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)
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
@ -148,7 +148,7 @@ windows-permissions = "^0"
|
||||
|
||||
# Dependencies for iOS
|
||||
[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
|
||||
# Except WASM which doesn't use sqlite
|
||||
|
@ -16,7 +16,9 @@ pub extern "system" fn Java_com_veilid_veilid_1core_1android_1tests_MainActivity
|
||||
ctx: JObject,
|
||||
) {
|
||||
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) {
|
||||
|
@ -22,7 +22,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
run_tests(this.context);
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,7 +30,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
this.testThread = new TestThread(this);
|
||||
this.testThread.start();
|
||||
run_tests(this.context);
|
||||
}
|
||||
}
|
||||
|
@ -7,15 +7,20 @@ use tracing_subscriber::{fmt, prelude::*};
|
||||
#[no_mangle]
|
||||
#[allow(dead_code)]
|
||||
pub extern "C" fn run_veilid_core_tests() {
|
||||
veilid_core_setup_ios_tests();
|
||||
run_all_tests();
|
||||
std::thread::spawn(|| {
|
||||
block_on(async {
|
||||
veilid_core_setup_ios_tests();
|
||||
run_all_tests().await;
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
pub fn veilid_core_setup_ios_tests() {
|
||||
// Set up subscriber and layers
|
||||
let filter = VeilidLayerFilter::new(VeilidConfigLogLevel::Trace, None);
|
||||
let fmt_layer = fmt::layer().with_filter(filter);
|
||||
tracing_subscriber::registry().with(fmt_layer).init();
|
||||
tracing_subscriber::registry()
|
||||
.with(OsLogger::new("com.veilid.veilidtools-tests", "default").with_filter(filter))
|
||||
.init();
|
||||
|
||||
panic::set_hook(Box::new(|panic_info| {
|
||||
let bt = Backtrace::new();
|
||||
|
@ -8,84 +8,40 @@ use crate::*;
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn run_all_tests() {
|
||||
info!("TEST: exec_test_host_interface");
|
||||
exec_test_host_interface();
|
||||
info!("TEST: exec_test_dht_key");
|
||||
exec_test_dht_key();
|
||||
info!("TEST: exec_test_veilid_core");
|
||||
exec_test_veilid_core();
|
||||
info!("TEST: exec_test_veilid_config");
|
||||
exec_test_veilid_config();
|
||||
info!("TEST: exec_test_connection_table");
|
||||
exec_test_connection_table();
|
||||
info!("TEST: exec_test_table_store");
|
||||
exec_test_table_store();
|
||||
info!("TEST: exec_test_protected_store");
|
||||
exec_test_protected_store();
|
||||
info!("TEST: exec_test_crypto");
|
||||
exec_test_crypto();
|
||||
info!("TEST: exec_test_envelope_receipt");
|
||||
exec_test_envelope_receipt();
|
||||
pub async fn run_all_tests() {
|
||||
info!("TEST: test_host_interface");
|
||||
test_host_interface::test_all().await;
|
||||
info!("TEST: test_dht_key");
|
||||
test_dht_key::test_all().await;
|
||||
info!("TEST: test_veilid_core");
|
||||
test_veilid_core::test_all().await;
|
||||
info!("TEST: test_veilid_config");
|
||||
test_veilid_config::test_all().await;
|
||||
info!("TEST: test_connection_table");
|
||||
test_connection_table::test_all().await;
|
||||
info!("TEST: test_table_store");
|
||||
test_table_store::test_all().await;
|
||||
info!("TEST: test_protected_store");
|
||||
test_protected_store::test_all().await;
|
||||
info!("TEST: test_crypto");
|
||||
test_crypto::test_all().await;
|
||||
info!("TEST: test_envelope_receipt");
|
||||
test_envelope_receipt::test_all().await;
|
||||
|
||||
info!("Finished unit tests");
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[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 local = tokio::task::LocalSet::new();
|
||||
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)
|
||||
rt.block_on(f)
|
||||
}
|
||||
|
||||
fn exec_test_host_interface() {
|
||||
block_on(async {
|
||||
test_host_interface::test_all().await;
|
||||
});
|
||||
}
|
||||
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;
|
||||
})
|
||||
#[cfg(feature = "rt-async-std")]
|
||||
#[allow(dead_code)]
|
||||
pub fn block_on<F: Future<Output = T>, T>(f: F) -> T {
|
||||
async_std::task::block_on(f)
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -119,63 +75,81 @@ cfg_if! {
|
||||
#[serial]
|
||||
fn run_test_host_interface() {
|
||||
setup();
|
||||
exec_test_host_interface();
|
||||
block_on(async {
|
||||
test_host_interface::test_all().await;
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn run_test_dht_key() {
|
||||
setup();
|
||||
exec_test_dht_key();
|
||||
block_on(async {
|
||||
test_dht_key::test_all().await;
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn run_test_veilid_core() {
|
||||
setup();
|
||||
exec_test_veilid_core();
|
||||
block_on(async {
|
||||
test_veilid_core::test_all().await;
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn run_test_veilid_config() {
|
||||
setup();
|
||||
exec_test_veilid_config();
|
||||
block_on(async {
|
||||
test_veilid_config::test_all().await;
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn run_test_connection_table() {
|
||||
setup();
|
||||
exec_test_connection_table();
|
||||
block_on(async {
|
||||
test_connection_table::test_all().await;
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn run_test_table_store() {
|
||||
setup();
|
||||
exec_test_table_store();
|
||||
block_on(async {
|
||||
test_table_store::test_all().await;
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn run_test_protected_store() {
|
||||
setup();
|
||||
exec_test_protected_store();
|
||||
block_on(async {
|
||||
test_protected_store::test_all().await;
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn run_test_crypto() {
|
||||
setup();
|
||||
exec_test_crypto();
|
||||
block_on(async {
|
||||
test_crypto::test_all().await;
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn run_test_envelope_receipt() {
|
||||
setup();
|
||||
exec_test_envelope_receipt();
|
||||
block_on(async {
|
||||
test_envelope_receipt::test_all().await;
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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", ]
|
||||
|
||||
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" ]
|
||||
|
||||
[dependencies]
|
||||
@ -72,7 +72,8 @@ android-logd-logger = "0.2.1"
|
||||
|
||||
# Dependencies for iOS
|
||||
[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
|
||||
|
||||
|
@ -15,8 +15,10 @@ pub extern "system" fn Java_com_veilid_veilid_1tools_1android_1tests_MainActivit
|
||||
_class: JClass,
|
||||
_ctx: JObject,
|
||||
) {
|
||||
crate::tests::android::veilid_tools_setup_android_tests();
|
||||
run_all_tests();
|
||||
veilid_tools_setup_android_tests();
|
||||
block_on(async {
|
||||
run_all_tests().await;
|
||||
})
|
||||
}
|
||||
|
||||
pub fn veilid_tools_setup_android_tests() {
|
||||
|
@ -6,38 +6,55 @@ use std::panic;
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn run_veilid_tools_tests() {
|
||||
crate::tests::ios::veilid_tools_setup_ios_tests();
|
||||
run_all_tests();
|
||||
veilid_tools_setup_ios_tests();
|
||||
block_on(async {
|
||||
run_all_tests().await;
|
||||
})
|
||||
}
|
||||
|
||||
pub fn veilid_tools_setup_ios_tests() {
|
||||
cfg_if! {
|
||||
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();
|
||||
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)
|
||||
.with(OsLogger::new("com.veilid.veilidtools-tests", "default"))
|
||||
.init();
|
||||
} else {
|
||||
use simplelog::*;
|
||||
let mut logs: Vec<Box<dyn SharedLogger>> = Vec::new();
|
||||
let mut cb = ConfigBuilder::new();
|
||||
for ig in DEFAULT_LOG_IGNORE_LIST {
|
||||
cb.add_filter_ignore_str(ig);
|
||||
}
|
||||
logs.push(TermLogger::new(
|
||||
LevelFilter::Trace,
|
||||
cb.build(),
|
||||
TerminalMode::Mixed,
|
||||
ColorChoice::Auto,
|
||||
));
|
||||
CombinedLogger::init(logs).expect("logger init error");
|
||||
// use simplelog::*;
|
||||
// let mut logs: Vec<Box<dyn SharedLogger>> = Vec::new();
|
||||
// let mut cb = ConfigBuilder::new();
|
||||
// for ig in DEFAULT_LOG_IGNORE_LIST {
|
||||
// cb.add_filter_ignore_str(ig);
|
||||
// }
|
||||
// logs.push(TermLogger::new(
|
||||
// LevelFilter::Trace,
|
||||
// cb.build(),
|
||||
// TerminalMode::Mixed,
|
||||
// ColorChoice::Auto,
|
||||
// ));
|
||||
// CombinedLogger::init(logs).expect("logger init error");
|
||||
|
||||
OsLogger::new("com.veilid.veilidtools-tests", "default")
|
||||
.level_filter(LevelFilter::Trace)
|
||||
.init()
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,42 +9,28 @@ use super::*;
|
||||
// Allow access to tests from non cfg(test), as required for android and ios tests
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn run_all_tests() {
|
||||
pub async fn run_all_tests() {
|
||||
info!("TEST: exec_test_host_interface");
|
||||
exec_test_host_interface();
|
||||
test_host_interface::test_all().await;
|
||||
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");
|
||||
exec_test_async_tag_lock();
|
||||
test_async_tag_lock::test_all().await;
|
||||
|
||||
info!("Finished unit tests");
|
||||
}
|
||||
|
||||
#[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 local = tokio::task::LocalSet::new();
|
||||
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)
|
||||
rt.block_on(f)
|
||||
}
|
||||
|
||||
fn exec_test_host_interface() {
|
||||
block_on(async {
|
||||
test_host_interface::test_all().await;
|
||||
});
|
||||
}
|
||||
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;
|
||||
})
|
||||
#[cfg(feature = "rt-async-std")]
|
||||
#[allow(dead_code)]
|
||||
pub fn block_on<F: Future<Output = T>, T>(f: F) -> T {
|
||||
async_std::task::block_on(f)
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -88,21 +74,27 @@ cfg_if! {
|
||||
#[serial]
|
||||
fn run_test_host_interface() {
|
||||
setup();
|
||||
exec_test_host_interface();
|
||||
block_on(async {
|
||||
test_host_interface::test_all().await;
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn run_test_async_peek_stream() {
|
||||
setup();
|
||||
exec_test_async_peek_stream();
|
||||
block_on(async {
|
||||
test_async_peek_stream::test_all().await;
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn run_test_async_tag_lock() {
|
||||
setup();
|
||||
exec_test_async_tag_lock();
|
||||
block_on(async {
|
||||
test_async_tag_lock::test_all().await;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user