# ==========================================================
# dev-dependencies
# ==========================================================
-# BuildRequires: rust-similar-asserts
+%if 0%{?run_tests}
+BuildRequires: rust-similar-asserts
+%endif
%description
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 unit_test_list="eval lexer parser"
+for unit_test in ${unit_test_list}
+do
+%{rustc_std_build} --test --crate-type=dylib \
+ --crate-name=${unit_test} \
+ %{?rustc_edition:--edition=%{rustc_edition}} \
+ %rust_dylib_extern smallvec \
+ %rust_dylib_extern similar_asserts \
+ --extern %{real_crate_name}=./lib%{real_crate_name}.so \
+ ./tests/${unit_test}.rs
+done
+
+for unit_test in ${unit_test_list}
+do
+./${unit_test}
+done
+%endif
+
%clean
%post -p /sbin/ldconfig