File tree 1 file changed +18
-0
lines changed
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,15 @@ impl TempDir {
101
101
Err ( Self :: already_exists ( ) )
102
102
}
103
103
104
+ /// Make this directory persistent.
105
+ ///
106
+ /// This corresponds to [`tempfile::TempDir::into_path`].
107
+ ///
108
+ /// [`tempfile::TempDir::into_path`]: https://docs.rs/tempfile/latest/tempfile/struct.TempDir.html#method.into_path
109
+ pub fn persist ( mut self ) -> io:: Result < Dir > {
110
+ Ok ( self . dir . take ( ) . unwrap ( ) )
111
+ }
112
+
104
113
/// Closes and removes the temporary directory, returning a `Result`.
105
114
///
106
115
/// This corresponds to [`tempfile::TempDir::close`].
@@ -222,6 +231,15 @@ fn close_tempdir() {
222
231
t. close ( ) . unwrap ( ) ;
223
232
}
224
233
234
+ #[ test]
235
+ fn persist_tempdir ( ) {
236
+ use crate :: ambient_authority;
237
+
238
+ let t = tempdir ( ambient_authority ( ) ) . unwrap ( ) ;
239
+ let d = t. persist ( ) . unwrap ( ) ;
240
+ assert ! ( d. exists( "." ) ) ;
241
+ }
242
+
225
243
#[ test]
226
244
fn drop_tempdir_in ( ) {
227
245
use crate :: ambient_authority;
You can’t perform that action at this time.
0 commit comments