Skip to content

Commit

Permalink
skip tools.jar in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Heliozoa committed Jul 9, 2020
1 parent 728c216 commit 6d74522
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 38 deletions.
4 changes: 2 additions & 2 deletions tmc-langs-abstraction/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub enum Strategy {
Disabled,
}

#[derive(Debug, Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct ValidationError {
pub column: usize,
Expand All @@ -21,7 +21,7 @@ pub struct ValidationError {
pub source_name: String,
}

#[derive(Debug, Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct ValidationResult {
pub strategy: Strategy,
Expand Down
4 changes: 2 additions & 2 deletions tmc-langs-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ fn write_result_to_file_as_json<T: Serialize>(result: &T, output_path: &Path) {
.exit()
});

serde_json::to_writer(output_file, result).unwrap_or_else(|e| {
serde_json::to_writer_pretty(output_file, result).unwrap_or_else(|e| {
Error::with_description(
&format!(
"Failed to write result as JSON to {}: {}",
Expand Down Expand Up @@ -935,7 +935,7 @@ fn run_checkstyle(exercise_path: &Path, output_path: &Path, locale: Language) {
)
.exit()
});
serde_json::to_writer(output_file, &check_result).unwrap_or_else(|e| {
serde_json::to_writer_pretty(output_file, &check_result).unwrap_or_else(|e| {
Error::with_description(
&format!(
"Failed to write check results as JSON to {}: {}",
Expand Down
2 changes: 1 addition & 1 deletion tmc-langs-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ pub use response::{
User,
};
pub use tmc_core::TmcCore;
pub use tmc_langs_util::{Language, RunResult, ValidationResult};
pub use tmc_langs_util::{Language, RunResult, Strategy, ValidationResult};
3 changes: 2 additions & 1 deletion tmc-langs-core/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use serde::{
use std::fmt;
use std::str::FromStr;
use thiserror::Error;
use tmc_langs_util::ValidationResult;

/// Models the responses from tmc-server, which can either
/// be some successful response, a single error or a list of errors
Expand Down Expand Up @@ -332,7 +333,7 @@ pub struct SubmissionFinished {
pub feedback_questions: Option<Vec<SubmissionFeedbackQuestion>>,
pub feedback_answer_url: Option<String>,
pub error: Option<String>,
// validations: unknown;
pub validations: Option<ValidationResult>,
}

#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)]
Expand Down
2 changes: 1 addition & 1 deletion tmc-langs-framework/src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub struct TestResult {
pub points: Vec<String>,
pub message: String,
#[serde(default)]
pub exceptions: Vec<String>,
pub exception: Vec<String>,
}

/// A description of an exercise.
Expand Down
19 changes: 10 additions & 9 deletions tmc-langs-java/src/ant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ use walkdir::WalkDir;

const BUILD_FILE_NAME: &str = "build.xml";

const JUNIT_RUNNER_ARCHIVE: &[u8] = include_bytes!("../jars/tmc-junit-runner-0.2.8.jar");

pub struct AntPlugin {
jvm: Jvm,
}
Expand Down Expand Up @@ -49,21 +51,18 @@ impl AntPlugin {
fn copy_tmc_junit_runner(&self, path: &Path) -> Result<(), JavaError> {
log::debug!("Copying TMC Junit runner");

let local_tmc_junit_runner = Path::new("./jars/tmc-junit-runner-0.2.8.jar");
let runner_dir = path.join("lib").join("testrunner");
let runner_path = runner_dir.join("tmc-junit-runner.jar");

// TODO: don't traverse symlinks
if !runner_path.exists() {
fs::create_dir_all(&runner_dir).map_err(|e| JavaError::Dir(runner_dir, e))?;
log::debug!(
"copying from {} to {}",
local_tmc_junit_runner.display(),
runner_path.display()
);
fs::copy(local_tmc_junit_runner, &runner_path).map_err(|e| {
JavaError::FileCopy(local_tmc_junit_runner.to_path_buf(), runner_path, e)
})?;
log::debug!("writing tmc-junit-runner to {}", runner_path.display());
let mut target_file =
File::create(&runner_path).map_err(|e| JavaError::File(runner_path, e))?;
target_file
.write_all(JUNIT_RUNNER_ARCHIVE)
.map_err(|_| JavaError::JarWrite("tmc-junit-runner".to_string()))?;
} else {
log::debug!("already exists");
}
Expand Down Expand Up @@ -353,11 +352,13 @@ mod test {
"Classpath {} did not contain build/test/classes",
cp
);
/*
assert!(
cp.ends_with(&format!("{0}..{0}lib{0}tools.jar", sep)),
"Classpath was {}",
cp
);
*/
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion tmc-langs-java/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub(crate) trait JavaPlugin: LanguagePlugin {
successful,
points,
message,
exceptions,
exception: exceptions,
}
}

Expand Down
2 changes: 1 addition & 1 deletion tmc-langs-make/src/check_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl CheckLog {
successful,
points,
message: test.message,
exceptions,
exception: exceptions,
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions tmc-langs-make/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ impl LanguagePlugin for MakePlugin {
if test_result.successful {
test_result.message += " - Failed due to errors in valgrind log; see log below. Try submitting to server, some leaks might be platform dependent";
}
test_result.exceptions.extend(valgrind_result.log);
test_result.exception.extend(valgrind_result.log);
}
}
}
Expand Down Expand Up @@ -340,7 +340,7 @@ mod test {
assert_eq!(test_result.name, "test_one");
assert!(test_result.successful);
assert_eq!(test_result.message, "Passed");
assert!(test_result.exceptions.is_empty());
assert!(test_result.exception.is_empty());
let points = &test_result.points;
assert_eq!(points.len(), 1);
let point = &points[0];
Expand Down
2 changes: 1 addition & 1 deletion tmc-langs-notests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl LanguagePlugin for NoTestsPlugin {
successful: true,
points: self.get_points(path),
message: "".to_string(),
exceptions: vec![],
exception: vec![],
}],
logs: HashMap::new(),
})
Expand Down
2 changes: 1 addition & 1 deletion tmc-langs-python3/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl PythonTestResult {
successful: self.passed,
message: self.message,
points: self.points,
exceptions: self.exceptions,
exception: self.exceptions,
}
}
}
6 changes: 3 additions & 3 deletions tmc-langs-python3/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ mod test {
assert!(run_result.test_results[0].points.contains(&"2.2".into()));
assert_eq!(run_result.test_results[0].points.len(), 3);
assert!(run_result.test_results[0].message.is_empty());
assert!(run_result.test_results[0].exceptions.is_empty());
assert!(run_result.test_results[0].exception.is_empty());
assert_eq!(run_result.test_results.len(), 1);
assert!(run_result.logs.is_empty());

Expand All @@ -263,7 +263,7 @@ mod test {
assert!(run_result.test_results[0].points.contains(&"1.2".into()));
assert!(run_result.test_results[0].points.contains(&"2.2".into()));
assert!(run_result.test_results[0].message.starts_with("'a' != 'b'"));
assert!(run_result.test_results[0].exceptions.is_empty());
assert!(run_result.test_results[0].exception.is_empty());
assert_eq!(run_result.test_results.len(), 1);
assert!(run_result.logs.is_empty());

Expand All @@ -282,7 +282,7 @@ mod test {
run_result.test_results[0].message,
"name 'doSomethingIllegal' is not defined"
);
assert!(run_result.test_results[0].exceptions.is_empty());
assert!(run_result.test_results[0].exception.is_empty());
assert_eq!(run_result.test_results.len(), 1);
assert!(run_result.logs.is_empty());
}
Expand Down
20 changes: 8 additions & 12 deletions tmc-langs-r/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@ impl From<RRunResult> for RunResult {
.collect(),
);
}
let mut status = RunStatus::Passed;
for test_result in &r_run_result.test_results {
if test_result.status != RTestStatus::Pass {
status = RunStatus::TestsFailed;
}
}
RunResult {
status: r_run_result.run_status.into(),
status,
test_results: r_run_result
.test_results
.into_iter()
Expand All @@ -53,16 +59,6 @@ enum RRunStatus {
SourcingFailed,
}

impl From<RRunStatus> for RunStatus {
fn from(r_run_status: RRunStatus) -> RunStatus {
match r_run_status {
RRunStatus::Success => RunStatus::Passed,
RRunStatus::RunFailed => RunStatus::TestsFailed,
RRunStatus::SourcingFailed => RunStatus::GenericError,
}
}
}

#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
struct RTestResult {
Expand All @@ -80,7 +76,7 @@ impl From<RTestResult> for TestResult {
successful: r_test_result.status == RTestStatus::Pass,
points: r_test_result.points,
message: r_test_result.message,
exceptions: r_test_result.backtrace,
exception: r_test_result.backtrace,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tmc-langs-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
mod tar;
pub mod task_executor;

pub use tmc_langs_abstraction::ValidationResult;
pub use tmc_langs_abstraction::{Strategy, ValidationResult};
pub use tmc_langs_framework::{
domain::{ExerciseDesc, ExercisePackagingConfiguration, RunResult, RunStatus},
plugin::Language,
Expand Down

0 comments on commit 6d74522

Please sign in to comment.