Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2002-06-06
22:22 • Closed ticket [558742ffff]: tcltest creates 'tmp' in current dir plu... artifact: f201fd3422 user: dgp
2002-06-01
05:50 • Ticket [558742ffff]: 4 changes artifact: 7a0ee9b52d user: dgp
05:44 • Ticket [558742ffff]: 4 changes artifact: 58e7b23d91 user: dgp
2002-05-22
11:45 • Ticket [558742ffff]: 1 change artifact: a4598b463f user: dgp
2002-05-21
15:56 • New ticket [558742ffff]. artifact: f4850fdf58 user: vincentdarley

tcltest creates 'tmp' in current dir

Closed / Fixed558742ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 24 years ago
Descriptionplain2002-05-21 15:56:48
The tcltest package tries to create a file 'tmp' in 
the pwd.  This is particularly problematic when 'pwd' 
is inside a vfs (which can easily happen since tcltest 
is actually a part of default tclkit executables).

Furthermore, under some circumstances, even if 
the 'tmp' file is created, it is not cleaned up.

The problematic code is around line 1179 of 
tcltest.tcl:

    testConstraint stdio 0
    catch {
catch {file delete -force tmp}
set f [open tmp w]
puts $f {
    exit
}
close $f

set f [open "|[list [interpreter] tmp]" r]
close $f

testConstraint stdio 1
    }
    catch {file delete -force tmp}

Problems observed are:

(i) assumption that 'tmp' is in the native filesystem 
and therefore that 'open |' will work.
(ii) assumption that 'puts $f ...' will not fail -- if 
it does, then '$f' is never closed.

It would be best if 'tmp' was put in $env(TEMP), ...
dgp Ticket [558742ffff]: 1 change [History diff]2002-05-22 11:45:36
dgpplain2002-06-01 05:44:46
Logged In: YES 
user_id=80530

A number of things are at play here.

The assumption (i) noted above is actually
what is being tested.  The "stdio" constraint
is supposed to indicate that the [interpreter]
can be launched as a pipeline, according to the docs.

   ASIDE: very strange name if you ask me, this was not
   at all obvious to me, and I re-invented this constraint
   in the main.test as "exec" (sort of).

Still, there really is no need to write a script file
to test pipeline launching.  One could as easily send
the [exit] command through the pipeline to stdin.

Even if a temp file is needed, tcltest already has
[makeFile] and [removeFile] for that purpose, and
should use them.  They write files to [temporaryDirectory]
which is tcltest's version of $env(TEMP).  A request that
the default value of [temporaryDirectory] should be
$env(TEMP) should be a separate report.

It's not clear to me why the final

catch {file delete -force tmp}

is not removing the tmp, though.  Something subtle
in a VFS?
dgpplain2002-06-01 05:50:03
Logged In: YES 
user_id=80530

Forgot to mention that the whole shebang is in
[InitConstraints], which is itself a design mistake.
As noted in Patch 512214, tcltest currently forces
all of its built-in constraints to be initialized
whether or not the tester is going to use them.
Would be much better to have the user request 
initialization of constraints by name, or at least
have them lazily initialized when needed.  I believe
this large amount of unnecessary initialization is
a big reason the tcltest.test of Tcl's test suite
is sooooooo sloooooowwwww...
dgpplain2002-06-06 22:22:47
Logged In: YES 
user_id=80530

Patch 512214 fixes this. committed.
Log in (anonymous is fine) to add a comment.