-
Notifications
You must be signed in to change notification settings - Fork 523
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test to ensure tera templates are in sync (#1879)
closes #1878
- Loading branch information
Showing
8 changed files
with
89 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use queen_attack::{ChessPiece, ChessPosition, Queen}; | ||
use queen_attack::*; | ||
|
||
{% for test in cases %} | ||
#[test] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[ | ||
{ | ||
"uuid": "88bf4b28-0de3-4883-93c7-db1b14aa806e", | ||
"description": "exponential", | ||
"comments": [ | ||
"This test case was added a long time ago.", | ||
"Upstreaming it would make the exercise more difficult." | ||
], | ||
"property": "exponentials", | ||
"input": { | ||
"question": "What is 2 raised to the 5th power?" | ||
}, | ||
"expected": 32 | ||
}, | ||
{ | ||
"uuid": "bb8c655c-cf42-4dfc-90e0-152fcfd8d4e0", | ||
"description": "addition and exponential", | ||
"comments": [ | ||
"This test case was added a long time ago.", | ||
"Upstreaming it would make the exercise more difficult." | ||
], | ||
"property": "exponentials", | ||
"input": { | ||
"question": "What is 1 plus 2 raised to the 2nd power?" | ||
}, | ||
"expected": 9 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//! This test is not run in CI. Doing so would slow down CI noticeably, because | ||
//! exercise generation depends on `tera`, which takes a while to compile. | ||
use glob::glob; | ||
use utils::fs::cd_into_repo_root; | ||
|
||
#[test] | ||
fn tera_templates_are_in_sync() { | ||
cd_into_repo_root(); | ||
for entry in glob("exercises/*/*/.meta/test_template.tera").unwrap() { | ||
let path = entry.unwrap(); | ||
let exercise_dir = path.parent().unwrap().parent().unwrap(); | ||
let slug = exercise_dir.file_name().unwrap().to_string_lossy(); | ||
|
||
let fn_names = generate::read_fn_names_from_lib_rs(&slug); | ||
let generated = generate::new(&slug, fn_names); | ||
|
||
let test_path = exercise_dir.join("tests").join(format!("{slug}.rs")); | ||
let on_disk = std::fs::read_to_string(test_path).unwrap(); | ||
|
||
assert_eq!(generated.tests, on_disk); | ||
} | ||
} |