テストの特定のサブセットを実行するバイナリをコンパイルしたいと思います。私は次のことを実行すると、それが動作します:特定のテストをバイナリにコンパイルする
[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
を実行しようと、それだけではなく9はhash::vec
に指定されているすべての私のテストを実行します。
私は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
は、--test
フラグ(--test NAME Build only the specified test target
)でNAMEを渡すことができると言います。「NAME」とはどのように渡すべきなのでしょうか?hash::vec
で指定された9つのテストのみを実行するバイナリを取得します。
ああ、それは実際に私の質問に答える。私が本当にやる必要があったのは、私のサブセットのテストを実行することでした(私はvalgrindを実行してメモリリークを検出しようとしています)。バイナリにhash :: vecを渡すことは、私が必要としていたものとまったく同じでした。ありがとう! – user1413793