Re: tcltest (was Re: How do you convert a TCL list into a string that PHP can read?)
- From: "comp.lang.tcl" <phillip.s.powell@xxxxxxxxx>
- Date: 24 Apr 2006 09:09:37 -0700
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 2invalid command name "test"
source {/var/www/html/tcl/lib/tcl_string_tools.tcl}
test PROPER_CASE {_hello world} -body
cleanupTests
eof
invalid command name "cleanupTests"
[phillip@here ~]$ tclsh << eof
source tcltest 2wrong # args: should be "source fileName"
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"
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
.
- Follow-Ups:
- References:
- Re: How do you convert a TCL list into a string that PHP can read?
- From: Donal K. Fellows
- Re: How do you convert a TCL list into a string that PHP can read?
- From: comp.lang.tcl
- tcltest (was Re: How do you convert a TCL list into a string that PHP can read?)
- From: Bryan Oakley
- Re: How do you convert a TCL list into a string that PHP can read?
- Prev by Date: Dr. Dobb's Tcl-URL! - weekly Tcl news and links (Apr 24)
- Next by Date: Re: tcltest (was Re: How do you convert a TCL list into a string that PHP can read?)
- Previous by thread: tcltest (was Re: How do you convert a TCL list into a string that PHP can read?)
- Next by thread: Re: tcltest (was Re: How do you convert a TCL list into a string that PHP can read?)
- Index(es):
Relevant Pages
|