Skip to content

Commit 3576e50

Browse files
authored
Merge pull request #103 from rage/tracing
Tracing
2 parents d9c01e2 + f39a35a commit 3576e50

File tree

20 files changed

+564
-688
lines changed

20 files changed

+564
-688
lines changed

plugins/csharp/src/plugin.rs

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use std::io::{BufReader, Cursor, Read, Seek};
99
use std::path::{Path, PathBuf};
1010
use std::time::Duration;
1111
use tmc_langs_framework::{
12-
anyhow,
1312
command::TmcCommand,
1413
domain::{
1514
ExerciseDesc, RunResult, RunStatus, StyleValidationResult, StyleValidationStrategy,
@@ -207,12 +206,7 @@ impl LanguagePlugin for CSharpPlugin {
207206
}
208207

209208
/// Runs --generate-points-file and parses the generated .tmc_available_points.json.
210-
fn scan_exercise(
211-
&self,
212-
path: &Path,
213-
exercise_name: String,
214-
_warnings: &mut Vec<anyhow::Error>,
215-
) -> Result<ExerciseDesc, TmcError> {
209+
fn scan_exercise(&self, path: &Path, exercise_name: String) -> Result<ExerciseDesc, TmcError> {
216210
// clean old points file
217211
let exercise_desc_json_path = path.join(".tmc_available_points.json");
218212
if exercise_desc_json_path.exists() {
@@ -251,7 +245,6 @@ impl LanguagePlugin for CSharpPlugin {
251245
&self,
252246
path: &Path,
253247
timeout: Option<Duration>,
254-
_warnings: &mut Vec<anyhow::Error>,
255248
) -> Result<RunResult, TmcError> {
256249
// clean old file
257250
let test_results_path = path.join(".tmc_test_results.json");
@@ -595,7 +588,7 @@ mod test {
595588
let temp = dir_to_temp("tests/data/passing-exercise");
596589
let plugin = CSharpPlugin::new();
597590
let scan = plugin
598-
.scan_exercise(temp.path(), "name".to_string(), &mut vec![])
591+
.scan_exercise(temp.path(), "name".to_string())
599592
.unwrap();
600593
assert_eq!(scan.name, "name");
601594
assert_eq!(scan.tests.len(), 2);
@@ -607,7 +600,7 @@ mod test {
607600

608601
let temp = dir_to_temp("tests/data/passing-exercise");
609602
let plugin = CSharpPlugin::new();
610-
let res = plugin.run_tests(temp.path(), &mut vec![]).unwrap();
603+
let res = plugin.run_tests(temp.path()).unwrap();
611604
assert_eq!(res.status, RunStatus::Passed);
612605
assert_eq!(res.test_results.len(), 2);
613606
for tr in res.test_results {
@@ -623,7 +616,7 @@ mod test {
623616

624617
let temp = dir_to_temp("tests/data/failing-exercise");
625618
let plugin = CSharpPlugin::new();
626-
let res = plugin.run_tests(temp.path(), &mut vec![]).unwrap();
619+
let res = plugin.run_tests(temp.path()).unwrap();
627620
assert_eq!(res.status, RunStatus::TestsFailed);
628621
assert_eq!(res.test_results.len(), 1);
629622
let test_result = &res.test_results[0];
@@ -641,7 +634,7 @@ mod test {
641634

642635
let temp = dir_to_temp("tests/data/non-compiling-exercise");
643636
let plugin = CSharpPlugin::new();
644-
let res = plugin.run_tests(temp.path(), &mut vec![]).unwrap();
637+
let res = plugin.run_tests(temp.path()).unwrap();
645638
assert_eq!(res.status, RunStatus::CompileFailed);
646639
assert!(!res.logs.is_empty());
647640
log::debug!("{:?}", res.logs.get("stdout"));
@@ -659,11 +652,7 @@ mod test {
659652
let temp = dir_to_temp("tests/data/passing-exercise");
660653
let plugin = CSharpPlugin::new();
661654
let res = plugin
662-
.run_tests_with_timeout(
663-
temp.path(),
664-
Some(std::time::Duration::from_nanos(1)),
665-
&mut vec![],
666-
)
655+
.run_tests_with_timeout(temp.path(), Some(std::time::Duration::from_nanos(1)))
667656
.unwrap();
668657
assert_eq!(res.status, RunStatus::TestsFailed);
669658
}
@@ -682,7 +671,7 @@ mod test {
682671
.join("obj");
683672
assert!(!bin_path.exists());
684673
assert!(!obj_path_test.exists());
685-
plugin.run_tests(temp.path(), &mut vec![]).unwrap();
674+
plugin.run_tests(temp.path()).unwrap();
686675
assert!(bin_path.exists());
687676
assert!(obj_path_test.exists());
688677
plugin.clean(temp.path()).unwrap();
@@ -709,7 +698,7 @@ mod test {
709698

710699
let temp = dir_to_temp("tests/data/partially-passing");
711700
let plugin = CSharpPlugin::new();
712-
let results = plugin.run_tests(temp.path(), &mut vec![]).unwrap();
701+
let results = plugin.run_tests(temp.path()).unwrap();
713702
assert_eq!(results.status, RunStatus::TestsFailed);
714703
let mut got_point = false;
715704
for test in results.test_results {

plugins/java/src/ant_plugin.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use std::ffi::OsStr;
1010
use std::path::{Path, PathBuf};
1111
use std::time::Duration;
1212
use tmc_langs_framework::{
13-
anyhow,
1413
command::TmcCommand,
1514
domain::{ExerciseDesc, RunResult, StyleValidationResult},
1615
file_util,
@@ -80,12 +79,7 @@ impl LanguagePlugin for AntPlugin {
8079
}
8180

8281
/// Scans the exercise at the given path. Immediately exits if the target directory is not a valid exercise.
83-
fn scan_exercise(
84-
&self,
85-
path: &Path,
86-
exercise_name: String,
87-
_warnings: &mut Vec<anyhow::Error>,
88-
) -> Result<ExerciseDesc, TmcError> {
82+
fn scan_exercise(&self, path: &Path, exercise_name: String) -> Result<ExerciseDesc, TmcError> {
8983
if !Self::is_exercise_type_correct(path) {
9084
return JavaError::InvalidExercise(path.to_path_buf()).into();
9185
}
@@ -98,7 +92,6 @@ impl LanguagePlugin for AntPlugin {
9892
&self,
9993
project_root_path: &Path,
10094
timeout: Option<Duration>,
101-
_warnings: &mut Vec<anyhow::Error>,
10295
) -> Result<RunResult, TmcError> {
10396
Ok(self.run_java_tests(project_root_path, timeout)?)
10497
}
@@ -496,7 +489,7 @@ mod test {
496489
let temp_dir = dir_to_temp("tests/data/ant-exercise");
497490
let plugin = AntPlugin::new().unwrap();
498491
let exercises = plugin
499-
.scan_exercise(&temp_dir.path(), "test".to_string(), &mut vec![])
492+
.scan_exercise(&temp_dir.path(), "test".to_string())
500493
.unwrap();
501494
assert_eq!(exercises.name, "test");
502495
assert_eq!(exercises.tests.len(), 4);
@@ -536,7 +529,7 @@ mod test {
536529
let temp_dir = dir_to_temp("tests/data/ant-exercise");
537530
let plugin = AntPlugin::new().unwrap();
538531
let test_result = plugin
539-
.run_tests_with_timeout(Path::new(temp_dir.path()), None, &mut vec![])
532+
.run_tests_with_timeout(Path::new(temp_dir.path()), None)
540533
.unwrap();
541534
log::debug!("{:?}", test_result);
542535
assert_eq!(
@@ -552,11 +545,7 @@ mod test {
552545
let temp_dir = dir_to_temp("tests/data/ant-exercise");
553546
let plugin = AntPlugin::new().unwrap();
554547
let test_result_err = plugin
555-
.run_tests_with_timeout(
556-
Path::new(temp_dir.path()),
557-
Some(Duration::from_nanos(1)),
558-
&mut vec![],
559-
)
548+
.run_tests_with_timeout(Path::new(temp_dir.path()), Some(Duration::from_nanos(1)))
560549
.unwrap_err();
561550
log::debug!("{:?}", test_result_err);
562551

plugins/java/src/java_plugin.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ mod test {
285285
use crate::SEPARATOR;
286286

287287
use super::*;
288-
use tmc_langs_framework::{anyhow, nom, TmcError};
288+
use tmc_langs_framework::{nom, TmcError};
289289

290290
fn init() {
291291
use log::*;
@@ -333,7 +333,6 @@ mod test {
333333
&self,
334334
_path: &Path,
335335
_exercise_name: String,
336-
_warnings: &mut Vec<anyhow::Error>,
337336
) -> Result<ExerciseDesc, TmcError> {
338337
unimplemented!()
339338
}
@@ -342,7 +341,6 @@ mod test {
342341
&self,
343342
_path: &Path,
344343
_timeout: Option<Duration>,
345-
_warnings: &mut Vec<anyhow::Error>,
346344
) -> Result<RunResult, TmcError> {
347345
unimplemented!()
348346
}

plugins/java/src/maven_plugin.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use std::path::{Path, PathBuf};
1212
use std::time::Duration;
1313
use tar::Archive;
1414
use tmc_langs_framework::{
15-
anyhow,
1615
command::TmcCommand,
1716
domain::{ExerciseDesc, RunResult, StyleValidationResult},
1817
file_util,
@@ -85,12 +84,7 @@ impl LanguagePlugin for MavenPlugin {
8584
Ok(Some(self.run_checkstyle(&locale, path)?))
8685
}
8786

88-
fn scan_exercise(
89-
&self,
90-
path: &Path,
91-
exercise_name: String,
92-
_warnings: &mut Vec<anyhow::Error>,
93-
) -> Result<ExerciseDesc, TmcError> {
87+
fn scan_exercise(&self, path: &Path, exercise_name: String) -> Result<ExerciseDesc, TmcError> {
9488
if !Self::is_exercise_type_correct(path) {
9589
return JavaError::InvalidExercise(path.to_path_buf()).into();
9690
}
@@ -103,7 +97,6 @@ impl LanguagePlugin for MavenPlugin {
10397
&self,
10498
project_root_path: &Path,
10599
timeout: Option<Duration>,
106-
_warnings: &mut Vec<anyhow::Error>,
107100
) -> Result<RunResult, TmcError> {
108101
Ok(self.run_java_tests(project_root_path, timeout)?)
109102
}
@@ -374,7 +367,7 @@ mod test {
374367
let temp_dir = dir_to_temp("tests/data/maven-exercise");
375368
let (plugin, _lock) = get_maven();
376369
let exercises = plugin
377-
.scan_exercise(&temp_dir.path(), "test".to_string(), &mut vec![])
370+
.scan_exercise(&temp_dir.path(), "test".to_string())
378371
.unwrap();
379372
assert_eq!(exercises.name, "test");
380373
assert_eq!(exercises.tests.len(), 1);
@@ -391,7 +384,7 @@ mod test {
391384

392385
let temp_dir = dir_to_temp("tests/data/maven-exercise");
393386
let (plugin, _lock) = get_maven();
394-
let res = plugin.run_tests(temp_dir.path(), &mut vec![]).unwrap();
387+
let res = plugin.run_tests(temp_dir.path()).unwrap();
395388
log::debug!("{:#?}", res);
396389
assert_eq!(
397390
res.status,
@@ -406,11 +399,7 @@ mod test {
406399
let temp_dir = dir_to_temp("tests/data/maven-exercise");
407400
let (plugin, _lock) = get_maven();
408401
let test_result_err = plugin
409-
.run_tests_with_timeout(
410-
temp_dir.path(),
411-
Some(std::time::Duration::from_nanos(1)),
412-
&mut vec![],
413-
)
402+
.run_tests_with_timeout(temp_dir.path(), Some(std::time::Duration::from_nanos(1)))
414403
.unwrap_err();
415404
log::debug!("{:#?}", test_result_err);
416405

plugins/make/src/plugin.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use std::io::{self, BufRead, BufReader, Read, Seek};
1111
use std::path::{Path, PathBuf};
1212
use std::time::Duration;
1313
use tmc_langs_framework::{
14-
anyhow,
1514
command::{Output, TmcCommand},
1615
domain::{ExerciseDesc, RunResult, RunStatus, TestDesc},
1716
error::{CommandError, FileIo},
@@ -129,12 +128,7 @@ impl LanguagePlugin for MakePlugin {
129128
const BLOCK_COMMENT: Option<(&'static str, &'static str)> = Some(("/*", "*/"));
130129
type StudentFilePolicy = MakeStudentFilePolicy;
131130

132-
fn scan_exercise(
133-
&self,
134-
path: &Path,
135-
exercise_name: String,
136-
_warnings: &mut Vec<anyhow::Error>,
137-
) -> Result<ExerciseDesc, TmcError> {
131+
fn scan_exercise(&self, path: &Path, exercise_name: String) -> Result<ExerciseDesc, TmcError> {
138132
if !Self::is_exercise_type_correct(path) {
139133
return MakeError::NoExerciseFound(path.to_path_buf()).into();
140134
}
@@ -154,7 +148,6 @@ impl LanguagePlugin for MakePlugin {
154148
&self,
155149
path: &Path,
156150
_timeout: Option<Duration>,
157-
_warnings: &mut Vec<anyhow::Error>,
158151
) -> Result<RunResult, TmcError> {
159152
let output = self.build(path)?;
160153
if !output.status.success() {
@@ -490,7 +483,7 @@ test [invalid] point6
490483
let temp = dir_to_temp("tests/data/passing-exercise");
491484
let plugin = MakePlugin::new();
492485
let exercise_desc = plugin
493-
.scan_exercise(temp.path(), "test".to_string(), &mut vec![])
486+
.scan_exercise(temp.path(), "test".to_string())
494487
.unwrap();
495488

496489
assert_eq!(exercise_desc.name, "test");
@@ -507,7 +500,7 @@ test [invalid] point6
507500

508501
let temp = dir_to_temp("tests/data/passing-exercise");
509502
let plugin = MakePlugin::new();
510-
let run_result = plugin.run_tests(temp.path(), &mut vec![]).unwrap();
503+
let run_result = plugin.run_tests(temp.path()).unwrap();
511504
assert_eq!(run_result.status, RunStatus::Passed);
512505
let test_results = run_result.test_results;
513506
assert_eq!(test_results.len(), 1);
@@ -528,7 +521,7 @@ test [invalid] point6
528521

529522
let temp = dir_to_temp("tests/data/failing-exercise");
530523
let plugin = MakePlugin::new();
531-
let run_result = plugin.run_tests(temp.path(), &mut vec![]).unwrap();
524+
let run_result = plugin.run_tests(temp.path()).unwrap();
532525
assert_eq!(run_result.status, RunStatus::TestsFailed);
533526
let test_results = &run_result.test_results;
534527
assert_eq!(test_results.len(), 1);
@@ -548,7 +541,7 @@ test [invalid] point6
548541

549542
let temp = dir_to_temp("tests/data/valgrind-failing-exercise");
550543
let plugin = MakePlugin::new();
551-
let run_result = plugin.run_tests(temp.path(), &mut vec![]).unwrap();
544+
let run_result = plugin.run_tests(temp.path()).unwrap();
552545
assert_eq!(run_result.status, RunStatus::TestsFailed);
553546
let test_results = &run_result.test_results;
554547
assert_eq!(test_results.len(), 2);

plugins/notests/src/plugin.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use std::io::{Read, Seek};
66
use std::path::{Path, PathBuf};
77
use std::time::Duration;
88
use tmc_langs_framework::{
9-
anyhow,
109
domain::{ExerciseDesc, RunResult, RunStatus, TestDesc, TestResult},
1110
nom::{self, error::VerboseError, IResult},
1211
zip::ZipArchive,
@@ -38,12 +37,7 @@ impl LanguagePlugin for NoTestsPlugin {
3837
const BLOCK_COMMENT: Option<(&'static str, &'static str)> = None;
3938
type StudentFilePolicy = NoTestsStudentFilePolicy;
4039

41-
fn scan_exercise(
42-
&self,
43-
path: &Path,
44-
exercise_name: String,
45-
_warnings: &mut Vec<anyhow::Error>,
46-
) -> Result<ExerciseDesc, TmcError> {
40+
fn scan_exercise(&self, path: &Path, exercise_name: String) -> Result<ExerciseDesc, TmcError> {
4741
let test_name = format!("{}Test", exercise_name);
4842
Ok(ExerciseDesc {
4943
name: exercise_name,
@@ -58,7 +52,6 @@ impl LanguagePlugin for NoTestsPlugin {
5852
&self,
5953
path: &Path,
6054
_timeout: Option<Duration>,
61-
_warnings: &mut Vec<anyhow::Error>,
6255
) -> Result<RunResult, TmcError> {
6356
Ok(RunResult {
6457
status: RunStatus::Passed,
@@ -159,11 +152,7 @@ no-tests:
159152

160153
let plugin = NoTestsPlugin::new();
161154
let _exercise_desc = plugin
162-
.scan_exercise(
163-
Path::new("/nonexistent path"),
164-
"ex".to_string(),
165-
&mut vec![],
166-
)
155+
.scan_exercise(Path::new("/nonexistent path"), "ex".to_string())
167156
.unwrap();
168157
}
169158

@@ -176,7 +165,6 @@ no-tests:
176165
.run_tests_with_timeout(
177166
Path::new("/nonexistent"),
178167
Some(std::time::Duration::from_nanos(1)),
179-
&mut vec![],
180168
)
181169
.unwrap();
182170
assert_eq!(run_result.status, RunStatus::Passed);

0 commit comments

Comments
 (0)