From 88620bd9def589d469e89d4180cdefcf5eaaf658 Mon Sep 17 00:00:00 2001 From: Woohyun Jung Date: Thu, 4 May 2023 14:40:17 +0900 Subject: [PATCH] Add unittest [ 23s] + ./compiletest [ 23s] [ 23s] running 1 test [ 23s] test ui ... ignored [ 23s] [ 23s] test result: ok. 0 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.00s [ 23s] [ 23s] + for unit_test in '${unit_test_list}' [ 23s] + ./test [ 23s] [ 23s] running 37 tests [ 23s] test test_append_tokens ... ok [ 23s] test test_advanced ... ok [ 23s] test test_box_str ... ok [ 23s] test test_btreeset_repetition ... ok [ 23s] test test_array ... ok [ 23s] test test_char ... ok [ 23s] test test_cow ... ok [ 23s] test test_closure ... ok [ 23s] test test_duplicate ... ok [ 23s] test test_duplicate_name_repetition ... ok [ 23s] test test_duplicate_name_repetition_no_copy ... ok [ 23s] test test_empty_quote ... ok [ 23s] test test_fancy_repetition ... ok [ 23s] test test_floating ... ok [ 23s] test test_format_ident ... ok [ 23s] test test_format_ident_strip_raw ... ok [ 23s] test test_ident ... ok [ 23s] test test_inner_attr ... ok [ 23s] test test_inner_block_comment ... ok [ 23s] test test_inner_line_comment ... ok [ 23s] test test_integer ... ok [ 23s] test test_interpolated_literal ... ok [ 23s] test test_iter ... ok [ 23s] test test_nested_fancy_repetition ... ok [ 23s] test test_nonrep_in_repetition ... ok [ 23s] test test_outer_attr ... ok [ 23s] test test_outer_block_comment ... ok [ 23s] test test_outer_line_comment ... ok [ 23s] test test_quote_impl ... ok [ 23s] test test_quote_raw_id ... ok [ 23s] test test_quote_spanned_impl ... ok [ 23s] test test_star_after_repetition ... ok [ 23s] test test_str ... ok [ 23s] test test_string ... ok [ 23s] test test_substitution ... ok [ 23s] test test_underscore ... ok [ 23s] test test_variable_name_conflict ... ok [ 23s] [ 23s] test result: ok. 37 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.05s --- packaging/rust-quote.spec | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/packaging/rust-quote.spec b/packaging/rust-quote.spec index a4d0b20..f5a4632 100644 --- a/packaging/rust-quote.spec +++ b/packaging/rust-quote.spec @@ -24,6 +24,13 @@ Source2: extern_core-proc_macro2.patch BuildRequires: rust BuildRequires: rust-proc-macro2 +# ========================================================== +# dev-dependencies +# ========================================================== +%if 0%{?run_tests} +BuildRequires: rust-rustversion +BuildRequires: rust-trybuild +%endif %description Quasi-quoting macro quote!(...). @@ -46,6 +53,32 @@ cp %{SOURCE1} . -lproc_macro2 \ ./src/lib.rs + +%check +%if 0%{?run_tests} +export unit_test_list="compiletest test" + +for unit_test in ${unit_test_list} +do +%{rustc_std_build} --test --crate-type=dylib \ + --crate-name=${unit_test} \ + %{?rustc_edition:--edition=%{rustc_edition}} \ + --cfg='feature="default"' \ + --cfg='feature="proc-macro"' \ + -lproc_macro2 \ + --extern %{real_crate_name}=./lib%{real_crate_name}.so \ + %rust_dylib_extern rustversion \ + %rust_dylib_extern trybuild \ + %rust_dylib_extern proc_macro2 \ + ./tests/${unit_test}.rs +done + +for unit_test in ${unit_test_list} +do +./${unit_test} +done +%endif + # ========================================================== # install section # ========================================================== -- 2.7.4