Struct emjudge_judgecore::run::StandardRunner
source · pub struct StandardRunner {
pub setting: RunSetting,
}
Fields§
§setting: RunSetting
Implementations§
source§impl StandardRunner
impl StandardRunner
sourcepub fn new(setting: &RunSetting) -> Self
pub fn new(setting: &RunSetting) -> Self
Examples found in repository?
examples/test_memorylimit_exceed.rs (line 17)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
fn main() {
let settings = settings::Settings::new();
let compiler = compile::Compiler::new(&settings.compile_setting);
let mut script = vec![];
let input = vec![];
File::open("examples/programs/mle.cpp").unwrap().read_to_end(&mut script).unwrap();
println!("Compiling...");
match compiler.compile(&String::from("C++"), &script) {
compile::CompileResult::OK(executable_script) => {
println!("Finish");
println!("Running...");
let runner = run::StandardRunner::new(&settings::RunSetting{memory_limit_KB: 1024 * 1024, cpu_limit_ms: 1000, dir: settings.run_setting.dir});
println!("{:?}", runner.run(&executable_script, &input));
},
compile::CompileResult::CompileError(result) => {
println!("Compile Error:\n{}", result);
}
compile::CompileResult::NoSuchLanguage => {
println!("Compile Error:\n{}", "No such language");
}
}
}
More examples
examples/test_timelimit_exceed.rs (line 16)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
fn main() {
let settings = settings::Settings::new();
let compiler = compile::Compiler::new(&settings.compile_setting);
let mut script = vec![];
let input = vec![];
File::open("examples/programs/loop.cpp").unwrap().read_to_end(&mut script).unwrap();
println!("Compiling...");
match compiler.compile(&String::from("C++"), &script) {
compile::CompileResult::OK(executable_script) => {
println!("Finish");
println!("Running...");
let runner = run::StandardRunner::new(&settings::RunSetting{memory_limit_KB: 1024 * 1024, cpu_limit_ms: 5000, dir: settings.run_setting.dir});
println!("{:?}", runner.run(&executable_script, &input));
},
compile::CompileResult::CompileError(result) => {
println!("Compile Error:\n{}", result);
}
compile::CompileResult::NoSuchLanguage => {
println!("Compile Error:\n{}", "No such language");
}
}
}
examples/test_helloworld.rs (line 17)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
fn main() {
let settings = settings::Settings::new();
let compiler = compile::Compiler::new(&settings.compile_setting);
let mut script = vec![];
let input = vec![];
File::open("examples/programs/helloworld.cpp").unwrap().read_to_end(&mut script).unwrap();
println!("Compiling...");
match compiler.compile(&String::from("C++"), &script) {
compile::CompileResult::OK(executable_script) => {
println!("Finish");
println!("Running...");
let runner = run::StandardRunner::new(&settings::RunSetting{memory_limit_KB: 1024 * 1024, cpu_limit_ms: 1000, dir:settings.run_setting.dir});
let result = runner.run(&executable_script, &input);
println!("{:?}", result);
if let RunResult::OK(_, result) = result {
println!("output is:{:?}", String::from_utf8_lossy(&result));
}
},
compile::CompileResult::CompileError(result) => {
println!("Compile Error:\n{}", result);
}
compile::CompileResult::NoSuchLanguage => {
println!("Compile Error:\n{}", "No such language");
}
}
}
examples/test_1plusto100.rs (line 9)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
fn main() {
let settings = settings::Settings::new();
let compiler = compile::Compiler::new(&settings.compile_setting);
let runner = run::StandardRunner::new(&RunSetting{memory_limit_KB: 1024 * 1024, cpu_limit_ms: 10000, dir: settings.run_setting.dir.clone()});
let mut eval_script = vec![];
let mut test_out = vec![];
let mut input = vec![];
let mut output = vec![];
File::open("examples/programs/1plusto100/eval.cpp").unwrap().read_to_end(&mut eval_script).unwrap();
File::open("examples/programs/1plusto100/in").unwrap().read_to_end(&mut input).unwrap();
File::open("examples/programs/1plusto100/out").unwrap().read_to_end(&mut output).unwrap();
File::open("examples/programs/1plusto100/testout").unwrap().read_to_end(&mut test_out).unwrap();
println!("Compiling eval...");
let compile_eval = compiler.compile(&String::from("C++"), &eval_script);
println!("Finish");
if let CompileResult::OK(exe_eval) = compile_eval {
println!("Testing...");
let tester = test::AnwserTester::new(&runner, &exe_eval);
println!("Finish: {:?}", tester.single_test(&input, &test_out, &output));
}
}
examples/test_aplusb.rs (line 9)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
fn main() {
let settings = settings::Settings::new();
let compiler = compile::Compiler::new(&settings.compile_setting);
let runner = run::StandardRunner::new(&RunSetting{memory_limit_KB: 1024 * 1024, cpu_limit_ms: 10000, dir: settings.run_setting.dir.clone()});
let mut eval_script = vec![];
let mut test_script = vec![];
let mut input = vec![];
let mut output = vec![];
File::open("examples/programs/aplusb/eval.cpp").unwrap().read_to_end(&mut eval_script).unwrap();
File::open("examples/programs/aplusb/main.cpp").unwrap().read_to_end(&mut test_script).unwrap();
File::open("examples/programs/aplusb/in").unwrap().read_to_end(&mut input).unwrap();
File::open("examples/programs/aplusb/out").unwrap().read_to_end(&mut output).unwrap();
println!("Compiling eval...");
let compile_eval = compiler.compile(&String::from("C++"), &eval_script);
println!("Finish");
if let CompileResult::OK(exe_eval) = compile_eval {
println!("Compiling test...");
let compile_test = compiler.compile(&String::from("C++"), &test_script);
println!("Finish");
if let CompileResult::OK(exe_test) = compile_test {
println!("Testing...");
let tester = test::StandardTester::new(&runner, &runner, &exe_test, &exe_eval);
println!("Finish: {:?}", tester.single_test(&input, &output));
}
}
}
sourcepub fn run(&self, executable_script: &Vec<u8>, input: &Vec<u8>) -> RunResult
pub fn run(&self, executable_script: &Vec<u8>, input: &Vec<u8>) -> RunResult
Examples found in repository?
examples/test_memorylimit_exceed.rs (line 18)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
fn main() {
let settings = settings::Settings::new();
let compiler = compile::Compiler::new(&settings.compile_setting);
let mut script = vec![];
let input = vec![];
File::open("examples/programs/mle.cpp").unwrap().read_to_end(&mut script).unwrap();
println!("Compiling...");
match compiler.compile(&String::from("C++"), &script) {
compile::CompileResult::OK(executable_script) => {
println!("Finish");
println!("Running...");
let runner = run::StandardRunner::new(&settings::RunSetting{memory_limit_KB: 1024 * 1024, cpu_limit_ms: 1000, dir: settings.run_setting.dir});
println!("{:?}", runner.run(&executable_script, &input));
},
compile::CompileResult::CompileError(result) => {
println!("Compile Error:\n{}", result);
}
compile::CompileResult::NoSuchLanguage => {
println!("Compile Error:\n{}", "No such language");
}
}
}
More examples
examples/test_timelimit_exceed.rs (line 17)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
fn main() {
let settings = settings::Settings::new();
let compiler = compile::Compiler::new(&settings.compile_setting);
let mut script = vec![];
let input = vec![];
File::open("examples/programs/loop.cpp").unwrap().read_to_end(&mut script).unwrap();
println!("Compiling...");
match compiler.compile(&String::from("C++"), &script) {
compile::CompileResult::OK(executable_script) => {
println!("Finish");
println!("Running...");
let runner = run::StandardRunner::new(&settings::RunSetting{memory_limit_KB: 1024 * 1024, cpu_limit_ms: 5000, dir: settings.run_setting.dir});
println!("{:?}", runner.run(&executable_script, &input));
},
compile::CompileResult::CompileError(result) => {
println!("Compile Error:\n{}", result);
}
compile::CompileResult::NoSuchLanguage => {
println!("Compile Error:\n{}", "No such language");
}
}
}
examples/test_helloworld.rs (line 18)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
fn main() {
let settings = settings::Settings::new();
let compiler = compile::Compiler::new(&settings.compile_setting);
let mut script = vec![];
let input = vec![];
File::open("examples/programs/helloworld.cpp").unwrap().read_to_end(&mut script).unwrap();
println!("Compiling...");
match compiler.compile(&String::from("C++"), &script) {
compile::CompileResult::OK(executable_script) => {
println!("Finish");
println!("Running...");
let runner = run::StandardRunner::new(&settings::RunSetting{memory_limit_KB: 1024 * 1024, cpu_limit_ms: 1000, dir:settings.run_setting.dir});
let result = runner.run(&executable_script, &input);
println!("{:?}", result);
if let RunResult::OK(_, result) = result {
println!("output is:{:?}", String::from_utf8_lossy(&result));
}
},
compile::CompileResult::CompileError(result) => {
println!("Compile Error:\n{}", result);
}
compile::CompileResult::NoSuchLanguage => {
println!("Compile Error:\n{}", "No such language");
}
}
}
Trait Implementations§
source§impl Clone for StandardRunner
impl Clone for StandardRunner
source§fn clone(&self) -> StandardRunner
fn clone(&self) -> StandardRunner
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for StandardRunner
impl Debug for StandardRunner
source§impl<'de> Deserialize<'de> for StandardRunner
impl<'de> Deserialize<'de> for StandardRunner
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl RefUnwindSafe for StandardRunner
impl Send for StandardRunner
impl Sync for StandardRunner
impl Unpin for StandardRunner
impl UnwindSafe for StandardRunner
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more