Skip to content

Commit

Permalink
Remove unused ignore-count-ignores (#1968)
Browse files Browse the repository at this point in the history
After having removed all macro-based testing, this is no longer needed.
  • Loading branch information
senekor authored Aug 15, 2024
1 parent bbd6958 commit e8e0aab
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 47 deletions.
10 changes: 0 additions & 10 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,6 @@ If there is a justified reason why this is not possible,
include a `.custom."allowed-to-not-compile"` key
in the exercise's `.meta/config.json` containing the reason.

If your exercise implements macro-based testing
(e.g. [`xorcism`](/exercises/practice/xorcism/tests/xorcism.rs)),
you will likely run afoul of a CI check which counts the `#[ignore]` lines
and compares the result to the number of `#[test]` lines.
To fix this, add a marker to the exercise's `.meta/config.json`:
`.custom."ignore-count-ignores"` should be `true`
to disable that check for your exercise.
However, tera templates should generally be preferred to generate many similar test cases.
See [issue #1824](https://github.com/exercism/rust/issues/1824) for the reasoning.

## Updating an exercise

Many exercises are derived from [`problem-specifications`].
Expand Down
5 changes: 1 addition & 4 deletions exercises/practice/paasio/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,5 @@
},
"blurb": "Report network IO statistics.",
"source": "Brian Matsuo",
"source_url": "https://github.com/bmatsuo",
"custom": {
"ignore-count-ignores": true
}
"source_url": "https://github.com/bmatsuo"
}
3 changes: 1 addition & 2 deletions exercises/practice/xorcism/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"blurb": "Implement zero-copy streaming adaptors",
"source": "Peter Goodspeed-Niklaus",
"custom": {
"allowed-to-not-compile": "The point of this exercise is for students to figure out the appropriate function signatures and generic bounds for their implementations, so we cannot provide those.",
"ignore-count-ignores": true
"allowed-to-not-compile": "The point of this exercise is for students to figure out the appropriate function signatures and generic bounds for their implementations, so we cannot provide those."
}
}
41 changes: 12 additions & 29 deletions rust-tooling/ci-tests/tests/count_ignores.rs
Original file line number Diff line number Diff line change
@@ -1,34 +1,17 @@
use models::exercise_config::{
get_all_concept_exercise_paths, get_all_practice_exercise_paths, PracticeExercise,
};

fn assert_one_less_ignore_than_tests(path: &str) {
let slug = path.split('/').last().unwrap();
let test_path = format!("{path}/tests/{slug}.rs");
let test_contents = std::fs::read_to_string(test_path).unwrap();
let num_tests = test_contents.matches("#[test]").count();
let num_ignores = test_contents.matches("#[ignore]").count();
assert_eq!(
num_tests,
num_ignores + 1,
"should have one more test than ignore in {slug}"
)
}
use models::exercise_config::get_all_exercise_paths;

#[test]
fn count_ignores() {
for path in get_all_concept_exercise_paths() {
assert_one_less_ignore_than_tests(&path);
}
for path in get_all_practice_exercise_paths() {
let config_path = format!("{path}/.meta/config.json");
let config_contents = std::fs::read_to_string(config_path).unwrap();
let config: PracticeExercise = serde_json::from_str(config_contents.as_str()).unwrap();
if let Some(custom) = config.custom {
if custom.ignore_count_ignores.unwrap_or_default() {
continue;
}
}
assert_one_less_ignore_than_tests(&path);
for path in get_all_exercise_paths() {
let slug = path.split('/').last().unwrap();
let test_path = format!("{path}/tests/{slug}.rs");
let test_contents = std::fs::read_to_string(test_path).unwrap();
let num_tests = test_contents.matches("#[test]").count();
let num_ignores = test_contents.matches("#[ignore]").count();
assert_eq!(
num_tests,
num_ignores + 1,
"should have one more test than ignore in {slug}"
)
}
}
2 changes: 0 additions & 2 deletions rust-tooling/models/src/exercise_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ pub struct Custom {
pub allowed_to_not_compile: Option<String>,
#[serde(rename = "test-in-release-mode")]
pub test_in_release_mode: Option<bool>,
#[serde(rename = "ignore-count-ignores")]
pub ignore_count_ignores: Option<bool>,
}

pub fn get_all_concept_exercise_paths() -> impl Iterator<Item = String> {
Expand Down

0 comments on commit e8e0aab

Please sign in to comment.