Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 09b987cf9034f672febb4bcc2ff5ecec13b40e0e
Ticket: 218939ffffffffffffffffffffffffffffffffff
Tcltest enhancement
User & Date: nobody on 2000-10-26 01:08:15
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OriginalBugID: 2842 Bug
    Version: 8.2
    SubmitDate: '1999-09-20'
    LastModified: '1999-10-20'
    Severity: LOW
    Status: Released
    Submitter: techsupp
    ChangedBy: jenn
    OS: Other
    Machine: NA
    FixedDate: '1999-10-20'
    ClosedDate: '2000-10-25'
    
    
    Name:
    
    Andreas Kupries
    
    
    ObservedBehavior:
    
    The following patch makes the tcltest more usable for extensions and
    
        their test suites.
    
        It adds 3 commandline flags allowing the user to define more things from
    
        the outside.
    
        Internally it refactors common code for dealing with paths into separate
    
        procedures.
    
    
    Patch:
    
    *** tcltest.tcl.orig6Fri Sep 17 19:27:17 1999
    
    --- tcltest.tclFri Sep 17 22:56:46 1999
    
    ***************
    
    *** 14,20 ****
    
      # 
    
      # RCS: @(#) $Id: tcltest.tcl,v 1.9 1999/07/30 01:35:27 jenn Exp $
    
    
    ! package provide tcltest 1.0
    
    
      # Ensure that we have a minimal auto_path so we don't pick up extra junk.
    
      set auto_path [list [info library]]
    
    --- 14,20 ----
    
      # 
    
      # RCS: @(#) $Id: tcltest.tcl,v 1.9 1999/07/30 01:35:27 jenn Exp $
    
    
    ! package provide tcltest 1.1
    
    
      # Ensure that we have a minimal auto_path so we don't pick up extra junk.
    
      set auto_path [list [info library]]
    
    ***************
    
    *** 26,32 ****
    
          # Export the public tcltest procs
    
          set procList [list test cleanupTests saveState restoreState \
    
          normalizeMsg makeFile removeFile makeDirectory removeDirectory \
    
    !     viewFile bytestring safeFetch threadReap getMatchingFiles]
    
          foreach proc $procList {
    
      namespace export $proc
    
          }
    
    --- 26,33 ----
    
          # Export the public tcltest procs
    
          set procList [list test cleanupTests saveState restoreState \
    
          normalizeMsg makeFile removeFile makeDirectory removeDirectory \
    
    !     viewFile bytestring safeFetch threadReap getMatchingFiles \
    
    !     loadTestedCommands]
    
          foreach proc $procList {
    
      namespace export $proc
    
          }
    
    ***************
    
    *** 114,119 ****
    
    --- 115,125 ----
    
          # Don't run only the constrained tests by default
    
          variable limitConstraints false
    
    
    +     # A test application has to know how to load the tested commands into
    
    +     # the interpreter.
    
    + 
    
    +     variable loadScript {}
    
    + 
    
          # tests that use threads need to know which is the main thread
    
    
          variable mainThread 1
    
    ***************
    
    *** 670,686 ****
    
    --- 676,783 ----
    
      -tmpdir directory\t Save temporary files in the specified\n\
    
      \t                 directory.  The default value is \n\
    
      \t                 $::tcltest::temporaryDirectory. \n\
    
    + -testdir directories\t Search tests in the specified\n\
    
    + \t                 directories.  The default value is \n\
    
    + \t                 $::tcltest::testsDirectory. \n\
    
      -outfile file    \t Send output from test runs to the \n\
    
      \t                 specified file.  The default is \n\
    
      \t                 stdout. \n\
    
      -errfile file    \t Send errors from test runs to the \n\
    
      \t                 specified file.  The default is \n\
    
      \t                 stderr. \n\
    
    + -loadfile file   \t Read the script to load the tested \n\
    
    + \t                 commands from the specified file. \n\
    
    + -load script  \t Specifies the script to load the tested \n\
    
    + \t                 commands. \n\
    
      -debug level     \t Internal debug flag."]
    
          ::tcltest::PrintUsageInfoHook
    
          return
    
      }
    
      
    
    + # ::tcltest::CheckDirectory --
    
    + #
    
    + #This procedure checks whether the specified path is a readable
    
    + #and/or writable directory. If one of the conditions is not
    
    + #satisfied an error is printed and the application aborted. The
    
    + #procedure assumes that the caller already checked the existence
    
    + #of the path.
    
    + #
    
    + # Arguments
    
    + #rwInformation what attributes to check. Allowed values:
    
    + #r, w, rw, wr. If 'r' is part of the value the directory
    
    + #must be readable. 'w' associates to 'writable'.
    
    + #dirThe directory to check.
    
    + #errMsgThe string to prepend to the actual error message before
    
    + #printing it.
    
    + #
    
    + # Results
    
    + #none
    
    + #
    
    + 
    
    + proc ::tcltest::CheckDirectory {rw dir errMsg} {
    
    +     # Allowed values for 'rw': r, w, rw, wr
    
    + 
    
    +     if {![file isdir $dir]} { 
    
    + ::tcltest::PrintError "$errMsg \"$dir\" is not a directory"
    
    + exit 1
    
    +     } elseif {([string first r $rw] >= 0) && ![file writable $dir]} {
    
    + ::tcltest::PrintError "$errMsg \"$dir\" is not writeable" 
    
    + exit 1
    
    +     } elseif {([string first w $rw] >= 0) &&![file readable $dir]} {
    
    + ::tcltest::PrintError "$errMsg \"$dir\" is not readable" 
    
    + exit 1
    
    +     }
    
    + }
    
    + 
    
    + # ::tcltest::NormalizePath --
    
    + #
    
    + #This procedure resolves any symlinks in the path thus creating a
    
    + #path without internal redirection. It assumes that the incoming
    
    + #path is absolute.
    
    + #
    
    + # Arguments
    
    + #pathVarcontains the name of the variable containing the path to modify.
    
    + #
    
    + # Results
    
    + #The path is modified in place.
    
    + #
    
    + 
    
    + proc ::tcltest::NormalizePath {pathVar} {
    
    +     upvar $pathVar path
    
    + 
    
    +     set oldpwd [pwd]
    
    +     cd $path
    
    +     set path [pwd]
    
    +     cd $oldpwd
    
    + }
    
    + 
    
    + # ::tcltest::MakeAbsolutePath --
    
    + #
    
    + #This procedure checks whether the incoming path is absolute or not.
    
    + #Makes it absolute if it was not.
    
    + #
    
    + # Arguments
    
    + #pathVarcontains the name of the variable containing the path to modify.
    
    + #prefixis optional, contains the path to use to make the other an
    
    + #absolute one. The current working directory is used if it was
    
    + #not specified.
    
    + #
    
    + # Results
    
    + #The path is modified in place.
    
    + #
    
    + 
    
    + proc ::tcltest::MakeAbsolutePath {pathVar {prefix {}}} {
    
    +     upvar $pathVar path
    
    + 
    
    +     if {![string equal [file pathtype $path] "absolute"]} { 
    
    + if {$prefix == {}} {
    
    +     set prefix [pwd]
    
    + }
    
    + 
    
    + set path [file join $prefix $path] 
    
    +     }
    
    + }
    
    + 
    
      # ::tcltest::processCmdLineArgsAddFlagsHook --
    
      #
    
      #This hook is used to add to the list of command line arguments that are
    
    ***************
    
    *** 751,757 ****
    
          # -help is not listed since it has already been processed
    
          lappend defaultFlags -verbose -match -skip -constraints \
    
          -outfile -errfile -debug -tmpdir -file -notfile \
    
    !     -preservecore -limitconstraints
    
          set defaultFlags [concat $defaultFlags \
    
          [ ::tcltest::processCmdLineArgsAddFlagsHook ]]
    
    
    --- 848,855 ----
    
          # -help is not listed since it has already been processed
    
          lappend defaultFlags -verbose -match -skip -constraints \
    
          -outfile -errfile -debug -tmpdir -file -notfile \
    
    !     -preservecore -limitconstraints -testdir -load  \
    
    !     -loadfile
    
          set defaultFlags [concat $defaultFlags \
    
          [ ::tcltest::processCmdLineArgsAddFlagsHook ]]
    
    
    ***************
    
    *** 830,864 ****
    
          if {[info exists flag(-tmpdir)]} {
    
      set ::tcltest::temporaryDirectory $flag(-tmpdir)
    
    
    ! if {![string equal \
    
    ! [file pathtype $::tcltest::temporaryDirectory] \
    
    ! "absolute"]} { 
    
    !     set ::tcltest::temporaryDirectory [file join [pwd] \
    
    !     $::tcltest::temporaryDirectory] 
    
    ! }
    
      set tmpDirError "bad argument \"$flag(-tmpdir)\" to -tmpdir: "
    
          }
    
          if {[file exists $::tcltest::temporaryDirectory]} {
    
    ! if {![file isdir $::tcltest::temporaryDirectory]} { 
    
    !     ::tcltest::PrintError "$tmpDirError \"$::tcltest::temporaryDirectory\" \
    
    !     is not a directory"
    
    !     exit 1
    
    ! } elseif {![file writable $::tcltest::temporaryDirectory]} {
    
    !     ::tcltest::PrintError "$tmpDirError \"$::tcltest::temporaryDirectory\" \
    
    !     is not writeable" 
    
    !     exit 1
    
    ! } elseif {![file readable $::tcltest::temporaryDirectory]} {
    
    !     ::tcltest::PrintError "$tmpDirError \"$::tcltest::temporaryDirectory\" \
    
    !     is not readable" 
    
    !     exit 1
    
    ! }
    
          } else {
    
      file mkdir $::tcltest::temporaryDirectory
    
          }
    
    !     set oldpwd [pwd]
    
    !     cd $::tcltest::temporaryDirectory
    
    !     set ::tcltest::temporaryDirectory [pwd]
    
    !     cd $oldpwd
    
    
          # Save the names of files that already exist in
    
          # the output directory.
    
    --- 928,968 ----
    
          if {[info exists flag(-tmpdir)]} {
    
      set ::tcltest::temporaryDirectory $flag(-tmpdir)
    
    
    ! MakeAbsolutePath ::tcltest::temporaryDirectory
    
      set tmpDirError "bad argument \"$flag(-tmpdir)\" to -tmpdir: "
    
          }
    
          if {[file exists $::tcltest::temporaryDirectory]} {
    
    ! ::tcltest::CheckDirectory rw $::tcltest::temporaryDirectory $tmpDirError
    
          } else {
    
      file mkdir $::tcltest::temporaryDirectory
    
          }
    
    ! 
    
    !     NormalizePath ::tcltest::temporaryDirectory
    
    ! 
    
    !     # Set the ::tcltest::testsDirectory to the arg of -testdir, if
    
    !     # given.
    
    !     # 
    
    !     # If the path is relative, make it absolute.  If the file exists but
    
    !     # is not a dir, then return an error.
    
    !     #
    
    !     # If ::tcltest::temporaryDirectory does not already exist return an error.
    
    ! 
    
    !     set testDirError ""
    
    !     if {[info exists flag(-testdir)]} {
    
    ! set ::tcltest::testsDirectory $flag(-testdir)
    
    ! 
    
    ! MakeAbsolutePath ::tcltest::testsDirectory
    
    ! set testDirError "bad argument \"$flag(-testdir)\" to -testdir: "
    
    !     }
    
    !     if {[file exists $::tcltest::testsDirectory]} {
    
    ! ::tcltest::CheckDirectory r $::tcltest::testsDirectory $testDirError
    
    !     } else {
    
    ! ::tcltest::PrintError "$testDirError \"$::tcltest::testsDirectory\" \
    
    ! does not exist"
    
    ! exit 1
    
    !     }
    
    ! 
    
    !     NormalizePath ::tcltest::testsDirectory
    
    
          # Save the names of files that already exist in
    
          # the output directory.
    
    ***************
    
    *** 872,891 ****
    
    
          if {[info exists flag(-outfile)]} {
    
      set tmp $flag(-outfile)
    
    ! if {![string equal [file pathtype $tmp] "absolute"]} {
    
    !     set tmp [file join $::tcltest::temporaryDirectory $tmp]
    
    ! }
    
      set ::tcltest::outputChannel [open $tmp w]
    
          } 
    
    
          if {[info exists flag(-errfile)]} {
    
      set tmp $flag(-errfile)
    
    ! if {![string equal [file pathtype $tmp] "absolute"]} {
    
    !     set tmp [file join $::tcltest::temporaryDirectory $tmp]
    
    ! }
    
      set ::tcltest::errorChannel [open $tmp w]
    
          }
    
    
          # If the user specifies debug testing, print out extra information during
    
          # the run.
    
          if {[info exists flag(-debug)]} {
    
    --- 976,1012 ----
    
    
          if {[info exists flag(-outfile)]} {
    
      set tmp $flag(-outfile)
    
    ! MakeAbsolutePath tmp $::tcltest::temporaryDirectory
    
      set ::tcltest::outputChannel [open $tmp w]
    
          } 
    
    
          if {[info exists flag(-errfile)]} {
    
      set tmp $flag(-errfile)
    
    ! MakeAbsolutePath tmp $::tcltest::temporaryDirectory
    
      set ::tcltest::errorChannel [open $tmp w]
    
          }
    
    
    +     # If a load script was specified, either directly or through
    
    +     # a file, remember it for later usage.
    
    + 
    
    +     if {
    
    + [info exists flag(-load)] &&
    
    + ([lsearch -exact $flagArray -load] > [lsearch -exact $flagArray -loadfile])
    
    +     } {
    
    + set ::tcltest::loadScript $flag(-load)
    
    +     }
    
    + 
    
    +     if {
    
    + [info exists flag(-loadfile)] &&
    
    + ([lsearch -exact $flagArray -loadfile] > [lsearch -exact $flagArray -load])
    
    +     } {
    
    + set tmp $flag(-loadfile)
    
    + MakeAbsolutePath tmp $::tcltest::temporaryDirectory
    
    + set tmp [open $tmp r]
    
    + set ::tcltest::loadScript [read $tmp]
    
    + close $tmp
    
    +     }
    
    + 
    
          # If the user specifies debug testing, print out extra information during
    
          # the run.
    
          if {[info exists flag(-debug)]} {
    
    ***************
    
    *** 914,919 ****
    
    --- 1035,1060 ----
    
          DebugPArray 1 ::tcltest::originalEnv
    
          DebugPuts   1 "Constraints:"
    
          DebugPArray 1 ::tcltest::testConstraints
    
    + }
    
    + 
    
    + # ::tcltest::loadTestedCommands --
    
    + #
    
    + #Uses the specified script to load the commands to test. Allowed to
    
    + #be empty, as the tested commands could have been compiled into the
    
    + #interpreter.
    
    + #
    
    + # Arguments
    
    + #none
    
    + #
    
    + # Results
    
    + #none
    
    + 
    
    + proc ::tcltest::loadTestedCommands {} {
    
    +     if {$::tcltest::loadScript == {}} {
    
    + return
    
    +     }
    
    + 
    
    +     uplevel #0 $::tcltest::loadScript
    
      }
    
      
    
      # ::tcltest::cleanupTests --
    
    
    PatchFiles:
    
    tcltest.tcl
    
    
    
    
    Before this patch can be applied, new test cases and documentation will need to be added.  It's also unclear to me how the two load flags can/should be used. 
    -- 09/21/1999 jenn
    
    The patch was applied with the tcltest version number remaining at 1.0.
    
    -- 10/20/1999 jenn
    
    
    
  4. foundin changed to: "obsolete: 8.2"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "34. tcltest Package"
  10. title changed to: "Tcltest enhancement"
  11. type changed to: "Bug"