我想編譯運行某個測試子集的二進制文件。當我運行下面的,它的工作原理:將特定測試編譯爲二進制文件
[email protected]:/ox$ cargo test hash::vec
Finished dev [unoptimized + debuginfo] target(s) in 0.11 secs
Running target/debug/deps/ox-824a031ff1732165
running 9 tests
test hash::vec::test_hash_entry::test_get_offset_tombstone ... ok
test hash::vec::test_hash_entry::test_get_offset_value ... ok
test hash::vec::test_hash_table::test_delete ... ok
test hash::vec::test_hash_table::test_delete_and_set ... ok
test hash::vec::test_hash_table::test_get_from_hash ... ok
test hash::vec::test_hash_table::test_get_non_existant_from_hash ... ok
test hash::vec::test_hash_table::test_override ... ok
test hash::vec::test_hash_table::test_grow_hash ... ok
test hash::vec::test_hash_table::test_set_after_filled_with_tombstones ... ok
test result: ok. 9 passed; 0 failed; 0 ignored; 0 measured; 8 filtered out
當我嘗試運行target/debug/deps/ox-824a031ff1732165
,它運行了所有的考試,不只是在hash::vec
指定的9。
我試着運行cargo rustc --test hash::vec
,但我得到 error: no test target named
哈希:: VEC .
貨物rustc - --test works, but creates a binary that runs all tests. If I try
貨物rustc - --test哈希:: vec`,我得到:
Compiling ox v0.1.0 (file:///ox)
error: multiple input filenames provided
error: Could not compile `ox`.
cargo rustc -h
說你可以通過NAME --test
標誌(--test NAME Build only the specified test target
),所以我想知道「NAME」是什麼,以及如何傳遞它,所以我得到一個二進制文件,只運行在hash::vec
指定的9個測試。
啊好的,這實際上回答了我的問題。我真正需要做的是運行我的測試子集(我試圖運行valgrind來檢測內存泄漏)。將哈希:: vec傳遞給二進制文件正是我所需要的。謝謝! – user1413793