tangled
alpha
login
or
join now
bwc9876.dev
/
gh-grader-preview
0
fork
atom
Local runner for GitHub autograder
0
fork
atom
overview
issues
pulls
pipelines
Update v0.4.0
bwc9876.dev
6 months ago
c4da97ef
a3e28a9c
verified
This commit was signed with the committer's
known signature
.
bwc9876.dev
SSH Key Fingerprint:
SHA256:DanMEP/RNlSC7pAVbnXO6wzQV00rqyKj053tz4uH5gQ=
+43
-39
4 changed files
expand all
collapse all
unified
split
Cargo.lock
Cargo.toml
flake.lock
src
grader.rs
+22
-21
Cargo.lock
···
81
82
[[package]]
83
name = "clap"
84
-
version = "4.5.46"
85
source = "registry+https://github.com/rust-lang/crates.io-index"
86
-
checksum = "2c5e4fcf9c21d2e544ca1ee9d8552de13019a42aa7dbf32747fa7aaf1df76e57"
87
dependencies = [
88
"clap_builder",
89
"clap_derive",
···
91
92
[[package]]
93
name = "clap_builder"
94
-
version = "4.5.46"
95
source = "registry+https://github.com/rust-lang/crates.io-index"
96
-
checksum = "fecb53a0e6fcfb055f686001bc2e2592fa527efaf38dbe81a6a9563562e57d41"
97
dependencies = [
98
"anstream",
99
"anstyle",
···
112
113
[[package]]
114
name = "clap_derive"
115
-
version = "4.5.45"
116
source = "registry+https://github.com/rust-lang/crates.io-index"
117
-
checksum = "14cb31bb0a7d536caef2639baa7fad459e15c3144efefa6dbd1c84562c4739f6"
118
dependencies = [
119
"heck",
120
"proc-macro2",
···
165
166
[[package]]
167
name = "gh-grader-preview"
168
-
version = "0.3.0"
169
dependencies = [
170
"anyhow",
171
"clap",
···
212
213
[[package]]
214
name = "js-sys"
215
-
version = "0.3.77"
216
source = "registry+https://github.com/rust-lang/crates.io-index"
217
-
checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f"
218
dependencies = [
219
"once_cell",
220
"wasm-bindgen",
···
228
229
[[package]]
230
name = "log"
231
-
version = "0.4.27"
232
source = "registry+https://github.com/rust-lang/crates.io-index"
233
-
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
234
235
[[package]]
236
name = "memchr"
···
399
400
[[package]]
401
name = "wasm-bindgen"
402
-
version = "0.2.100"
403
source = "registry+https://github.com/rust-lang/crates.io-index"
404
-
checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5"
405
dependencies = [
406
"cfg-if",
407
"once_cell",
408
"wasm-bindgen-macro",
0
409
]
410
411
[[package]]
412
name = "wasm-bindgen-backend"
413
-
version = "0.2.100"
414
source = "registry+https://github.com/rust-lang/crates.io-index"
415
-
checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6"
416
dependencies = [
417
"bumpalo",
418
"log",
···
424
425
[[package]]
426
name = "wasm-bindgen-macro"
427
-
version = "0.2.100"
428
source = "registry+https://github.com/rust-lang/crates.io-index"
429
-
checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407"
430
dependencies = [
431
"quote",
432
"wasm-bindgen-macro-support",
···
434
435
[[package]]
436
name = "wasm-bindgen-macro-support"
437
-
version = "0.2.100"
438
source = "registry+https://github.com/rust-lang/crates.io-index"
439
-
checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
440
dependencies = [
441
"proc-macro2",
442
"quote",
···
447
448
[[package]]
449
name = "wasm-bindgen-shared"
450
-
version = "0.2.100"
451
source = "registry+https://github.com/rust-lang/crates.io-index"
452
-
checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d"
453
dependencies = [
454
"unicode-ident",
455
]
···
81
82
[[package]]
83
name = "clap"
84
+
version = "4.5.47"
85
source = "registry+https://github.com/rust-lang/crates.io-index"
86
+
checksum = "7eac00902d9d136acd712710d71823fb8ac8004ca445a89e73a41d45aa712931"
87
dependencies = [
88
"clap_builder",
89
"clap_derive",
···
91
92
[[package]]
93
name = "clap_builder"
94
+
version = "4.5.47"
95
source = "registry+https://github.com/rust-lang/crates.io-index"
96
+
checksum = "2ad9bbf750e73b5884fb8a211a9424a1906c1e156724260fdae972f31d70e1d6"
97
dependencies = [
98
"anstream",
99
"anstyle",
···
112
113
[[package]]
114
name = "clap_derive"
115
+
version = "4.5.47"
116
source = "registry+https://github.com/rust-lang/crates.io-index"
117
+
checksum = "bbfd7eae0b0f1a6e63d4b13c9c478de77c2eb546fba158ad50b4203dc24b9f9c"
118
dependencies = [
119
"heck",
120
"proc-macro2",
···
165
166
[[package]]
167
name = "gh-grader-preview"
168
+
version = "0.4.0"
169
dependencies = [
170
"anyhow",
171
"clap",
···
212
213
[[package]]
214
name = "js-sys"
215
+
version = "0.3.78"
216
source = "registry+https://github.com/rust-lang/crates.io-index"
217
+
checksum = "0c0b063578492ceec17683ef2f8c5e89121fbd0b172cbc280635ab7567db2738"
218
dependencies = [
219
"once_cell",
220
"wasm-bindgen",
···
228
229
[[package]]
230
name = "log"
231
+
version = "0.4.28"
232
source = "registry+https://github.com/rust-lang/crates.io-index"
233
+
checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
234
235
[[package]]
236
name = "memchr"
···
399
400
[[package]]
401
name = "wasm-bindgen"
402
+
version = "0.2.101"
403
source = "registry+https://github.com/rust-lang/crates.io-index"
404
+
checksum = "7e14915cadd45b529bb8d1f343c4ed0ac1de926144b746e2710f9cd05df6603b"
405
dependencies = [
406
"cfg-if",
407
"once_cell",
408
"wasm-bindgen-macro",
409
+
"wasm-bindgen-shared",
410
]
411
412
[[package]]
413
name = "wasm-bindgen-backend"
414
+
version = "0.2.101"
415
source = "registry+https://github.com/rust-lang/crates.io-index"
416
+
checksum = "e28d1ba982ca7923fd01448d5c30c6864d0a14109560296a162f80f305fb93bb"
417
dependencies = [
418
"bumpalo",
419
"log",
···
425
426
[[package]]
427
name = "wasm-bindgen-macro"
428
+
version = "0.2.101"
429
source = "registry+https://github.com/rust-lang/crates.io-index"
430
+
checksum = "7c3d463ae3eff775b0c45df9da45d68837702ac35af998361e2c84e7c5ec1b0d"
431
dependencies = [
432
"quote",
433
"wasm-bindgen-macro-support",
···
435
436
[[package]]
437
name = "wasm-bindgen-macro-support"
438
+
version = "0.2.101"
439
source = "registry+https://github.com/rust-lang/crates.io-index"
440
+
checksum = "7bb4ce89b08211f923caf51d527662b75bdc9c9c7aab40f86dcb9fb85ac552aa"
441
dependencies = [
442
"proc-macro2",
443
"quote",
···
448
449
[[package]]
450
name = "wasm-bindgen-shared"
451
+
version = "0.2.101"
452
source = "registry+https://github.com/rust-lang/crates.io-index"
453
+
checksum = "f143854a3b13752c6950862c906306adb27c7e839f7414cec8fea35beab624c1"
454
dependencies = [
455
"unicode-ident",
456
]
+1
-1
Cargo.toml
···
1
[package]
2
name = "gh-grader-preview"
3
-
version = "0.3.0"
4
edition = "2024"
5
6
[dependencies]
···
1
[package]
2
name = "gh-grader-preview"
3
+
version = "0.4.0"
4
edition = "2024"
5
6
[dependencies]
+12
-12
flake.lock
···
2
"nodes": {
3
"crane": {
4
"locked": {
5
-
"lastModified": 1755993354,
6
-
"narHash": "sha256-FCRRAzSaL/+umLIm3RU3O/+fJ2ssaPHseI2SSFL8yZU=",
7
"owner": "ipetkov",
8
"repo": "crane",
9
-
"rev": "25bd41b24426c7734278c2ff02e53258851db914",
10
"type": "github"
11
},
12
"original": {
···
22
]
23
},
24
"locked": {
25
-
"lastModified": 1756126213,
26
-
"narHash": "sha256-iSmyMn8r5NJfTWEsp6R/5jmMHrVLnQ/icebYfNP5QnQ=",
27
"owner": "nix-community",
28
"repo": "flakelight",
29
-
"rev": "4415f8e61c770441f01a5b2550da5815aeebe144",
30
"type": "github"
31
},
32
"original": {
···
41
"flakelight": "flakelight"
42
},
43
"locked": {
44
-
"lastModified": 1756212791,
45
-
"narHash": "sha256-90/xH2TwrCluU3ROooeeBYNxpeRqdGDQQptiqZN6FlA=",
46
"owner": "accelbread",
47
"repo": "flakelight-rust",
48
-
"rev": "ce31f0d6c3adea38a4d8011c5e0b55d16888f21e",
49
"type": "github"
50
},
51
"original": {
···
56
},
57
"nixpkgs": {
58
"locked": {
59
-
"lastModified": 1756288264,
60
-
"narHash": "sha256-Om8adB1lfkU7D33VpR+/haZ2gI5r3Q+ZbIPzE5sYnwE=",
61
"owner": "NixOS",
62
"repo": "nixpkgs",
63
-
"rev": "ddd1826f294a0ee5fdc198ab72c8306a0ea73aa9",
64
"type": "github"
65
},
66
"original": {
···
2
"nodes": {
3
"crane": {
4
"locked": {
5
+
"lastModified": 1756705356,
6
+
"narHash": "sha256-dpBFe8SqYKr7W6KN5QOVCr8N76SBKwTslzjw+4BVBVs=",
7
"owner": "ipetkov",
8
"repo": "crane",
9
+
"rev": "305707bbc27d83aa1039378e91d7dd816f4cac10",
10
"type": "github"
11
},
12
"original": {
···
22
]
23
},
24
"locked": {
25
+
"lastModified": 1756730985,
26
+
"narHash": "sha256-Uv5lLUZfFxQv6RHi1TqLTKso0j0eUVMQQwud29LTV/s=",
27
"owner": "nix-community",
28
"repo": "flakelight",
29
+
"rev": "950121d809b75c32e73684b32ccba8d4e8a67703",
30
"type": "github"
31
},
32
"original": {
···
41
"flakelight": "flakelight"
42
},
43
"locked": {
44
+
"lastModified": 1756817437,
45
+
"narHash": "sha256-O8xyYYBJucwHMnqjoaNFEDYPJQ5nzwnuXjPoW2TCvYo=",
46
"owner": "accelbread",
47
"repo": "flakelight-rust",
48
+
"rev": "af3cc6a17c210efb85d99ed3ea601f5d0b55b50f",
49
"type": "github"
50
},
51
"original": {
···
56
},
57
"nixpkgs": {
58
"locked": {
59
+
"lastModified": 1756911493,
60
+
"narHash": "sha256-6n/n1GZQ/vi+LhFXMSyoseKdNfc2QQaSBXJdgamrbkE=",
61
"owner": "NixOS",
62
"repo": "nixpkgs",
63
+
"rev": "c6a788f552b7b7af703b1a29802a7233c0067908",
64
"type": "github"
65
},
66
"original": {
+8
-5
src/grader.rs
···
72
}
73
74
impl TestCase {
75
-
pub fn check_output(&self, output: String) -> Result<bool> {
76
if let Some(ref expected_output) = self.output {
0
0
77
match self.comparison {
78
-
ComparisonType::Included => Ok(output.contains(expected_output)),
79
-
ComparisonType::Excluded => Ok(!output.contains(expected_output)),
80
ComparisonType::Exact => Ok(output.trim() == expected_output.trim()),
81
ComparisonType::Regex => {
82
-
let re = regex::Regex::new(expected_output)?;
83
Ok(re.is_match(&output))
84
}
85
ComparisonType::Pass => Ok(true),
···
94
runner::setup_phase(setup)?;
95
}
96
let res = runner::run_phase(&self.run, &self.input, self.timeout as u64)?;
97
-
let matches = self.check_output(res.stdout.clone())?;
0
98
Ok((matches, res))
99
}
100
}
···
72
}
73
74
impl TestCase {
75
+
fn check_output(&self, output: String) -> Result<bool> {
76
if let Some(ref expected_output) = self.output {
77
+
let expected_output = expected_output.replace("\r\n", "\n");
78
+
79
match self.comparison {
80
+
ComparisonType::Included => Ok(output.contains(&expected_output)),
81
+
ComparisonType::Excluded => Ok(!output.contains(&expected_output)),
82
ComparisonType::Exact => Ok(output.trim() == expected_output.trim()),
83
ComparisonType::Regex => {
84
+
let re = regex::Regex::new(&expected_output)?;
85
Ok(re.is_match(&output))
86
}
87
ComparisonType::Pass => Ok(true),
···
96
runner::setup_phase(setup)?;
97
}
98
let res = runner::run_phase(&self.run, &self.input, self.timeout as u64)?;
99
+
let output = res.stdout.replace("\r\n", "\n");
100
+
let matches = self.check_output(output)?;
101
Ok((matches, res))
102
}
103
}