@@ -2647,17 +2647,18 @@ pub fn run_ldb_tool(ldb_args: &[String], opts: &DBOptions) {
26472647
26482648#[ cfg( test) ]
26492649mod test {
2650- use super :: * ;
26512650 use std:: fs;
26522651 use std:: path:: Path ;
26532652 use std:: str;
26542653 use std:: string:: String ;
26552654 use std:: thread;
2656- use tempdir:: TempDir ;
2655+
2656+ use super :: * ;
2657+ use crate :: tempdir_with_prefix;
26572658
26582659 #[ test]
26592660 fn external ( ) {
2660- let path = TempDir :: new ( "_rust_rocksdb_externaltest" ) . expect ( " ") ;
2661+ let path = tempdir_with_prefix ( "_rust_rocksdb_externaltest" ) ;
26612662 let db = DB :: open_default ( path. path ( ) . to_str ( ) . unwrap ( ) ) . unwrap ( ) ;
26622663 let p = db. put ( b"k1" , b"v1111" ) ;
26632664 assert ! ( p. is_ok( ) ) ;
@@ -2670,7 +2671,7 @@ mod test {
26702671 #[ allow( unused_variables) ]
26712672 #[ test]
26722673 fn errors_do_stuff ( ) {
2673- let path = TempDir :: new ( "_rust_rocksdb_error" ) . expect ( " ") ;
2674+ let path = tempdir_with_prefix ( "_rust_rocksdb_error" ) ;
26742675 let path_str = path. path ( ) . to_str ( ) . unwrap ( ) ;
26752676 let db = DB :: open_default ( path_str) . unwrap ( ) ;
26762677 let opts = DBOptions :: new ( ) ;
@@ -2689,7 +2690,7 @@ mod test {
26892690
26902691 #[ test]
26912692 fn writebatch_works ( ) {
2692- let path = TempDir :: new ( "_rust_rocksdb_writebacktest" ) . expect ( " ") ;
2693+ let path = tempdir_with_prefix ( "_rust_rocksdb_writebacktest" ) ;
26932694 let db = DB :: open_default ( path. path ( ) . to_str ( ) . unwrap ( ) ) . unwrap ( ) ;
26942695
26952696 // test put
@@ -2760,7 +2761,7 @@ mod test {
27602761
27612762 #[ test]
27622763 fn iterator_test ( ) {
2763- let path = TempDir :: new ( "_rust_rocksdb_iteratortest" ) . expect ( " ") ;
2764+ let path = tempdir_with_prefix ( "_rust_rocksdb_iteratortest" ) ;
27642765
27652766 let db = DB :: open_default ( path. path ( ) . to_str ( ) . unwrap ( ) ) . unwrap ( ) ;
27662767 db. put ( b"k1" , b"v1111" ) . expect ( "" ) ;
@@ -2779,7 +2780,7 @@ mod test {
27792780
27802781 #[ test]
27812782 fn approximate_size_test ( ) {
2782- let path = TempDir :: new ( "_rust_rocksdb_iteratortest" ) . expect ( " ") ;
2783+ let path = tempdir_with_prefix ( "_rust_rocksdb_iteratortest" ) ;
27832784 let db = DB :: open_default ( path. path ( ) . to_str ( ) . unwrap ( ) ) . unwrap ( ) ;
27842785 for i in 1 ..8000 {
27852786 db. put (
@@ -2807,7 +2808,7 @@ mod test {
28072808
28082809 #[ test]
28092810 fn property_test ( ) {
2810- let path = TempDir :: new ( "_rust_rocksdb_propertytest" ) . expect ( " ") ;
2811+ let path = tempdir_with_prefix ( "_rust_rocksdb_propertytest" ) ;
28112812 let db = DB :: open_default ( path. path ( ) . to_str ( ) . unwrap ( ) ) . unwrap ( ) ;
28122813 db. put ( b"a1" , b"v1" ) . unwrap ( ) ;
28132814 db. flush ( true ) . unwrap ( ) ;
@@ -2822,7 +2823,7 @@ mod test {
28222823
28232824 #[ test]
28242825 fn list_column_families_test ( ) {
2825- let path = TempDir :: new ( "_rust_rocksdb_list_column_families_test" ) . expect ( " ") ;
2826+ let path = tempdir_with_prefix ( "_rust_rocksdb_list_column_families_test" ) ;
28262827 let mut cfs = [ "default" , "cf1" , "cf2" , "cf3" ] ;
28272828 {
28282829 let mut cfs_opts = vec ! [ ] ;
@@ -2853,13 +2854,13 @@ mod test {
28532854 let key = b"foo" ;
28542855 let value = b"bar" ;
28552856
2856- let db_dir = TempDir :: new ( "_rust_rocksdb_backuptest" ) . unwrap ( ) ;
2857+ let db_dir = tempdir_with_prefix ( "_rust_rocksdb_backuptest" ) ;
28572858 let db = DB :: open_default ( db_dir. path ( ) . to_str ( ) . unwrap ( ) ) . unwrap ( ) ;
28582859 let p = db. put ( key, value) ;
28592860 assert ! ( p. is_ok( ) ) ;
28602861
28612862 // Make a backup.
2862- let backup_dir = TempDir :: new ( "_rust_rocksdb_backuptest_backup" ) . unwrap ( ) ;
2863+ let backup_dir = tempdir_with_prefix ( "_rust_rocksdb_backuptest_backup" ) ;
28632864 let backup_engine = db. backup_at ( backup_dir. path ( ) . to_str ( ) . unwrap ( ) ) . unwrap ( ) ;
28642865
28652866 // Restore it.
@@ -2868,7 +2869,7 @@ mod test {
28682869 ropt2. set_keep_log_files ( true ) ;
28692870 let ropts = [ ropt1, ropt2] ;
28702871 for ropt in & ropts {
2871- let restore_dir = TempDir :: new ( "_rust_rocksdb_backuptest_restore" ) . unwrap ( ) ;
2872+ let restore_dir = tempdir_with_prefix ( "_rust_rocksdb_backuptest_restore" ) ;
28722873 let restored_db = DB :: restore_from (
28732874 & backup_engine,
28742875 restore_dir. path ( ) . to_str ( ) . unwrap ( ) ,
@@ -2884,7 +2885,7 @@ mod test {
28842885
28852886 #[ test]
28862887 fn log_dir_test ( ) {
2887- let db_dir = TempDir :: new ( "_rust_rocksdb_logdirtest" ) . unwrap ( ) ;
2888+ let db_dir = tempdir_with_prefix ( "_rust_rocksdb_logdirtest" ) ;
28882889 let db_path = db_dir. path ( ) . to_str ( ) . unwrap ( ) ;
28892890 let log_path = format ! ( "{}" , Path :: new( & db_path) . join( "log_path" ) . display( ) ) ;
28902891 fs:: create_dir_all ( & log_path) . unwrap ( ) ;
@@ -2910,7 +2911,7 @@ mod test {
29102911
29112912 #[ test]
29122913 fn single_delete_test ( ) {
2913- let path = TempDir :: new ( "_rust_rocksdb_singledeletetest" ) . expect ( " ") ;
2914+ let path = tempdir_with_prefix ( "_rust_rocksdb_singledeletetest" ) ;
29142915 let db = DB :: open_default ( path. path ( ) . to_str ( ) . unwrap ( ) ) . unwrap ( ) ;
29152916
29162917 db. put ( b"a" , b"v1" ) . unwrap ( ) ;
@@ -2945,7 +2946,7 @@ mod test {
29452946
29462947 #[ test]
29472948 fn test_pause_bg_work ( ) {
2948- let path = TempDir :: new ( "_rust_rocksdb_pause_bg_work" ) . expect ( " ") ;
2949+ let path = tempdir_with_prefix ( "_rust_rocksdb_pause_bg_work" ) ;
29492950 let db = DB :: open_default ( path. path ( ) . to_str ( ) . unwrap ( ) ) . unwrap ( ) ;
29502951 let db = Arc :: new ( db) ;
29512952 let db1 = db. clone ( ) ;
@@ -3000,7 +3001,7 @@ mod test {
30003001
30013002 #[ test]
30023003 fn block_cache_usage ( ) {
3003- let path = TempDir :: new ( "_rust_rocksdb_block_cache_usage" ) . expect ( " ") ;
3004+ let path = tempdir_with_prefix ( "_rust_rocksdb_block_cache_usage" ) ;
30043005 let db = DB :: open_default ( path. path ( ) . to_str ( ) . unwrap ( ) ) . unwrap ( ) ;
30053006
30063007 for i in 0 ..200 {
@@ -3018,7 +3019,7 @@ mod test {
30183019
30193020 #[ test]
30203021 fn flush_cf ( ) {
3021- let path = TempDir :: new ( "_rust_rocksdb_flush_cf" ) . expect ( " ") ;
3022+ let path = tempdir_with_prefix ( "_rust_rocksdb_flush_cf" ) ;
30223023 let mut opts = DBOptions :: new ( ) ;
30233024 opts. create_if_missing ( true ) ;
30243025 let mut db = DB :: open ( opts, path. path ( ) . to_str ( ) . unwrap ( ) ) . unwrap ( ) ;
@@ -3058,7 +3059,7 @@ mod test {
30583059 fn test_get_all_key_versions ( ) {
30593060 let mut opts = DBOptions :: new ( ) ;
30603061 opts. create_if_missing ( true ) ;
3061- let path = TempDir :: new ( "_rust_rocksdb_get_all_key_version_test" ) . expect ( " ") ;
3062+ let path = tempdir_with_prefix ( "_rust_rocksdb_get_all_key_version_test" ) ;
30623063 let db = DB :: open ( opts, path. path ( ) . to_str ( ) . unwrap ( ) ) . unwrap ( ) ;
30633064
30643065 let samples = vec ! [
@@ -3084,7 +3085,7 @@ mod test {
30843085 fn test_get_approximate_memtable_stats ( ) {
30853086 let mut opts = DBOptions :: new ( ) ;
30863087 opts. create_if_missing ( true ) ;
3087- let path = TempDir :: new ( "_rust_rocksdb_get_approximate_memtable_stats" ) . expect ( " ") ;
3088+ let path = tempdir_with_prefix ( "_rust_rocksdb_get_approximate_memtable_stats" ) ;
30883089 let db = DB :: open ( opts, path. path ( ) . to_str ( ) . unwrap ( ) ) . unwrap ( ) ;
30893090
30903091 let samples = [
@@ -3114,7 +3115,7 @@ mod test {
31143115 fn test_set_options ( ) {
31153116 let mut opts = DBOptions :: new ( ) ;
31163117 opts. create_if_missing ( true ) ;
3117- let path = TempDir :: new ( "_rust_rocksdb_set_option" ) . expect ( " ") ;
3118+ let path = tempdir_with_prefix ( "_rust_rocksdb_set_option" ) ;
31183119
31193120 let db = DB :: open ( opts, path. path ( ) . to_str ( ) . unwrap ( ) ) . unwrap ( ) ;
31203121 let cf = db. cf_handle ( "default" ) . unwrap ( ) ;
@@ -3135,7 +3136,7 @@ mod test {
31353136
31363137 #[ test]
31373138 fn test_load_latest_options ( ) {
3138- let path = TempDir :: new ( "_rust_rocksdb_load_latest_option" ) . expect ( " ") ;
3139+ let path = tempdir_with_prefix ( "_rust_rocksdb_load_latest_option" ) ;
31393140 let dbpath = path. path ( ) . to_str ( ) . unwrap ( ) . clone ( ) ;
31403141 let cf_name: & str = "cf_dynamic_level_bytes" ;
31413142
@@ -3170,7 +3171,7 @@ mod test {
31703171
31713172 #[ test]
31723173 fn test_sequence_number ( ) {
3173- let path = TempDir :: new ( "_rust_rocksdb_sequence_number" ) . expect ( " ") ;
3174+ let path = tempdir_with_prefix ( "_rust_rocksdb_sequence_number" ) ;
31743175
31753176 let mut opts = DBOptions :: new ( ) ;
31763177 opts. create_if_missing ( true ) ;
@@ -3188,7 +3189,7 @@ mod test {
31883189
31893190 #[ test]
31903191 fn test_map_property ( ) {
3191- let path = TempDir :: new ( "_rust_rocksdb_get_map_property" ) . expect ( " ") ;
3192+ let path = tempdir_with_prefix ( "_rust_rocksdb_get_map_property" ) ;
31923193 let dbpath = path. path ( ) . to_str ( ) . unwrap ( ) . clone ( ) ;
31933194
31943195 let mut opts = DBOptions :: new ( ) ;
0 commit comments