1# This file contains tests for the tkMain.c file.
2#
3# This file contains a collection of tests for one or more of the Tcl
4# built-in commands.  Sourcing this file into Tcl runs the tests and
5# generates output for errors.  No output means no errors were found.
6#
7# Copyright (c) 1997 by Sun Microsystems, Inc.
8# Copyright (c) 1998-1999 by Scriptics Corporation.
9# All rights reserved.
10#
11# RCS: @(#) $Id: main.test,v 1.6.2.1 2008/04/07 23:12:10 hobbs Exp $
12
13package require tcltest 2.1
14namespace import -force tcltest::configure
15namespace import -force tcltest::testsDirectory
16configure -testdir [file join [pwd] [file dirname [info script]]]
17configure -loadfile [file join [testsDirectory] constraints.tcl]
18tcltest::loadTestedCommands
19
20namespace import -force tcltest::interpreter
21namespace import -force tcltest::makeFile
22namespace import -force tcltest::removeFile
23
24test main-1.1 {StdinProc} {unix} {
25    set script [makeFile {
26	close stdin; exit
27    } script]
28    if {[catch {exec [interpreter] <$script} msg]} {
29	set error 1
30    } else {
31	set error 0
32    }
33    removeFile script
34    list $error $msg
35} {0 {}}
36
37test main-3.1 {Tk_ParseArgv: -help option} -constraints unix -body {
38    # Run only on unix as Win32 pops up native dialog
39    list [catch {exec [interpreter] -help} msg] $msg
40} -match glob -result {1 {% Application initialization failed: Command-specific options:*}}
41
42test main-3.2 {Tk_ParseArgv: -help option} -setup {
43    set maininterp [interp create]
44} -body {
45    $maininterp eval { set argc 1 ; set argv -help }
46    list [catch {load {} Tk $maininterp} msg] $msg
47} -cleanup {
48    interp delete $maininterp
49} -match glob -result {1 {Command-specific options:*}}
50
51test main-3.3 {Tk_ParseArgv: -help option} -setup {
52    set maininterp [interp create]
53} -body {
54    # Repeat of 3.2 to catch cleanup, eg Bug 1927135
55    $maininterp eval { set argc 1 ; set argv -help }
56    list [catch {load {} Tk $maininterp} msg] $msg
57} -cleanup {
58    interp delete $maininterp
59} -match glob -result {1 {Command-specific options:*}}
60
61# cleanup
62::tcltest::cleanupTests
63return
64