Tcl Source Code

View Ticket
Login
Ticket UUID: 541637
Title: {puts stdout $msg} fails inside test
Type: Patch Version: None
Submitter: kenstir Created on: 2002-04-09 17:25:41
Subsystem: 34. tcltest Package Assigned To: dgp
Priority: 6 Severity:
Status: Closed Last Modified: 2002-06-26 11:05:56
Resolution: Wont Fix Closed By: kenstir
    Closed on: 2002-06-26 04:05:56
Description:
If you run the attached foo.test, you'll get an error
(against CVS HEAD as of today).  There are three things
wrong and I could only figure out how to fix two:

1) [outputChannel] doesn't work from within
tcltest::replace namespace.  Fixed by specifying
complete namespace.

2) We don't want to append the output to outData twice.
 Fixed by calling return after figuring out we could
handle the puts.

3) The test now runs but still doesn't pass.  Somehow
the [concat] inside tcltest::test is stripping the
newline from the -output option.  I don't understand
why the concat is done so I'm not sure the best way to
fix it.

Hopefully this 2/3 patch is useful.

Regards, a tcltest fan,
Ken
User Comments: kenstir added on 2002-06-26 11:05:56:
Logged In: YES 
user_id=246646

Yes, the other issues are fixed in the cvs HEAD.

And thank you for your advice on issue 3.  I will heed it,
go forward, and prosper, using the simpler first syntax.  I
was drawn astray by the siren song of the braced syntax.  It
looked so expect-like and friendly, I should have known it
was a trap.

Thanks and regards,
Ken Cox

dgp added on 2002-06-26 08:11:36:
Logged In: YES 
user_id=80530


uggghhhh.  Issue 3 has to do with how to interpret the second
form of the tcltest::test command.  tcltest::test recognizes two
documented syntaxes:

    test $name $description ?$opt $val ...?

and

    test $name $description $singleArgumentToBeParsed

Supposedly the second form is helpful because it lets one
enclose everything in braces and avoid a lot of backslash
quoting
of newlines.  Trouble is that the rules for parsing that single
argument (what substitutions are done?  in what context?) are
never documented clearly, and the code that implements that
parsing is a maze of obfuscation.  I think the code is probably
wrong, but I think it's wrong to even offer the second syntax.
Tcl has simple quoting rules; why muck up this command with
its own undocumented special parsing syntax.

The backslash newline issues can be just about completely
addressed by a coding convention that places the newlines
within arguments that are brace-quoted anyway.  See
main.test for an example.

But, I'm not going to change that now.  Whatever voodoo is
in there, there must be some test suite somewhere that's
using it, so I don't dare change it.  Indeed when I disabled
the [concat] voodoo, tests in the Tcl test suite indeed did 
begin to fail.

Instead, I just recommend that you do not use the second
syntax in your own test suites.  It is documented that
the two forms can behave differently.  From my perspective,
the first form is predictable (if you know Tcl substitution
rules);
the second form is not.  As you've discovered, the second
form can cause the dropping of trailing whitespace that can
be important.

Rewrite your foo.test as:

  test CLR-1.1 {...} -body {
    puts stdout here...
  } -result {} -output "here\n"

and go forward and prosper.

dgp added on 2002-06-26 07:41:03:
Logged In: YES 
user_id=80530

I believe the first 2 issues are corrected in tcltest 2.1.
please test again.

I'm looking into 3 now...

kenstir added on 2002-04-10 00:26:17:

File Added - 20868: foo.patch

kenstir added on 2002-04-10 00:25:41:

File Added - 20867: foo.test

Attachments: