diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | generic/tclTest.c | 106 | ||||
-rw-r--r-- | tests/fileSystem.test | 11 | ||||
-rw-r--r-- | tests/http.test | 4 |
4 files changed, 80 insertions, 50 deletions
@@ -1,3 +1,12 @@ +2003-02-07 Vince Darley <vincentdarley@users.sourceforge.net> + + * generic/tclTest.c: + * tests/fileSystem.text: fixed test 7.2 to avoid a possible + crash, and not change the pwd. + + * tests/http.text: added comment to test 4.15, that it may + fail if you use a proxy server. + 2003-02-06 Mo DeJong <mdejong@users.sourceforge.net> * generic/tclCompCmds.c (TclCompileIncrCmd): diff --git a/generic/tclTest.c b/generic/tclTest.c index c3b52a9..91a1caf 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclTest.c,v 1.58 2003/02/05 12:46:17 vincentdarley Exp $ + * RCS: @(#) $Id: tclTest.c,v 1.59 2003/02/07 11:59:43 vincentdarley Exp $ */ #define TCL_TEST @@ -399,8 +399,7 @@ static Tcl_Channel SimpleOpenFileChannel _ANSI_ARGS_ (( static Tcl_Obj* SimpleListVolumes _ANSI_ARGS_ ((void)); static int SimplePathInFilesystem _ANSI_ARGS_ (( Tcl_Obj *pathPtr, ClientData *clientDataPtr)); -static Tcl_Obj* SimpleCopy _ANSI_ARGS_ ((Tcl_Interp *interp, - Tcl_Obj *pathPtr)); +static Tcl_Obj* SimpleCopy _ANSI_ARGS_ ((Tcl_Obj *pathPtr)); static Tcl_Filesystem testReportingFilesystem = { "reporting", @@ -5744,34 +5743,6 @@ TestFilesystemObjCmd(dummy, interp, objc, objv) return res; } -static int -TestSimpleFilesystemObjCmd(dummy, interp, objc, objv) - ClientData dummy; - Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; -{ - int res, boolVal; - char *msg; - - if (objc != 2) { - Tcl_WrongNumArgs(interp, 1, objv, "boolean"); - return TCL_ERROR; - } - if (Tcl_GetBooleanFromObj(interp, objv[1], &boolVal) != TCL_OK) { - return TCL_ERROR; - } - if (boolVal) { - res = Tcl_FSRegister((ClientData)interp, &simpleFilesystem); - msg = (res == TCL_OK) ? "registered" : "failed"; - } else { - res = Tcl_FSUnregister(&simpleFilesystem); - msg = (res == TCL_OK) ? "unregistered" : "failed"; - } - Tcl_SetResult(interp, msg, TCL_VOLATILE); - return res; -} - static int TestReportInFilesystem(Tcl_Obj *pathPtr, ClientData *clientDataPtr) { @@ -6072,20 +6043,71 @@ SimplePathInFilesystem(Tcl_Obj *pathPtr, ClientData *clientDataPtr) { static Tcl_Interp *simpleInterpPtr = NULL; /* + * This is a very 'hacky' filesystem which is used just so + * test two important features of the vfs code: (1) that + * you can load a shared library from a vfs, (2) that when + * copying files from one fs to another, the 'mtime' is + * preserved. + * + * It reates any file in 'simplefs:/' as a real file, and + * artificially creates a real file on the fly which it uses + * to extract information from. The real file is uses is + * whatever follows the trailing '/' (e.g. 'foo' in 'simplefs:/foo'), + * and that file is assumed to exist in the native pwd, and is + * copied over to the native temporary directory where it is + * accessed. + * + * Please do not consider this filesystem a model of how + * things are to be done. It is quite the opposite! But, it + * does allow us to test two important features. + * + * Finally: this fs can only be used from one interpreter. + */ +static int +TestSimpleFilesystemObjCmd(dummy, interp, objc, objv) + ClientData dummy; + Tcl_Interp *interp; + int objc; + Tcl_Obj *CONST objv[]; +{ + int res, boolVal; + char *msg; + + if (objc != 2) { + Tcl_WrongNumArgs(interp, 1, objv, "boolean"); + return TCL_ERROR; + } + if (Tcl_GetBooleanFromObj(interp, objv[1], &boolVal) != TCL_OK) { + return TCL_ERROR; + } + if (boolVal) { + res = Tcl_FSRegister((ClientData)interp, &simpleFilesystem); + msg = (res == TCL_OK) ? "registered" : "failed"; + simpleInterpPtr = interp; + } else { + res = Tcl_FSUnregister(&simpleFilesystem); + msg = (res == TCL_OK) ? "unregistered" : "failed"; + simpleInterpPtr = NULL; + } + Tcl_SetResult(interp, msg, TCL_VOLATILE); + return res; +} + +/* * Treats a file name 'simplefs:/foo' by copying the file 'foo' * in the current (native) directory to a temporary native file, * and then returns that native file. */ static Tcl_Obj* -SimpleCopy(interp, pathPtr) - Tcl_Interp *interp; /* Interpreter for error reporting; - * can be NULL. */ +SimpleCopy(pathPtr) Tcl_Obj *pathPtr; /* Name of file to copy. */ { int res; CONST char *str; Tcl_Obj *origPtr; - Tcl_Obj *tempPtr = TclpTempFileName(); + Tcl_Obj *tempPtr; + + tempPtr = TclpTempFileName(); Tcl_IncrRefCount(tempPtr); /* @@ -6095,12 +6117,7 @@ SimpleCopy(interp, pathPtr) origPtr = Tcl_NewStringObj(str+10,-1); Tcl_IncrRefCount(origPtr); - if (interp != NULL) { - simpleInterpPtr = interp; - } else { - interp = simpleInterpPtr; - } - res = TclCrossFilesystemCopy(interp, origPtr, tempPtr); + res = TclCrossFilesystemCopy(simpleInterpPtr, origPtr, tempPtr); Tcl_DecrRefCount(origPtr); if (res != TCL_OK) { @@ -6129,7 +6146,7 @@ SimpleOpenFileChannel(interp, pathPtr, mode, permissions) return NULL; } - tempPtr = SimpleCopy(interp, pathPtr); + tempPtr = SimpleCopy(pathPtr); if (tempPtr == NULL) { return NULL; @@ -6156,9 +6173,10 @@ SimpleStat(pathPtr, bufPtr) Tcl_Obj *pathPtr; /* Path of file to stat (in current CP). */ Tcl_StatBuf *bufPtr; /* Filled with results of stat call. */ { - Tcl_Obj *tempPtr = SimpleCopy(NULL, pathPtr); + Tcl_Obj *tempPtr = SimpleCopy(pathPtr); if (tempPtr == NULL) { - return TCL_ERROR; + /* We just pretend the file exists anyway */ + return TCL_OK; } else { int res = Tcl_FSStat(tempPtr, bufPtr); Tcl_DecrRefCount(tempPtr); diff --git a/tests/fileSystem.test b/tests/fileSystem.test index f015270..9a4f1c2 100644 --- a/tests/fileSystem.test +++ b/tests/fileSystem.test @@ -132,7 +132,6 @@ file delete -force dir2.link file delete -force link.file dir.link removeFile [file join dir.file inside.file] removeDirectory dir.file -removeFile gorp.file test filesystem-2.0 {new native path} {unixOnly} { foreach f [lsort [glob -nocomplain /usr/bin/c*]] { @@ -406,12 +405,12 @@ test filesystem-7.1 {load from vfs} {win} { test filesystem-7.2 {cross-filesystem copy from vfs maintains mtime} { set dir [pwd] - cd [file dirname [info script]] - set origtime [file mtime [info script]] - set dir [pwd] + cd [tcltest::temporaryDirectory] + # We created this file several tests ago. + set origtime [file mtime gorp.file] testsimplefilesystem 1 file delete -force theCopy - file copy simplefs:/[file tail [info script]] theCopy + file copy simplefs:/gorp.file theCopy testsimplefilesystem 0 set newtime [file mtime theCopy] file delete theCopy @@ -419,6 +418,8 @@ test filesystem-7.2 {cross-filesystem copy from vfs maintains mtime} { expr {$origtime == $newtime} } {1} +removeFile gorp.file + cleanupTests } namespace delete ::tcl::test::fileSystem diff --git a/tests/http.test b/tests/http.test index 9d33802..b5fb26c 100644 --- a/tests/http.test +++ b/tests/http.test @@ -12,7 +12,7 @@ # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # # -# RCS: @(#) $Id: http.test,v 1.31 2002/10/03 13:34:32 dkf Exp $ +# RCS: @(#) $Id: http.test,v 1.32 2003/02/07 11:59:43 vincentdarley Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 @@ -444,6 +444,8 @@ test http-4.14 {http::Event} { # Bogus host test http-4.15 {http::Event} { + # This test may fail if you use a proxy server. That is to be + # expected and is not a problem with Tcl. set code [catch { set token [http::geturl not_a_host.scriptics.com -timeout 1000 -command {#}] http::wait $token |