Skip to content

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

Closed
wants to merge 1 commit into from
Closed

Added ignore/tests counter #363

wants to merge 1 commit into from

Conversation

f3rn0s
Copy link
Contributor

@f3rn0s f3rn0s commented Oct 10, 2017

Created a bash script that when run will find invalid test files.

Automates according to #352

Copy link
Member

@petertseng petertseng left a 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
Copy link
Member

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))
Copy link
Member

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))
Copy link
Member

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)
Copy link
Member

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"
Copy link
Member

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.

@f3rn0s f3rn0s closed this Oct 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants