# # logtofile.test -- # nca-073-9 # # Copyright (c) 1996-2000 by Netcetera AG. # Copyright (c) 2001 by Apache Software Foundation. # All rights reserved. # # See the file "license.terms" for information on usage and # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. # # @(#) $Id$ # if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest namespace import ::tcltest::* } # ----------------------------------------------------------------------------- # logtofile errors (-1.x) # ----------------------------------------------------------------------------- test logtofile-1.1 {web::logdest add file cannot open file} { web::logdest delete catch { set res [web::logdest add info2.-debug file /gugus/data/test.dat] } msg set msg } {couldn't open "/gugus/data/test.dat": no such file or directory} test logtofile-1.2 {web::logdest add file wrong number of args} { catch { set res [web::logdest add info2.-debug file] } msg set msg } {wrong # args: should be "file ?-unbuffered? fileName"} test logtofile-1.3 {web::logdest add file; too many args} { catch { set res [web::logdest add info2.-debug file 1 2 3 4 5] } msg set msg } {wrong # args: should be "file ?-unbuffered? fileName"} # ----------------------------------------------------------------------------- # logtofile normal operation (-2.x) # ----------------------------------------------------------------------------- test logtofile-2.1 {web::logdest add file returns id} { web::logdest delete set res [web::logdest add info2.-debug file test.dat] web::logdest delete file delete test.dat set res } {logdest0} test logtofile-2.2 {web::logdest add file accepts -unbuffered} { web::logdest delete set res [web::logdest add info2.-debug file -unbuffered test.dat] web::logdest delete file delete test.dat set res } {logdest0} test logtofile-2.3 {web::logdest add file but file exists} { web::logdest delete set fh [open test.dat "w"] close $fh set res [web::logdest add info2.-debug file -unbuffered test.dat] set res [web::logdest add info2.-debug file -unbuffered test.dat] web::logdest delete file delete test.dat set res } {logdest1} test logtofile-3.1 {web::log to file} { web::logdest delete web::logdest add info2.-debug file -unbuffered test.dat web::loglevel add *.-debug web::log info3.debug "" web::readfile test.dat empty web::log info2.debug "hi" web::readfile test.dat hi web::logdest delete file delete test.dat set res [list $empty [string match "*\] info2.debug: hi*" $hi]] } {{} 1} # cleanup ::tcltest::cleanupTests