Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce documentation of additional tests #1817

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
{
"uuid": "46dc5c50-5538-401d-93a5-41102680d068",
"description": "encode wide characters",
"comments": [
"Unicode tests are not suitable to be upstreamed.",
"Handling unicode is tedious in many languages."
],
"property": "encode",
"input": {
"msg": "古池蛙飛び込む水の音",
Expand Down
8 changes: 8 additions & 0 deletions exercises/practice/reverse-string/.meta/additional-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
{
"uuid": "01ebf55b-bebb-414e-9dec-06f7bb0bee3c",
"description": "wide characters",
"comments": [
"Unicode tests are not suitable to be upstreamed.",
"Handling unicode is tedious in many languages."
],
"property": "reverse",
"input": {
"value": "子猫"
Expand All @@ -11,6 +15,10 @@
{
"uuid": "01ebf55b-bebb-414e-9dec-06f7bb0bee3c",
"description": "grapheme clusters",
"comments": [
"Unicode tests are not suitable to be upstreamed.",
"Handling unicode is tedious in many languages."
],
"property": "grapheme",
"input": {
"value": "uüu"
Expand Down
16 changes: 16 additions & 0 deletions exercises/practice/rna-transcription/.meta/additional-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
{
"uuid": "6eedbb5c-12cb-4c8b-9f51-f8320b4dc2e7",
"description": "Invalid DNA input",
"comments": [
"Upstream does not focus on error handling,",
"but this is a big focus for Rust."
],
"property": "invalidDna",
"input": {
"dna": "U"
Expand All @@ -11,6 +15,10 @@
{
"uuid": "6eedbb5c-12cb-4c8b-9f51-f8320b4dc2e7",
"description": "Invalid DNA input at offset",
"comments": [
"Upstream does not focus on error handling,",
"but this is a big focus for Rust."
],
"property": "invalidDna",
"input": {
"dna": "ACGTUXXCTTAA"
Expand All @@ -20,6 +28,10 @@
{
"uuid": "6eedbb5c-12cb-4c8b-9f51-f8320b4dc2e7",
"description": "Invalid RNA input",
"comments": [
"Upstream does not focus on error handling,",
"but this is a big focus for Rust."
],
"property": "invalidRna",
"input": {
"dna": "T"
Expand All @@ -29,6 +41,10 @@
{
"uuid": "6eedbb5c-12cb-4c8b-9f51-f8320b4dc2e7",
"description": "Invalid RNA input at offset",
"comments": [
"Upstream does not focus on error handling,",
"but this is a big focus for Rust."
],
"property": "invalidRna",
"input": {
"dna": "ACGTUXXCTTAA"
Expand Down
10 changes: 10 additions & 0 deletions exercises/practice/say/.meta/additional-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
{
"uuid": "ecafab60-89f2-4680-9286-56b423e8a7b9",
"description": "max i64",
"comments": [
"Idiomatic Rust emphasizes the principle",
"'Make invalid states impossible to represent'.",
"So it is appropriate to test the entire range of possible inputs."
],
"property": "say",
"input": {
"number": 9223372036854775807
Expand All @@ -11,6 +16,11 @@
{
"uuid": "88808dac-dffb-46a6-95d4-68d5271a9c38",
"description": "max u64",
"comments": [
"Idiomatic Rust emphasizes the principle",
"'Make invalid states impossible to represent'.",
"So it is appropriate to test the entire range of possible inputs."
],
"property": "say",
"input": {
"number": 18446744073709551615
Expand Down
8 changes: 8 additions & 0 deletions exercises/practice/scrabble-score/.meta/additional-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
{
"uuid": "9e0faee7-dc23-460b-afec-17c7145ae564",
"description": "non english scrabble letters do not score",
"comments": [
"Unicode tests are not suitable to be upstreamed.",
"Handling unicode is tedious in many languages."
],
"property": "score",
"input": {
"word": "piñata"
Expand All @@ -11,6 +15,10 @@
{
"uuid": "3099e8fd-0077-4520-be33-54bb9a1c0dc7",
"description": "german letters do not score",
"comments": [
"Unicode tests are not suitable to be upstreamed.",
"Handling unicode is tedious in many languages."
],
"property": "score",
"input": {
"word": "STRAßE"
Expand Down
1 change: 1 addition & 0 deletions rust-tooling/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rust-tooling/ci-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ description = "Tests to be run in CI to make sure the repo is in good shape"
# Be considerate when adding dependencies to keep compile times reasonable.
[dependencies]
convert_case = "0.6.0"
glob = "0.3.1"
ignore = "0.4.20"
models = { version = "0.1.0", path = "../models" }
serde_json = "1.0.108"
Expand Down
22 changes: 22 additions & 0 deletions rust-tooling/ci-tests/tests/additional_tests_are_documented.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use glob::glob;
use models::problem_spec::SingleTestCase;
use utils::fs::cd_into_repo_root;

#[test]
fn additional_tests_are_documented() {
cd_into_repo_root();
for entry in glob("exercises/*/*/.meta/additional-tests.json").unwrap() {
let path = entry.unwrap();
let f = std::fs::File::open(&path).unwrap();
let reader = std::io::BufReader::new(f);
let test_cases: Vec<SingleTestCase> = serde_json::from_reader(reader).unwrap();

for case in test_cases {
assert!(
!case.comments.unwrap_or_default().is_empty(),
"missing documentation for additional tests in {}",
path.display()
);
}
}
}