Skip to content

Commit 8b43d79

Browse files
committed
Fix integration tests
1 parent dc086c6 commit 8b43d79

File tree

3 files changed

+59
-7
lines changed

3 files changed

+59
-7
lines changed

Cargo.lock

Lines changed: 49 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ serde_json = "1.0.122"
5757
serde.workspace = true
5858
toml_edit.workspace = true
5959

60+
[dev-dependencies]
61+
tempfile = "3.12.0"
62+
6063
[profile.release]
6164
panic = "abort"
6265

tests/integration_tests.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,28 +155,28 @@ fn hint() {
155155

156156
#[test]
157157
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();
159161

160-
Cmd::default().current_dir("tests").fail();
162+
Cmd::default().current_dir(test_dir).fail();
161163

162164
Cmd::default()
163-
.current_dir("tests")
165+
.current_dir(test_dir)
164166
.args(&["init"])
165167
.success();
166168

167169
// Running `init` after a successful initialization.
168170
Cmd::default()
169-
.current_dir("tests")
171+
.current_dir(test_dir)
170172
.args(&["init"])
171173
.output(PartialStderr("`cd rustlings`"))
172174
.fail();
173175

174176
// Running `init` in the initialized directory.
175177
Cmd::default()
176-
.current_dir("tests/rustlings")
178+
.current_dir(initialized_dir.to_str().unwrap())
177179
.args(&["init"])
178180
.output(PartialStderr("already initialized"))
179181
.fail();
180-
181-
fs::remove_dir_all("tests/rustlings").unwrap();
182182
}

0 commit comments

Comments
 (0)