landro / TesTcl

when you don't have the balls to test your F5 BIG-IP iRules directly in production
https://testcl.com
BSD 3-Clause "New" or "Revised" License
98 stars 30 forks source link

support for table, multiple irules and multiple events #35

Closed mynameisrufus closed 9 years ago

mynameisrufus commented 10 years ago

I changed event to trigger as event is used by iRules(tm), I think it's also more common to have the method called trigger.

You can now trigger multiple events and see what state your mock table is in:

trigger CLIENT_ACCEPTED
trigger CLIENT_ACCEPTED

verify "foo" 2 eq { table keys -subtable "foo" -count }

The table implementation is very naive it only works for this case.

See test/test_table.tcl for an example on how this works.

Some tests are failing and jtcl is not working because of the use of dict and ensemble.

landro commented 10 years ago

Great stuff. Really look forward to testing it. Is the code stable yet? In the past I've tried keeping the master branch clean and do development on the development branch. Make sure to keep code jtcl compatible.

mynameisrufus commented 10 years ago

I have problems with jtcl becuase of dict and ensemble, looks stable of tclsh just run make. I could have a look at getting rid of the jtcl dependency?

landro commented 10 years ago

I believe there is support for the dict command in jtcl - it was backported - have a look here: https://jtcl.kenai.com/docs/ https://github.com/jtcl-project/jtcl/blob/master/src/main/java/tcl/lang/TclDict.java

The thing is - we have to make sure we support all valid irules (as in we have to support the starts_with etc operators). So, we're left with two alternatives:

mynameisrufus commented 10 years ago

I prefixed everything ::tcl::dict for jtcl but that broke tclsh. I have only looked at tcl for couple of weeks so i'm not sure how to achieve table key without using ensemble (args hacks could be used but dirty), the thing is jtcl seems to have implemented ensemble so i'm not sure what is going on.

I will try and implement starts_with and friends and update this PR over the next few days or few weeks (about to take a holiday).

landro commented 10 years ago

How about renaming aliasing ::tcl::dict with dict in case of jtcl? I believe the ensemble command in jtcl is part of itcl and not implemented "natively" or backported, ref: http://wiki.tcl.tk/4302 and https://github.com/jtcl-project/jtcl/blob/master/src/main/java/tcl/pkg/itcl/Ensemble.java

mynameisrufus commented 9 years ago

I'm a bit disgruntled with big devices and iRules so will not be doing any more work on this, thanks for looking at my PR.