Skip to content

Commit

Permalink
try to fix compile error
Browse files Browse the repository at this point in the history
  • Loading branch information
Zztrans committed Mar 28, 2024
1 parent 5b43c1e commit 2f00b9f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
2 changes: 1 addition & 1 deletion judge-core/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl Compiler {
} else {
let error_output = String::from_utf8_lossy(&output.stderr).to_string();
log::error!("Compile error: {}", error_output);
Err(JudgeCoreError::AnyhowError(anyhow!(error_output)))
Err(JudgeCoreError::CompileError(error_output))
}
}
}
1 change: 1 addition & 0 deletions judge-core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub enum JudgeCoreError {
SerdeJsonError(serde_json::Error),
AnyhowError(anyhow::Error),
FromUtf8Error(FromUtf8Error),
CompileError(String),
}

impl From<Errno> for JudgeCoreError {
Expand Down
5 changes: 3 additions & 2 deletions judge-core/src/judge/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{fmt, ops::Add, time::Duration};

use super::JudgeConfig;

#[derive(Debug, Serialize)]
#[derive(Debug, Serialize, Clone)]
pub struct JudgeResultInfo {
pub verdict: JudgeVerdict,
pub time_usage: Duration,
Expand All @@ -14,7 +14,7 @@ pub struct JudgeResultInfo {
pub checker_exit_status: i32,
}

#[derive(Debug, PartialEq, Serialize)]
#[derive(Debug, PartialEq, Serialize, Clone)]
pub enum JudgeVerdict {
Accepted,
WrongAnswer,
Expand All @@ -23,6 +23,7 @@ pub enum JudgeVerdict {
RuntimeError,
PartialScore,
SystemError,
CompileError,
}

impl fmt::Display for JudgeVerdict {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <iostream>

using namespace std;

int main() {
ojlab
string s;
cin >> s;
cout << "Hello! " << s << endl;
}
18 changes: 16 additions & 2 deletions judger/src/worker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ use crate::agent::platform::{JudgeTask, PlatformClient};
use crate::agent::rclone::RcloneClient;
use crate::handler::state;
use anyhow::Error;
use judge_core::error::JudgeCoreError;
use judge_core::judge;
use judge_core::judge::result::JudgeVerdict;
use judge_core::{
judge::builder::{JudgeBuilder, JudgeBuilderInput},
judge::result::JudgeResultInfo,
Expand Down Expand Up @@ -109,9 +111,21 @@ impl JudgeWorker {
})
.map_err(|e| {
state::set_idle();
anyhow::anyhow!("Failed to new builder result: {:?}", e)
if let JudgeCoreError::CompileError(_) = e {
return Ok(vec![
JudgeResultInfo {
verdict: JudgeVerdict::CompileError,
time_usage: Duration::new(0, 0),
memory_usage_bytes: -1,
exit_status: -1,
checker_exit_status: -1,
};
1
]);
}
Err(anyhow::anyhow!("Failed to new builder result: {:?}", e))
});
let builder = new_builder_result?;
let builder = new_builder_result.expect("builder creater error");
log::debug!("Builder created: {:?}", builder);
let mut results: Vec<JudgeResultInfo> = vec![];
for idx in 0..builder.testdata_configs.len() {
Expand Down

0 comments on commit 2f00b9f

Please sign in to comment.