Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2002-06-26
11:05 • Ticket [541637ffff] {puts stdout $msg} fails inside test status still Closed... artifact: ecdb3685de user: kenstir
08:11 • Closed ticket [541637ffff]. artifact: 0df67f45cb user: dgp
07:41 • Ticket [541637ffff]: 4 changes artifact: 009059f668 user: dgp
2002-04-19
04:39 • Ticket [541637ffff]: 1 change artifact: 2fab412995 user: dgp
2002-04-11
08:10 • Ticket [541637ffff]: 1 change artifact: b06d6c1182 user: dgp
2002-04-10
00:26 • Ticket [541637ffff]: 4 changes artifact: f818dfd275 user: kenstir
00:26 • Add attachment foo.patch to ticket [541637ffff] artifact: cd256cc62b user: kenstir
00:25 • Ticket [541637ffff] {puts stdout $msg} fails inside test status still Open w... artifact: 2825ba90bf user: kenstir
00:25 • Add attachment foo.test to ticket [541637ffff] artifact: a9d30f9921 user: kenstir
2002-04-09
17:25 • New ticket [541637ffff] {puts stdout $msg} fails inside test. artifact: abe1cf68ac user: kenstir

{puts stdout $msg} fails inside test

Closed / Wont Fix541637ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 24 years ago
Descriptionplain2002-04-09 17:25:41
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
kenstirplain2002-04-10 00:25:41
File Added - 20867: foo.test
kenstirplain2002-04-10 00:26:17
File Added - 20868: foo.patch
dgp Ticket [541637ffff]: 1 change [History diff]2002-04-11 08:10:34
dgp Ticket [541637ffff]: 1 change [History diff]2002-04-19 04:39:02
dgpplain2002-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...
dgpplain2002-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.
kenstirplain2002-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
Log in (anonymous is fine) to add a comment.

Attachments: