-
Notifications
You must be signed in to change notification settings - Fork 544
Added ignore/tests counter #363
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff, good stuff. I don't need you to fix any of the comments I made since I'm doing them in #361, but I have made them for your reference
@@ -0,0 +1,40 @@ | |||
current_dir=$(pwd) | |||
|
|||
cd exercises |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because this always does cd exercises
, the caller of this script must be at the root of https://github.com/exercism/rust when running it, which is more disadvantageous compared to being able to run it anywhere
|
||
#Number of tests | ||
test_num=$(cat $file_name | grep "\#\[test\]" | wc -l) | ||
test_num=$(($test_num - $comment_test_num)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could consider counting those number of lines for which #[test]
is the first thing on the line (possibly preceded by some number of spaces), rather than taking all lines with #[test]
anywhere on them and subtracting the comments.
|
||
#Number of ignores | ||
ignore_num=$(cat $file_name | grep "\#\[ignore\]" | wc -l) | ||
ignore_num=$(($ignore_num - $comment_ignore_num)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could consider counting those number of lines for which #[ignore]
is the first thing on the line (possibly preceded by some number of spaces), rather than taking all lines with #[ignore]
anywhere on them and subtracting the comments.
file_name="$exercise_name/tests/*.rs" | ||
|
||
#Commented tests | ||
comment_test_num=$(cat $file_name | grep "// \#\[test\]" | wc -l) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is probably preferable to grep PATTERN FILE
rather than cat FILE | grep PATTERN
, right? Is there a difference between the two?
else | ||
echo "$file_name : " | ||
echo "Tests: $test_num" | ||
echo "Ignores: $ignore_num" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be good if the script would exit nonzero if any file were found to have an unexpected number of ignore
lines. That will make it usable in CI.
Created a bash script that when run will find invalid test files.
Automates according to #352