Local runner for GitHub autograder
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add Windows Support

Ben C 3bcd98c1 27af3331

+21 -10
+2 -2
Cargo.lock
··· 192 192 193 193 [[package]] 194 194 name = "libc" 195 - version = "0.2.152" 195 + version = "0.2.153" 196 196 source = "registry+https://github.com/rust-lang/crates.io-index" 197 - checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" 197 + checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" 198 198 199 199 [[package]] 200 200 name = "memchr"
+3 -2
README.md
··· 2 2 3 3 Simple program that runs test cases specified in an autograding.json file and reports results. Useful for previewing how GitHub will run your autograder and project. 4 4 5 - This will only work on Linux as it uses `bash`. Also most GitHub auto-graders runs on the Ubuntu runner image so the commands 6 - are gonna be Linux specific anyway. 5 + > [!INFO] 6 + > While this works on Windows, the GitHub classroom runner uses Linux by default, and so some professors may write commands 7 + > specific to Linux meaning they won't work for you. 7 8 8 9 ## Usage 9 10
+16 -6
src/runner.rs
··· 7 7 use anyhow::{anyhow, Result}; 8 8 use wait_timeout::ChildExt; 9 9 10 + #[cfg(not(windows))] 11 + fn spawn_cmd(cmd: &str) -> Command { 12 + let mut command = Command::new("bash"); 13 + command.arg("-c").arg(cmd); 14 + command 15 + } 16 + 17 + #[cfg(windows)] 18 + fn spawn_cmd(cmd: &str) -> Command { 19 + let mut command = Command::new("PowerShell"); 20 + command.arg("-Command").arg(cmd); 21 + command 22 + } 23 + 10 24 pub fn setup_phase(cmd: &str) -> Result<()> { 11 - let mut child = Command::new("bash") 12 - .arg("-c") 13 - .arg(cmd) 25 + let mut child = spawn_cmd(cmd) 14 26 .spawn() 15 27 .map_err(|e| anyhow!("Failed to spawn shell: {e:?}"))?; 16 28 ··· 39 51 } 40 52 41 53 pub fn run_phase(cmd: &str, input: &str, timeout: u64) -> Result<TestResult> { 42 - let mut child = Command::new("bash") 43 - .arg("-c") 44 - .arg(cmd) 54 + let mut child = spawn_cmd(cmd) 45 55 .stdin(Stdio::piped()) 46 56 .stdout(Stdio::piped()) 47 57 .stderr(Stdio::piped())