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

I don't like having to manually verify that second+later tests are ignored. Can it be automated? #352

Closed
petertseng opened this issue Sep 22, 2017 · 3 comments

Comments

@petertseng
Copy link
Member

petertseng commented Sep 22, 2017

As noted in #279, we ignore all tests except the first.

I don't like having to check by hand whether every new exercise submission has done this.

Maybe we can automate it We are automating it in #361 by counting the number of #[ignore] lines and ensuring that it is exactly one smaller than the number of #[test] lines.

By suggestion of a contributor (not myself) another possible way to do it is to run cargo test and make sure it says 1 passed; 0 failed. One disadvantage is it involves having to actually compile and run, whereas counting ignore and test does not.

All current exercises have been fixed so they have exactly one fewer ignore line than test line.

The remaining task is to add it to Travis CI so that future exercises also receive its benefit.

@f3rn0s
Copy link
Contributor

f3rn0s commented Oct 3, 2017

I had a think.

Here is a shell script that will return whether the given file name is valid.

#Argument 0
file_name="$1"

#Number of tests
test_num=$(cat $file_name | grep "\#\[test\]" | wc -l)

#Number of ignores
ignore_num=$(cat $file_name | grep "\#\[ignore\]" | wc -l)

#Number of tests minus 1 should be the number of ignores
compare=$(($test_num - 1))

#Print logic
if [ "$compare" -eq "$ignore_num" ]
then
    echo true
else
    echo false
fi

@petertseng
Copy link
Member Author

Current:

./exercises/bob/tests/bob.rs: Has 25 tests and 23 ignores (should be 24)
./exercises/crypto-square/tests/crypto-square.rs: Has 8 tests and 0 ignores (should be 7)
./exercises/say/tests/say.rs: Has 18 tests and 15 ignores (should be 17)

petertseng pushed a commit that referenced this issue Oct 10, 2017
We ignore all tests except the first, as discussed in
#279

Requested by #352
@petertseng
Copy link
Member Author

Updated issue description: The script exists, and current exercises have been fixed. Next step, if the script receives approval and gets merged, is to add it to Travis CI.

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

No branches or pull requests

2 participants