@@ -1457,12 +1457,12 @@ mod tests {
1457
1457
use prelude:: v1:: * ;
1458
1458
use io:: prelude:: * ;
1459
1459
1460
- use env;
1461
1460
use fs:: { self , File , OpenOptions } ;
1462
1461
use io:: { ErrorKind , SeekFrom } ;
1463
- use path:: { Path , PathBuf } ;
1464
- use rand:: { self , StdRng , Rng } ;
1462
+ use path:: Path ;
1463
+ use rand:: { StdRng , Rng } ;
1465
1464
use str;
1465
+ use sys_common:: io:: test:: { TempDir , tmpdir} ;
1466
1466
1467
1467
#[ cfg( windows) ]
1468
1468
use os:: windows:: fs:: { symlink_dir, symlink_file} ;
@@ -1490,37 +1490,6 @@ mod tests {
1490
1490
}
1491
1491
) }
1492
1492
1493
- pub struct TempDir ( PathBuf ) ;
1494
-
1495
- impl TempDir {
1496
- fn join ( & self , path : & str ) -> PathBuf {
1497
- let TempDir ( ref p) = * self ;
1498
- p. join ( path)
1499
- }
1500
-
1501
- fn path < ' a > ( & ' a self ) -> & ' a Path {
1502
- let TempDir ( ref p) = * self ;
1503
- p
1504
- }
1505
- }
1506
-
1507
- impl Drop for TempDir {
1508
- fn drop ( & mut self ) {
1509
- // Gee, seeing how we're testing the fs module I sure hope that we
1510
- // at least implement this correctly!
1511
- let TempDir ( ref p) = * self ;
1512
- check ! ( fs:: remove_dir_all( p) ) ;
1513
- }
1514
- }
1515
-
1516
- pub fn tmpdir ( ) -> TempDir {
1517
- let p = env:: temp_dir ( ) ;
1518
- let mut r = rand:: thread_rng ( ) ;
1519
- let ret = p. join ( & format ! ( "rust-{}" , r. next_u32( ) ) ) ;
1520
- check ! ( fs:: create_dir( & ret) ) ;
1521
- TempDir ( ret)
1522
- }
1523
-
1524
1493
// Several test fail on windows if the user does not have permission to
1525
1494
// create symlinks (the `SeCreateSymbolicLinkPrivilege`). Instead of
1526
1495
// disabling these test on Windows, use this function to test whether we
0 commit comments