Skip to content
Tcl Source Code Artifact [3132f609b5]
Login

Artifact [3132f609b5]

Artifact 3132f609b576262b8fb76a7862d1f0be6d9a7878a04dbd8bd65a8063cb040b21:


# -*- tcl -*-
# Commands covered:  pkgconfig
#
# 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 © 1991-1993 The Regents of the University of California.
# Copyright © 1994-1996 Sun Microsystems, Inc.
# Copyright © 1998-1999 Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.

if {"::tcltest" ni [namespace children]} {
    package require tcltest 2.5
    namespace import -force ::tcltest::*
}

::tcltest::loadTestedCommands
catch [list package require -exact tcl::test [info patchlevel]]

testConstraint testregisterconfig [llength [info commands testregisterconfig]]

test pkgconfig-1.1 {query keys} -body {
    lsort [::tcl::pkgconfig list]
} -match glob -result {*bindir,install bindir,runtime*docdir,install docdir,runtime includedir,install includedir,runtime libdir,install libdir,runtime*scriptdir,install scriptdir,runtime*}
test pkgconfig-1.2 {query keys multiple times} {
    string compare [::tcl::pkgconfig list] [::tcl::pkgconfig list]
} 0
test pkgconfig-1.3 {query value multiple times} {
    string compare \
	    [::tcl::pkgconfig get bindir,install] \
	    [::tcl::pkgconfig get bindir,install]
} 0


test pkgconfig-2.0 {error: missing subcommand} {
    catch {::tcl::pkgconfig} msg
    set msg
} {wrong # args: should be "::tcl::pkgconfig subcommand ?arg?"}
test pkgconfig-2.1 {error: illegal subcommand} {
    catch {::tcl::pkgconfig foo} msg
    set msg
} {bad subcommand "foo": must be get or list}
test pkgconfig-2.2 {error: list with arguments} {
    catch {::tcl::pkgconfig list foo} msg
    set msg
} {wrong # args: should be "::tcl::pkgconfig list"}
test pkgconfig-2.3 {error: get without arguments} {
    catch {::tcl::pkgconfig get} msg
    set msg
} {wrong # args: should be "::tcl::pkgconfig get key"}
test pkgconfig-2.4 {error: query unknown key} {
    catch {::tcl::pkgconfig get foo} msg
    set msg
} {key not known}
test pkgconfig-2.5 {error: query with to many arguments} {
    catch {::tcl::pkgconfig get foo bar} msg
    set msg
} {wrong # args: should be "::tcl::pkgconfig subcommand ?arg?"}

test pkgconfig-3.1 {Tcl_RegisterConfig twice merges, bug 67769bcad3} -constraints {
    testregisterconfig
} -body {
    testregisterconfig pkgconfigtest a 1
    testregisterconfig pkgconfigtest b 2
    list [lsort [pkgconfigtest::pkgconfig list]] \
	    [pkgconfigtest::pkgconfig get a] [pkgconfigtest::pkgconfig get b]
} -cleanup {
    namespace delete pkgconfigtest
} -result {{a b} 1 2}

# cleanup
::tcltest::cleanupTests
return