Add unittest accepted/tizen_rust tizen accepted/tizen/rust/20231016.020937
authorDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 2 May 2023 01:09:51 +0000 (10:09 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 2 May 2023 01:09:51 +0000 (10:09 +0900)
[   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

index 56221cd..5487293 100644 (file)
@@ -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