Skip to content

Commit a8e81ce

Browse files
committed
Improved handling of tmp dirs in integration tests
1 parent bac30de commit a8e81ce

File tree

100 files changed

+1273
-32
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+1273
-32
lines changed

crates/tmc-langs-cli/tests/integration.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ use tmc_langs_cli::app::Cli;
66
use walkdir::WalkDir;
77

88
fn cp_exercise(path: &Path) -> TempDir {
9+
let path_parent = path.parent().unwrap();
910
let temp = tempdir().unwrap();
1011
for file in WalkDir::new(path) {
1112
let file = file.unwrap();
12-
let relative = file.path().strip_prefix(path).unwrap();
13+
let relative = file.path().strip_prefix(path_parent).unwrap();
1314
let target = temp.path().join(relative);
1415
if file.file_type().is_dir() {
1516
std::fs::create_dir_all(target).unwrap();
@@ -91,23 +92,24 @@ fn test(f: impl Fn(&Path)) {
9192
],
9293
}, {
9394
insta::glob!("../../../", "sample_exercises/*/*", |exercise| {
94-
println!("testing {exercise:?}");
95-
f(exercise)
95+
let dir_name = exercise.file_name().unwrap();
96+
let exercise = cp_exercise(&exercise);
97+
println!("testing {:?}", exercise.path().join(dir_name));
98+
f(&exercise.path().join(dir_name))
9699
})
97100
})
98101
}
99102

100103
#[test]
101104
fn checkstyle() {
102105
test(|exercise| {
103-
let ex = cp_exercise(exercise);
104106
let out = NamedTempFile::new().unwrap();
105107
let cli = Cli::parse_from([
106108
"tmc-langs-cli",
107109
"--pretty",
108110
"checkstyle",
109111
"--exercise-path",
110-
path_str(&ex),
112+
path_str(&exercise),
111113
"--locale",
112114
"eng",
113115
"--output-path",
@@ -121,17 +123,16 @@ fn checkstyle() {
121123
#[test]
122124
fn clean() {
123125
test(|exercise| {
124-
let ex = cp_exercise(exercise);
125126
let cli = Cli::parse_from([
126127
"tmc-langs-cli",
127128
"--pretty",
128129
"clean",
129130
"--exercise-path",
130-
path_str(&ex),
131+
path_str(&exercise),
131132
]);
132133
let output = tmc_langs_cli::run(cli).unwrap();
133134
insta::assert_yaml_snapshot!(output);
134-
let files = sorted_list_of_files(&ex);
135+
let files = sorted_list_of_files(&exercise);
135136
insta::assert_yaml_snapshot!(files);
136137
})
137138
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
source: crates/tmc-langs-cli/tests/integration.rs
3+
expression: files
4+
input_file: sample_exercises/csharp/failing-exercise
5+
---
6+
- failing-exercise
7+
- failing-exercise/src
8+
- failing-exercise/src/FailingSample
9+
- failing-exercise/src/FailingSample/FailingSample.csproj
10+
- failing-exercise/src/FailingSample/Program.cs
11+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
source: crates/tmc-langs-cli/tests/integration.rs
3+
expression: output
4+
input_file: sample_exercises/csharp/failing-exercise
5+
---
6+
output-kind: output-data
7+
status: finished
8+
message: compressed project from [PATH] to [PATH]
9+
result: executed-command
10+
data: ~
11+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
source: crates/tmc-langs-cli/tests/integration.rs
3+
expression: files
4+
input_file: sample_exercises/csharp/non-compiling-exercise
5+
---
6+
- non-compiling-exercise
7+
- non-compiling-exercise/src
8+
- non-compiling-exercise/src/NonCompilingSample
9+
- non-compiling-exercise/src/NonCompilingSample/NonCompilingSample.csproj
10+
- non-compiling-exercise/src/NonCompilingSample/Program.cs
11+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
source: crates/tmc-langs-cli/tests/integration.rs
3+
expression: output
4+
input_file: sample_exercises/csharp/non-compiling-exercise
5+
---
6+
output-kind: output-data
7+
status: finished
8+
message: compressed project from [PATH] to [PATH]
9+
result: executed-command
10+
data: ~
11+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
source: crates/tmc-langs-cli/tests/integration.rs
3+
expression: files
4+
input_file: sample_exercises/csharp/partially-passing
5+
---
6+
- partially-passing
7+
- partially-passing/src
8+
- partially-passing/src/TestProject
9+
- partially-passing/src/TestProject/Program.cs
10+
- partially-passing/src/TestProject/TestProject.csproj
11+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
source: crates/tmc-langs-cli/tests/integration.rs
3+
expression: output
4+
input_file: sample_exercises/csharp/partially-passing
5+
---
6+
output-kind: output-data
7+
status: finished
8+
message: compressed project from [PATH] to [PATH]
9+
result: executed-command
10+
data: ~
11+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
source: crates/tmc-langs-cli/tests/integration.rs
3+
expression: files
4+
input_file: sample_exercises/csharp/passing-exercise
5+
---
6+
- passing-exercise
7+
- passing-exercise/src
8+
- passing-exercise/src/PassingSample
9+
- passing-exercise/src/PassingSample/PassingSample.csproj
10+
- passing-exercise/src/PassingSample/Program.cs
11+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
source: crates/tmc-langs-cli/tests/integration.rs
3+
expression: output
4+
input_file: sample_exercises/csharp/passing-exercise
5+
---
6+
output-kind: output-data
7+
status: finished
8+
message: compressed project from [PATH] to [PATH]
9+
result: executed-command
10+
data: ~
11+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
source: crates/tmc-langs-cli/tests/integration.rs
3+
expression: files
4+
input_file: sample_exercises/java/ant-exercise
5+
---
6+
- ant-exercise
7+
- ant-exercise/src
8+
- ant-exercise/src/Arith.java
9+

0 commit comments

Comments
 (0)