Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
returning to a specific upper lever

Posted by sarmstro (sarmstro), 10 August 2005
I'm writing a test automation framework in Expectk and I need help with a feature.

First, I'll explain the structure: a script called runTests.exp (called when a button in the Tk GUI is pressed) runs each test script in a list in turn and writes the result of the test in a database. In each test script there are calls to a testStep() function which reports test step passes or fails. I'd like to include a FATAL fail where the test script will then call a few lines of cleanup code (which may be different for each test script) and then return to the runTests.exp script which will run the next test script in the for loop.

So, it looks like this:
runTests.exp
|_> for test in $testlist {
                source $test


Posted by sarmstro (sarmstro), 10 August 2005
whoops, sorry - hadn't finished

runTests.exp
|_> for test in $testlist {
      source $test
                |-> testStep FATAL
                             |-> cleanup()
                                   continue in for loop

It is the "continue in for loop" part that's catching me - how can I return to a specified level a few levels up.

Any help will be much appreciated.

Thanks,
Scott  

Posted by admin (Graham Ellis), 11 August 2005
I've looked at this a couple of times ... not totally convinced I'm following the question but ...

If you want to exit from several nested loops, or from nested procs, the best way is to use a flag variable and exit the levels one by one; yes, the coding isn't very short.

If the mechanism is in use throughout your program, then you might prefer to consider a global variable that you check after each return.

Finally, have a look at the uplevel and upvar commands that let you reference variables and run commands one level up ... and you CAN tell them to work multiple levels up.   Do this latter with care as it can lead to code that's obscure and very hard to maintain.

Posted by sarmstro (sarmstro), 18 October 2005
Revisiting this problem - if I use catch can i throw an error in the result of a FATAL fail and deal with it using catch {source <single test>...  ?

Posted by admin (Graham Ellis), 18 October 2005
Usually, yes.   You can't if the error is a syntax error such as incorrectly matched { and } within the catch.



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho