From 70a6e5ad2458f680b33210073182cdeb98fb77c8 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Fri, 14 Apr 2023 15:09:43 +0900 Subject: [PATCH] Add unittest [ 63s] + ./basic [ 64s] [ 64s] running 11 tests [ 64s] test cancel_and_run ... ok [ 64s] test detach_and_drop ... ok [ 64s] test detach_and_run ... ok [ 64s] test cancel_join ... ok [ 64s] test drop_and_detach ... ok [ 64s] test drop_inside_schedule ... ok [ 64s] test run_and_cancel ... ok [ 64s] test run_and_detach ... ok [ 64s] test schedule ... ok [ 64s] test schedule_counter ... ok [ 64s] test waker ... ok [ 64s] [ 64s] test result: ok. 11 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s [ 64s] [ 64s] + for unit_test in '"basic"' '"cancel"' '"join"' [ 64s] + ./cancel [ 64s] [ 64s] running 3 tests [ 64s] test run_and_cancel ... ok [ 64s] test cancel_during_run ... ok [ 64s] test cancel_and_run ... ok [ 64s] [ 64s] test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.62s [ 64s] [ 64s] + for unit_test in '"basic"' '"cancel"' '"join"' [ 64s] + ./join [ 64s] [ 64s] running 10 tests [ 64s] test detach_and_run ... ok [ 64s] test await_output ... ok [ 64s] test drop_and_join ... ok [ 64s] test join_twice ... ok [ 64s] test run_and_join ... ok [ 64s] test try_join_and_cancel_and_run ... ok [ 65s] test try_join_and_run_and_cancel ... ok [ 65s] test join_and_cancel ... ok [ 65s] test join_and_run ... ok [ 65s] test try_join_and_run_and_join ... ok [ 65s] [ 65s] test result: ok. 10 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.63s --- packaging/rust-async-task.spec | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/packaging/rust-async-task.spec b/packaging/rust-async-task.spec index 44ed162..f014520 100644 --- a/packaging/rust-async-task.spec +++ b/packaging/rust-async-task.spec @@ -25,12 +25,14 @@ BuildRequires: rust # ========================================================== # dev-dependencies # ========================================================== +%if 0%{?run_tests} # BuildRequires: rust-atomic-waker -# BuildRequires: rust-easy-parallel # BuildRequires: rust-flaky_test -# BuildRequires: rust-flume # BuildRequires: rust-once_cell -# BuildRequires: rust-smol +BuildRequires: rust-easy-parallel +BuildRequires: rust-flume +BuildRequires: rust-smol +%endif %description @@ -58,6 +60,27 @@ cp %{SOURCE1} . install -d -m 0755 %{buildroot}%{_rust_dylibdir} install -m 0644 lib%{real_crate_name}.so %{buildroot}/%{_rust_dylibdir}/lib%{real_crate_name}.so +%check +%if 0%{?run_tests} +for unit_test in "basic" "cancel" "join" +do +%{rustc_std_build} --test \ + --crate-name=${unit_test} \ + %{?rustc_edition:--edition=%{rustc_edition}} \ + --cfg='feature="std"' \ + --extern %{real_crate_name}=./lib%{real_crate_name}.so \ + %rust_dylib_extern easy_parallel \ + %rust_dylib_extern flume \ + %rust_dylib_extern smol \ + ./tests/${unit_test}.rs +done + +for unit_test in "basic" "cancel" "join" +do +./${unit_test} +done + +%endif %clean %post -p /sbin/ldconfig -- 2.34.1