From: DongHun Kwak Date: Thu, 4 May 2023 00:16:13 +0000 (+0900) Subject: Add unittest X-Git-Tag: accepted/tizen/rust/20231016.020948^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Faccepted%2Ftizen_rust;p=platform%2Fupstream%2Frust-ciborium-ll.git Add unittest [ 14s] + ./ciborium_ll [ 14s] [ 14s] running 2 tests [ 14s] test tests::node ... ok [ 14s] test tests::leaf ... ok [ 14s] [ 14s] test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s --- diff --git a/packaging/rust-ciborium-ll.spec b/packaging/rust-ciborium-ll.spec index 4fb9a6b..e99ddca 100644 --- a/packaging/rust-ciborium-ll.spec +++ b/packaging/rust-ciborium-ll.spec @@ -30,7 +30,9 @@ Requires: rust-half # ========================================================== # dev-dependencies # ========================================================== -# BuildRequires: rust-hex +%if 0%{?run_tests} +BuildRequires: rust-hex +%endif %description @@ -62,6 +64,21 @@ cp %{SOURCE2} . 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} +%{rustc_std_build} --test --crate-type=dylib \ + --crate-name=%{real_crate_name} \ + %{?rustc_edition:--edition=%{rustc_edition}} \ + %rust_dylib_extern ciborium_io \ + %rust_dylib_extern half \ + %rust_dylib_extern hex \ + --cfg='feature="std"' \ + --cfg='feature="alloc"' \ + ./src/lib.rs + +./%{real_crate_name} +%endif + %clean %post -p /sbin/ldconfig