Re: tcltest (was Re: How do you convert a TCL list into a string that PHP can read?)




Bryan Oakley wrote:
comp.lang.tcl wrote:

Dude, that was utter UTTER Hungarian! :(

I understood NONE of what you just did. Absolutely NOTHING.

This might be a great time to mention that I learned TCL via..
VIGNETTE. http://www.vignette.com. Does that help?

I suspected as much. I used to work at Vignette and I know first hand
that they did an absolutely terrible job teaching Tcl. Because of their
rather questionable design choices they magnified quoting problems
ten-fold and encouraged bad habits. Pity, because tcl is just absolutely
perfect for scripting web pages; much better than any other language IMHO.


The abject irony is that Vignette no longer uses TCL in newer versions
of its content management platform; it's all J2EE now.

The simple answer, Phil, is that tcltest is just a file you can "source"
like any other file. It may already exist as a package in which case you
can do "package require tcltest" instead of "source". Once you've done
either of those, you have at your disposal a new tcl command named
"test" (or "tcltest::test") that you can use to build up suites of
automated tests. You actually get a lot more than just the test command,
but that's beside the point.

So, much like you can create a web page with something like this (I'm
guessing; I don't know exactly how you embed tcl in your php scripts):

<html>
<some tag to embed tcl>
PROPER_CASE "Hello, world"
</some tag>

Don't have anything that can do that, sorry. My TCL code is called
command-line only:

[PHP]
<?
$msg = exec("tclsh \"$pathToTclFile\" 2>&1");
?>
[/PHP]

Only way I can do it since Apache is not set up to handle embedded TCL
(and I don't have root privileges to change Apache were I to know how
to do it and it's also not a requirement so no one will OK such a
change)


... you can create test scripts with something that may look like this :

<html>
<some tag to embed tcl>
source tcltest.tcl ;# or "package require tcltest 2"
source yourCodeToBeTested.tcl
test example-1 {a simple test} -body ... -result ...
test example-2 {another test} -body ... -result ...
cleanupTests
</some tag>


I am probably still doing this wrong but I at this point don't know if
I'll ever get this right, so here goes:

[phillip@here ~]$ tclsh << eof
package require tcltest 2
source {/var/www/html/tcl/lib/tcl_string_tools.tcl}
test PROPER_CASE {_hello world} -body
cleanupTests
eof
invalid command name "test"
invalid command name "cleanupTests"
[phillip@here ~]$ tclsh << eof
source tcltest 2
source {/var/www/html/tcl/lib/tcl_string_tools.tcl}
test PROPER_CASE {_hello world} -body
cleanupTests
eof
wrong # args: should be "source fileName"
invalid command name "test"
invalid command name "cleanupTests"



Visit the web page, et voila!, you've just written and run a regression
test. Now, I can't guarantee it is truly that easy for you because I
don't know what environment you are using. Generally speaking though, if
you are able to source your own tcl files you can source tcltest.tcl and
write regression tests with the "test" command.

Environment: RHEL4 with Apache 2.0.53, PHP 4.3.9 and MySQL 4.1.17


My suggestion: where you have one file now that defines the proc
PROPER_CASE, create two files. Assuming the first file is named
"library.tcl", name the second file "library.test". Put your test
scripts in the second file, then source "library.test" (or do "tclsh
library.test") whenever you want to run the tests.

I hope this helps.


It does to a point, but I still don't understand, I'm sorry.

Phil


--
Bryan Oakley
http://www.tclscripting.com

.



Relevant Pages

  • ANN: AOLserver 4.5.0 released!
    ... On behalf of the AOLserver Team, I have the honor of announcing the ... AOLserver 4.5.0 is a major upgrade including several new Tcl commands, ... AOLserver is America Online's Open-Source web server. ... the "ns_zlib" command for compressing and uncompressing ...
    (comp.lang.tcl)
  • Tcl-URL! - weekly Tcl news and links (Mar 5)
    ... GRIDPLUS2 is a Tile based version of GRIDPLUS. ... *) New "gpselect" command to select a tablelist row or tree node. ... Some people take their license issues very personal indeed;-) (and ... Word documents via Tcl and tcom - ...
    (comp.lang.tcl)
  • S21SEC-024 - Vignette TCL Injection
    ... Title: Vignette TCL Injection ... Vignette Software presents a vulnerability in some propietary commands that permits the injection of TCL code under some circunstances. ... the value of some unfiltered variables is used and evaluated with the SHOW command. ...
    (Bugtraq)
  • Re: Core commands as ensembles...
    ... command that does much the same as [namespace code], ... TCL as their scripting/console engine. ... home-brew bits and pieces, in which I will use TCL in any way that I ...
    (comp.lang.tcl)
  • Re: Can Ruby read emails?
    ... command, and Ruby will read it and exacute that command. ... I actually wrote a system using Tcl some years back which used ... e-mail to "move" a software agent from one host to another. ...
    (comp.lang.ruby)