summaryrefslogtreecommitdiffstats
path: root/tests/main.test
blob: 3799be70b515087ec3560c619c1c7a9a638f2771 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# This file contains tests for the tkMain.c 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.
#
# Copyright (c) 1997 by Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.

package require tcltest 2.1
namespace import -force tcltest::configure
namespace import -force tcltest::testsDirectory
configure -testdir [file join [pwd] [file dirname [info script]]]
configure -loadfile [file join [testsDirectory] constraints.tcl]
tcltest::loadTestedCommands

namespace import -force tcltest::interpreter
namespace import -force tcltest::makeFile
namespace import -force tcltest::removeFile

test main-1.1 {StdinProc} {unix} {
    set script [makeFile {
	close stdin; exit
    } script]
    if {[catch {exec [interpreter] <$script} msg]} {
	set error 1
    } else {
	set error 0
    }
    removeFile script
    list $error $msg
} {0 {}}

test main-3.1 {Tk_ParseArgv: -help option} -constraints unix -body {
    # Run only on unix as Win32 pops up native dialog
    list [catch {exec [interpreter] -help} msg] $msg
} -match glob -result {1 {% Application initialization failed: Command-specific options:*}}

test main-3.2 {Tk_ParseArgv: -help option} -setup {
    set maininterp [interp create]
} -body {
    $maininterp eval { set argc 1 ; set argv -help }
    list [catch {load {} Tk $maininterp} msg] $msg
} -cleanup {
    interp delete $maininterp
} -match glob -result {1 {Command-specific options:*}}

test main-3.3 {Tk_ParseArgv: -help option} -setup {
    set maininterp [interp create]
} -body {
    # Repeat of 3.2 to catch cleanup, eg Bug 1927135
    $maininterp eval { set argc 1 ; set argv -help }
    list [catch {load {} Tk $maininterp} msg] $msg
} -cleanup {
    interp delete $maininterp
} -match glob -result {1 {Command-specific options:*}}

# cleanup
::tcltest::cleanupTests
return