diff --git a/Cargo.lock b/Cargo.lock index ed233cf..310a74a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -81,9 +81,9 @@ checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" [[package]] name = "clap" -version = "4.5.46" +version = "4.5.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c5e4fcf9c21d2e544ca1ee9d8552de13019a42aa7dbf32747fa7aaf1df76e57" +checksum = "7eac00902d9d136acd712710d71823fb8ac8004ca445a89e73a41d45aa712931" dependencies = [ "clap_builder", "clap_derive", @@ -91,9 +91,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.46" +version = "4.5.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fecb53a0e6fcfb055f686001bc2e2592fa527efaf38dbe81a6a9563562e57d41" +checksum = "2ad9bbf750e73b5884fb8a211a9424a1906c1e156724260fdae972f31d70e1d6" dependencies = [ "anstream", "anstyle", @@ -112,9 +112,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.45" +version = "4.5.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14cb31bb0a7d536caef2639baa7fad459e15c3144efefa6dbd1c84562c4739f6" +checksum = "bbfd7eae0b0f1a6e63d4b13c9c478de77c2eb546fba158ad50b4203dc24b9f9c" dependencies = [ "heck", "proc-macro2", @@ -165,7 +165,7 @@ checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" [[package]] name = "gh-grader-preview" -version = "0.3.0" +version = "0.4.0" dependencies = [ "anyhow", "clap", @@ -212,9 +212,9 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "js-sys" -version = "0.3.77" +version = "0.3.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +checksum = "0c0b063578492ceec17683ef2f8c5e89121fbd0b172cbc280635ab7567db2738" dependencies = [ "once_cell", "wasm-bindgen", @@ -228,9 +228,9 @@ checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543" [[package]] name = "log" -version = "0.4.27" +version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" +checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" [[package]] name = "memchr" @@ -399,20 +399,21 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.100" +version = "0.2.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +checksum = "7e14915cadd45b529bb8d1f343c4ed0ac1de926144b746e2710f9cd05df6603b" dependencies = [ "cfg-if", "once_cell", "wasm-bindgen-macro", + "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.100" +version = "0.2.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +checksum = "e28d1ba982ca7923fd01448d5c30c6864d0a14109560296a162f80f305fb93bb" dependencies = [ "bumpalo", "log", @@ -424,9 +425,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.100" +version = "0.2.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +checksum = "7c3d463ae3eff775b0c45df9da45d68837702ac35af998361e2c84e7c5ec1b0d" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -434,9 +435,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.100" +version = "0.2.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +checksum = "7bb4ce89b08211f923caf51d527662b75bdc9c9c7aab40f86dcb9fb85ac552aa" dependencies = [ "proc-macro2", "quote", @@ -447,9 +448,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.100" +version = "0.2.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +checksum = "f143854a3b13752c6950862c906306adb27c7e839f7414cec8fea35beab624c1" dependencies = [ "unicode-ident", ] diff --git a/Cargo.toml b/Cargo.toml index 368d123..b52d63b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gh-grader-preview" -version = "0.3.0" +version = "0.4.0" edition = "2024" [dependencies] diff --git a/flake.lock b/flake.lock index 7f5bde3..b9cecae 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "crane": { "locked": { - "lastModified": 1755993354, - "narHash": "sha256-FCRRAzSaL/+umLIm3RU3O/+fJ2ssaPHseI2SSFL8yZU=", + "lastModified": 1756705356, + "narHash": "sha256-dpBFe8SqYKr7W6KN5QOVCr8N76SBKwTslzjw+4BVBVs=", "owner": "ipetkov", "repo": "crane", - "rev": "25bd41b24426c7734278c2ff02e53258851db914", + "rev": "305707bbc27d83aa1039378e91d7dd816f4cac10", "type": "github" }, "original": { @@ -22,11 +22,11 @@ ] }, "locked": { - "lastModified": 1756126213, - "narHash": "sha256-iSmyMn8r5NJfTWEsp6R/5jmMHrVLnQ/icebYfNP5QnQ=", + "lastModified": 1756730985, + "narHash": "sha256-Uv5lLUZfFxQv6RHi1TqLTKso0j0eUVMQQwud29LTV/s=", "owner": "nix-community", "repo": "flakelight", - "rev": "4415f8e61c770441f01a5b2550da5815aeebe144", + "rev": "950121d809b75c32e73684b32ccba8d4e8a67703", "type": "github" }, "original": { @@ -41,11 +41,11 @@ "flakelight": "flakelight" }, "locked": { - "lastModified": 1756212791, - "narHash": "sha256-90/xH2TwrCluU3ROooeeBYNxpeRqdGDQQptiqZN6FlA=", + "lastModified": 1756817437, + "narHash": "sha256-O8xyYYBJucwHMnqjoaNFEDYPJQ5nzwnuXjPoW2TCvYo=", "owner": "accelbread", "repo": "flakelight-rust", - "rev": "ce31f0d6c3adea38a4d8011c5e0b55d16888f21e", + "rev": "af3cc6a17c210efb85d99ed3ea601f5d0b55b50f", "type": "github" }, "original": { @@ -56,11 +56,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1756288264, - "narHash": "sha256-Om8adB1lfkU7D33VpR+/haZ2gI5r3Q+ZbIPzE5sYnwE=", + "lastModified": 1756911493, + "narHash": "sha256-6n/n1GZQ/vi+LhFXMSyoseKdNfc2QQaSBXJdgamrbkE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ddd1826f294a0ee5fdc198ab72c8306a0ea73aa9", + "rev": "c6a788f552b7b7af703b1a29802a7233c0067908", "type": "github" }, "original": { diff --git a/src/grader.rs b/src/grader.rs index 9fb7081..d990748 100644 --- a/src/grader.rs +++ b/src/grader.rs @@ -72,14 +72,16 @@ impl AutoGraderData { } impl TestCase { - pub fn check_output(&self, output: String) -> Result { + fn check_output(&self, output: String) -> Result { if let Some(ref expected_output) = self.output { + let expected_output = expected_output.replace("\r\n", "\n"); + match self.comparison { - ComparisonType::Included => Ok(output.contains(expected_output)), - ComparisonType::Excluded => Ok(!output.contains(expected_output)), + ComparisonType::Included => Ok(output.contains(&expected_output)), + ComparisonType::Excluded => Ok(!output.contains(&expected_output)), ComparisonType::Exact => Ok(output.trim() == expected_output.trim()), ComparisonType::Regex => { - let re = regex::Regex::new(expected_output)?; + let re = regex::Regex::new(&expected_output)?; Ok(re.is_match(&output)) } ComparisonType::Pass => Ok(true), @@ -94,7 +96,8 @@ impl TestCase { runner::setup_phase(setup)?; } let res = runner::run_phase(&self.run, &self.input, self.timeout as u64)?; - let matches = self.check_output(res.stdout.clone())?; + let output = res.stdout.replace("\r\n", "\n"); + let matches = self.check_output(output)?; Ok((matches, res)) } }