Re: tcltest Tk Applications



Erik Leunissen wrote:

I just found a fix for the problem that I addressed in the previous posting. See the code inside "setupScript" in the test script below.


But all access to files other than stdout, stderr and stdin will remain a very big



PITA


The following example test "writeToFile" will cause an error because the call to puts in [writeToFile] requires the channel $fd to exist. While that is the case in a normal execution environment, it is not in a slave interpreter unless you make it explicitly available using [interp transfer]. Since the [puts] immediately follows the opening of the file, there is no way to do that in a timely fashion when you're writing the test script. You could of course insert it into the proc to take into account that in the future it may be executed in a test environment that uses slave interpreters, but ... good heavens, NO.


Are there any people who see a workable solution here?

Or should we conclude that the best thing is not to use slave interpreters when the code that you want to test accesses files other than the standard ones?



set proc writeToFile {txt} {
    set fd [open ./testFile w]
    puts $fd $txt
    close $fd
}

set setupScript {
    interp create slave
    slave alias puts puts
}
set cleanupScript {
    interp delete slave
}

test writeToFile {exercises a file access error} \
    -setup $setupScript -body {
	slave eval writeToFile tralala
} -result "" -returnCodes ok -cleanup $cleanupScript


-- leunissen@ nl | Merge the left part of these two lines into one, e. hccnet. | respecting a character's position in a line.

.



Relevant Pages

  • Recursive parallel readdir() with drb and slave libraries
    ... recurse down to the bottom, and work your way back up. ... So I've tried to use the 'drb' and 'slave' libraries to make my life ... def count ... #puts " no threads." ...
    (comp.lang.ruby)
  • Re: tcltest Tk Applications
    ... puts command which would redirect all stdout/stderr output to the master interp, and use the default puts command for everything else. ... I resolved the issues with non-standard files too and fixed a problem that had been created when defining the alias for puts. ... I've attached the complete setup for using slave interps with tcltest to this message. ...
    (comp.lang.tcl)
  • DRb::DRbBadScheme when using drbunix sockets, why?
    ... I've been slowly hacking on my parallel recursive readdir() ... require 'slave' ... def count ... puts " no threads." ...
    (comp.lang.ruby)
  • Unexpected result from [slave alias srcCmd {}]
    ... I'm exercising aliases between master and slave interps. ... The unexpected part is that [slave alias srcCmd ] should delete a previously defined alias. ... % slave alias puts putsFromMaster ...
    (comp.lang.tcl)