File tree Expand file tree Collapse file tree 3 files changed +59
-7
lines changed Expand file tree Collapse file tree 3 files changed +59
-7
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,9 @@ serde_json = "1.0.122"
57
57
serde.workspace = true
58
58
toml_edit.workspace = true
59
59
60
+ [dev-dependencies ]
61
+ tempfile = " 3.12.0"
62
+
60
63
[profile .release ]
61
64
panic = " abort"
62
65
Original file line number Diff line number Diff line change @@ -155,28 +155,28 @@ fn hint() {
155
155
156
156
#[ test]
157
157
fn init ( ) {
158
- let _ = fs:: remove_dir_all ( "tests/rustlings" ) ;
158
+ let test_dir = tempfile:: TempDir :: new ( ) . unwrap ( ) ;
159
+ let initialized_dir = test_dir. path ( ) . join ( "rustlings" ) ;
160
+ let test_dir = test_dir. path ( ) . to_str ( ) . unwrap ( ) ;
159
161
160
- Cmd :: default ( ) . current_dir ( "tests" ) . fail ( ) ;
162
+ Cmd :: default ( ) . current_dir ( test_dir ) . fail ( ) ;
161
163
162
164
Cmd :: default ( )
163
- . current_dir ( "tests" )
165
+ . current_dir ( test_dir )
164
166
. args ( & [ "init" ] )
165
167
. success ( ) ;
166
168
167
169
// Running `init` after a successful initialization.
168
170
Cmd :: default ( )
169
- . current_dir ( "tests" )
171
+ . current_dir ( test_dir )
170
172
. args ( & [ "init" ] )
171
173
. output ( PartialStderr ( "`cd rustlings`" ) )
172
174
. fail ( ) ;
173
175
174
176
// Running `init` in the initialized directory.
175
177
Cmd :: default ( )
176
- . current_dir ( "tests/rustlings" )
178
+ . current_dir ( initialized_dir . to_str ( ) . unwrap ( ) )
177
179
. args ( & [ "init" ] )
178
180
. output ( PartialStderr ( "already initialized" ) )
179
181
. fail ( ) ;
180
-
181
- fs:: remove_dir_all ( "tests/rustlings" ) . unwrap ( ) ;
182
182
}
You can’t perform that action at this time.
0 commit comments