# Commands covered:  log_file
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands.  Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest
    # do this in a way that is backward compatible for Tcl 8.3
    namespace import ::tcltest::test ::tcltest::cleanupTests
}
package require Expect

test logfile-1.1 {basic logfile} {
    set filename /tmp/logfile.[pid]
    file delete -force $filename
    log_file $filename
    unset spawn_id   ;# clean up results of previous test
    send "via send"
    send_user "via send_user"
    send_error "via send_stdout"
    if {[info exists ::tty_spawn_id]} {
	    send_tty "via send_tty"
    }
    send_log "via send_log"
    log_file
    set fid [open $filename]
    gets $fid buffer
    close $fid
    file delete -force $filename
    # verify everything but "send" is logged

    regexp "via send_uservia send_stdout.*via send_log" $buffer
} {1}

cleanupTests
return
