grdlok / crypto

cryptography library in multiple programming languages for learning
0 stars 1 forks source link

add flag to the test script to only test the desired cipher #10

Open grdlok opened 10 years ago

grdlok commented 10 years ago

want to be able to test only the desired cipher or desired language. that involves messing about the scripts.

pbhandari commented 10 years ago

So 2 options: the harder one

./test.sh Ruby/Affine ruby/Caesar Java/affine Python

This will run the Affine and Caesar tests for Ruby, the Affine for Java, and all available tests for Python, ./test.sh with no arguments, will run all the tests for all languages. I'll try and get this working, but the code will be ugly as hell.

and the easier one:

./test.sh --lang="Ruby Java" --func="affine caesar"

This will run the Affine and Caeasr tests for Ruby and Java

And here's how the defaults work out

./test.sh # all tests for all languages
./test.sh --func="affine" #affine for all languages
./test.sh --lang="Java Ruby" # all tests for Java and Ruby

I'll try and get this up first and include atleast the --func='affine' for this in the top one. Either that or I'll make it so that ./test.sh */affine will run all the affine tests

grdlok commented 10 years ago

the second will work better, problem is keeping the definitions updated so there wont be a need to consistently update the scripts files. but sounds good, go ahead with the implementation.

pbhandari commented 10 years ago

Oh yeah, I'm woking on that part first, Modifying the test files every-time is just annoying. And OK, I'll get that behaviour up and running soon.

pbhandari commented 10 years ago

Checkout my misc/tests branch. Right now only the ruby and python tests work with the new flags. That creates a merge conflict with the tests on the Affine branch, so I'll wait a bit to merge it in. But see if that's more or less what you want, if it is I'll c/p that over to the rest of the languages.

Also, right now it doesn't handle empty arguments well, so if you need it empty, just don't pass it in.

And if you pass in a garbage -f value, it will silently ignore it and run all the tests, but those can be fixed later.

Oh and languages are case-sensitive, functions aren't. Again, will fix that later.

EDIT: OK Everything but the Java tests are done and pushed to that branch. With JavaScript and PHP I'm just hoping I haven't screwed something up.

grdlok commented 10 years ago

from your misc/tests branch everything seems fine i'll do a pull and see if everything is right as rain.

so stock osx screams fire when it runs your script, the base getopt is not compatible but using it under a VM ubuntu distribution shows that it does work. so i trust that what you say works, works. the current ruby implementation does not pass the tests for some reason but the original did further investigation will be required to determine if this is due to your updated script or a bad implementation. first off does the ruby tests pass on your machine?

pbhandari commented 10 years ago

Ruby tests work fine on my end, with or without the script. Btw, which version of Ruby are you using, I know there are some major changes b/w v1.x and v2.x that could be it.

Also, I forgot you were using OSX. Yeah, the forgot that the way getopt works on Linux is different from the way it does in BSD. I've been meaning to install a BSD for a while, so the next time I'm in school, I'll do that and see whether I can't fix it so that it works on all Unices.

EDIT: Try it in OSX now, hopefullly this'll work.

grdlok commented 10 years ago

no dice,

find: -printf: unknown primary or operator

we don't need to worry to much about compatibility at this stage in development, though if your determined i applaud you and support your pursuit.

pbhandari commented 10 years ago

Damn it .... I'll get it working just give me a second

OK, Try now.

pbhandari commented 10 years ago

OK I was planning on testing this with FreeBSD, but it's giving me issues, adam, can you try now and see if it works?

grdlok commented 10 years ago

there some problems when your constructing the path, I think your appending the SCRIPT_PATH accidentally. sometimes SCRIPT_PATH is appended to TEST_LANG

For example Alone

./test.sh 
**************Test $SCRIPT_PATH*******************
$SCRIPT_PATH/$SCRIPT_PATH/$lang/test.sh
**************Test SCRIPT_PATH*******************

which would raise an fnf error

and finally when only a function is specified lets say Caesar the exact same result occurs. since your fork does not have all the current tests in Affine, i couldn't continue testing the script. In any case your doing great! thanks dude

pbhandari commented 10 years ago

Oops, forgot to mention this.

For the -f flag, just test Ruby. And create a file in tests/Ruby called RandomTest.rb.

Here is what should happen

./test.sh -l Ruby -f Random # Runs only Random
./test.sh -l Ruby # Runs both Random and Caesar

Right now the -f functionality is only in Ruby, once that is done, I'll c/p the script across all languages.