#1885 tcltest creates 'tmp' in current dir


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

testConstraint stdio 0
catch {
catch {file delete -force tmp}
set f [open tmp w]
puts $f {
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), ...


  • Don Porter

    Don Porter - 2002-05-22
    • assigned_to: dkf --> dgp
  • Don Porter

    Don Porter - 2002-05-31

    Logged In: YES

    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?

  • Don Porter

    Don Porter - 2002-05-31

    Logged In: YES

    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...

  • Don Porter

    Don Porter - 2002-06-06

    Logged In: YES

    Patch 512214 fixes this. committed.

  • Don Porter

    Don Porter - 2002-06-06
    • status: open --> closed-fixed

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks