Skip to content

Commit a31d3e1

Browse files
committed
Hold a class judge to the name its starters define
The harness instantiates the judge's class name and the candidate defines it in their starter, but the two are produced from different files: the judge is renamed out of the bank, the starters are rewritten from the variant. A rename that reached one and not the other compiled to a missing symbol on the candidate's first run, and nothing compared them.
1 parent e1d1a31 commit a31d3e1

1 file changed

Lines changed: 22 additions & 6 deletions

File tree

‎tests/web.rs‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,12 +1539,28 @@ fn static_problem_bank_and_judges_cover_each_problem() {
15391539
);
15401540
}
15411541
if spec["kind"] == "class" {
1542-
assert!(
1543-
spec["className"]
1544-
.as_str()
1545-
.is_some_and(|name| !name.is_empty()),
1546-
"missing class name for {id}"
1547-
);
1542+
let class_name = spec["className"]
1543+
.as_str()
1544+
.filter(|name| !name.is_empty())
1545+
.unwrap_or_else(|| panic!("missing class name for {id}"));
1546+
1547+
// The harness instantiates this name and the candidate defines it,
1548+
// and the two come from different files: the judge is renamed from
1549+
// the bank while the starters are rewritten from the variant. A
1550+
// rename that reached one and not the other would compile to a
1551+
// missing symbol on the candidate's first run, which is the worst
1552+
// place to find out.
1553+
for (language, starter) in problem["starterCode"]
1554+
.as_object()
1555+
.unwrap_or_else(|| panic!("starterCode must be an object for {id}"))
1556+
{
1557+
assert!(
1558+
starter
1559+
.as_str()
1560+
.is_some_and(|code| code.contains(class_name)),
1561+
"{id}: the {language} starter does not define {class_name}"
1562+
);
1563+
}
15481564
}
15491565
if spec["kind"] == "function" {
15501566
let param_names = spec["paramNames"]

0 commit comments

Comments
 (0)