From 3ae11b4f730522d34e668ee930502fbcfc1fe052 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Tue, 2 May 2023 10:09:51 +0900 Subject: [PATCH] Add unittest [ 34s] + ./cexpr [ 34s] [ 34s] running 6 tests [ 34s] test int_signed ... FAILED [ 34s] test chars ... FAILED [ 34s] test fail ... FAILED [ 34s] test floats ... FAILED [ 34s] test int_unsigned ... FAILED [ 34s] test strings ... FAILED [ 34s] [ 34s] failures: [ 34s] [ 34s] ---- int_signed stdout ---- [ 34s] thread 'int_signed' panicked at 'Once instance has previously been poisoned', ./tests/clang.rs:317:15 [ 34s] [ 34s] ---- chars stdout ---- [ 34s] thread 'chars' panicked at 'a `libclang` shared library is not loaded on this thread', ./src/lib.rs:1735:1 [ 34s] note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace [ 34s] [ 34s] ---- fail stdout ---- [ 34s] thread 'fail' panicked at 'Once instance has previously been poisoned', ./tests/clang.rs:317:15 [ 34s] [ 34s] ---- floats stdout ---- [ 34s] thread 'floats' panicked at 'Once instance has previously been poisoned', ./tests/clang.rs:317:15 [ 34s] [ 34s] ---- int_unsigned stdout ---- [ 34s] thread 'int_unsigned' panicked at 'Once instance has previously been poisoned', ./tests/clang.rs:317:15 [ 34s] [ 34s] ---- strings stdout ---- [ 34s] thread 'strings' panicked at 'Once instance has previously been poisoned', ./tests/clang.rs:317:15 [ 34s] [ 34s] [ 34s] failures: [ 34s] chars [ 34s] fail [ 34s] floats [ 34s] int_signed [ 34s] int_unsigned [ 34s] strings [ 34s] [ 34s] test result: FAILED. 0 passed; 6 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s --- packaging/rust-cexpr.spec | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/packaging/rust-cexpr.spec b/packaging/rust-cexpr.spec index 56221cd..5487293 100644 --- a/packaging/rust-cexpr.spec +++ b/packaging/rust-cexpr.spec @@ -29,7 +29,9 @@ Requires: rust-nom # ========================================================== # dev-dependencies # ========================================================== -# BuildRequires: rust-clang-sys +%if 0%{?run_tests} +BuildRequires: rust-clang-sys +%endif %description @@ -47,7 +49,7 @@ cp %{SOURCE1} . %{rustc_std_build} --crate-type=dylib \ --crate-name=%{real_crate_name} \ %{?rustc_edition:--edition=%{rustc_edition}} \ - --extern nom=%{_rust_dylibdir}/libnom.so \ + %rust_dylib_extern nom \ ./src/lib.rs # ========================================================== @@ -57,6 +59,20 @@ 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} +# export RUST_BACKTRACE=1 +%{rustc_std_build} --test --crate-type=dylib \ + --crate-name=%{real_crate_name} \ + %{?rustc_edition:--edition=%{rustc_edition}} \ + %rust_dylib_extern nom \ + %rust_dylib_extern clang_sys \ + --extern %{real_crate_name}=./lib%{real_crate_name}.so \ + ./tests/clang.rs + +./%{real_crate_name} +%endif + %clean %post -p /sbin/ldconfig -- 2.7.4