summaryrefslogtreecommitdiff
path: root/tests/logfile.test
blob: d0a52429441ffa9e2df7ba832b788a117d5331e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 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