• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.
1) ../bin/TestRunner.pl:44 - test_tmpl_form_notext_params(InitFormTests)
Assertion failed!
 at /home/twiki/TWIKI4/lib/Assert.pm line 91
        Assert::ASSERT('') called at /home/twiki/TWIKI4/lib/TWiki.pm line 2559
        TWiki::handleCommonTags('TWiki=HASH(0xd4ef494)', '<style type=\'text/css\' media=\'all\'>\x{a}  @import url(\'%PUBU...', 'TestWeb', '') called at /home/twiki/TWIKI4/lib/TWiki.pm line 2627
        TWiki::addToHEAD('TWiki=HASH(0xd4ef494)', 'JSCALENDAR_HEAD', '<style type=\'text/css\' media=\'all\'>\x{a}  @import url(\'%PUBU...') called at /home/twiki/TWIKI4/lib/TWiki/Func.pm line 1554
        TWiki::Func::addToHEAD('JSCALENDAR_HEAD', '<style type=\'text/css\' media=\'all\'>\x{a}  @import url(\'%PUBU...') called at /home/twiki/TWIKI4/lib/TWiki/Contrib/JSCalendarContrib.pm line 34
        TWiki::Contrib::JSCalendarContrib::addHEAD('twiki') called at /home/twiki/TWIKI4/lib/TWiki/Plugins/DateFieldPlugin.pm line 49
        TWiki::Plugins::DateFieldPlugin::beforeEditHandler('', '', 'TestWeb', 'TWiki::Meta=HASH(0xd3901b4)') called at /home/twiki/TWIKI4/lib/TWiki/Plugin.pm line 246
        TWiki::Plugin::invoke('TWiki::Plugin=HASH(0xd43d010)', 'beforeEditHandler', '', '', 'TestWeb', 'TWiki::Meta=HASH(0xd3901b4)') called at /home/twiki/TWIKI4/lib/TWiki/Plugins.pm line 333
        TWiki::Plugins::_dispatch('TWiki::Plugins=HASH(0xd367590)', 'beforeEditHandler', '', '', 'TestWeb', 'TWiki::Meta=HASH(0xd3901b4)') called at /home/twiki/TWIKI4/lib/TWiki/Plugins.pm line 621
        TWiki::Plugins::beforeEditHandler('TWiki::Plugins=HASH(0xd367590)', '', '', 'TestWeb', 'TWiki::Meta=HASH(0xd3901b4)') called at /home/twiki/TWIKI4/lib/TWiki/UI/Edit.pm line 306
        TWiki::UI::Edit::init_edit('TWiki=HASH(0xd4ef494)', 'myedit') called at /home/twiki/TWIKI4/test/unit/InitFormTests.pm line 189
        InitFormTests::setup_formtests('InitFormTests=HASH(0x8d519d4)', 'TestWeb', '', 'formtemplate="TestWeb.InitTestForm" templatetopic="TestWeb.In...') called at /home/twiki/TWIKI4/test/unit/InitFormTests.pm line 325
        InitFormTests::test_tmpl_form_notext_params('InitFormTests=HASH(0x8d519d4)') called at /usr/local/share/perl/5.8.8/Test/Unit/TestCase.pm line 75
        Test::Unit::TestCase::run_test('InitFormTests=HASH(0x8d519d4)') called at /usr/local/share/perl/5.8.8/Test/Unit/TestCase.pm line 61
        Test::Unit::TestCase::__ANON__() called at /home/twiki/TWIKI4/lib/CPAN/lib//Error.pm line 372
        eval {...} called at /home/twiki/TWIKI4/lib/CPAN/lib//Error.pm line 371
        Error::subs::try('CODE(0xd540b90)', 'HASH(0xd4f0f80)') called at /usr/local/share/perl/5.8.8/Test/Unit/TestCase.pm line 66
        Test::Unit::TestCase::run_bare('InitFormTests=HASH(0x8d519d4)') called at /usr/local/share/perl/5.8.8/Test/Unit/Result.pm line 103
        Test::Unit::Result::__ANON__() called at /usr/local/share/perl/5.8.8/Test/Unit/Result.pm line 119
        Test::Unit::Result::__ANON__() called at /home/twiki/TWIKI4/lib/CPAN/lib//Error.pm line 379
        eval {...} called at /home/twiki/TWIKI4/lib/CPAN/lib//Error.pm line 371
        Error::subs::try('CODE(0xa50f6e4)', 'HASH(0xd313958)') called at /usr/local/share/perl/5.8.8/Test/Unit/Result.pm line 133
        Test::Unit::Result::run_protected('Test::Unit::Result=HASH(0x8a416d8)', 'InitFormTests=HASH(0x8d519d4)', 'CODE(0xac5d21c)') called at /usr/local/share/perl/5.8.8/Test/Unit/Result.pm line 107
        Test::Unit::Result::run('Test::Unit::Result=HASH(0x8a416d8)', 'InitFormTests=HASH(0x8d519d4)') called at /usr/local/share/perl/5.8.8/Test/Unit/TestCase.pm line 51
        Test::Unit::TestCase::run('InitFormTests=HASH(0x8d519d4)', 'Test::Unit::Result=HASH(0x8a416d8)', 'Test::Unit::TestRunner=HASH(0x8151c28)') called at /usr/local/share/perl/5.8.8/Test/Unit/TestSuite.pm line 278
        Test::Unit::TestSuite::run('Test::Unit::TestSuite=HASH(0x8d39d4c)', 'Test::Unit::Result=HASH(0x8a416d8)', 'Test::Unit::TestRunner=HASH(0x8151c28)') called at /usr/local/share/perl/5.8.8/Test/Unit/TestSuite.pm line 278
        Test::Unit::TestSuite::run('TWikiUnitTestsSuite=HASH(0x8a41594)', 'Test::Unit::Result=HASH(0x8a416d8)', 'Test::Unit::TestRunner=HASH(0x8151c28)') called at /usr/local/share/perl/5.8.8/Test/Unit/TestRunner.pm line 54
        Test::Unit::TestRunner::do_run('Test::Unit::TestRunner=HASH(0x8151c28)', 'TWikiUnitTestsSuite=HASH(0x8a41594)', 0) called at /usr/local/share/perl/5.8.8/Test/Unit/TestRunner.pm line 183
        Test::Unit::TestRunner::start('Test::Unit::TestRunner=HASH(0x8151c28)', 'TWikiSuite.pm') called

Test was not successful.

Looks like the TWiki object has not topic defined (undef ->{topicName})

CC

Funny. They pass OK on my test computer

KJL

You probably don't have asserts enabled. The test definitely fails.

CC

And how do I enable asserts? This is beyond what my knowledge covers.

What did I miss in TWiki:Codev.TestCasesTutorial?

KJL

As described in TWiki:Codev.TestCasesTutorial (now)

CC

Hmm. Strange.

You write in the new text in the tutorial that the unit test case enables asserts automatically.

And it does look like that when running the test.

# perl ../bin/TestRunner.pl InitFormTests.pm
exporting TWIKI_ASSERTS=1 for extra checking; disable by exporting TWIKI_ASSERTS=0
Assert checking on 1
..........
Time:  2 wallclock secs ( 1.34 usr  0.47 sys +  0.08 cusr  0.48 csys =  2.37 CPU)

OK (10 tests)

But I went ahead and added the $ENV{TWIKI_ASSERTS}=1; to the top of LocalLib.cfg.

and then I get a similar error output like you.

There was 1 error:
1) ../bin/TestRunner.pl:44 - test_tmpl_form_notext_params(InitFormTests)
Assertion failed!
 at /var/www/twiki/lib/Assert.pm line 92
 Assert::ASSERT('') called at /var/www/twiki/lib/TWiki.pm line 2560
 TWiki::handleCommonTags('TWiki=HASH(0x920d3e8)', '%FORMFIELDS%\x{a}', 'TestWeb', '') called at /var/www/twiki/lib/TWiki/UI/Edit.pm line 319
 TWiki::UI::Edit::init_edit('TWiki=HASH(0x920d3e8)', 'myedit') called at /var/www/MAIN/test/unit/InitFormTests.pm line 189
 InitFormTests::setup_formtests('InitFormTests=HASH(0x8d9c088)', 'TestWeb', '', 'formtemplate="TestWeb.InitTestForm" templatetopic="TestWeb.In...') called at /var/www/MAIN/test/unit/InitFormTests.pm line 325
 InitFormTests::test_tmpl_form_notext_params('InitFormTests=HASH(0x8d9c088)') called at /usr/lib/perl5/site_perl/5.8.5/Test/Unit/TestCase.pm line 75
 Test::Unit::TestCase::run_test('InitFormTests=HASH(0x8d9c088)') called at /usr/lib/perl5/site_perl/5.8.5/Test/Unit/TestCase.pm line 61
 Test::Unit::TestCase::__ANON__() called at /var/www/twiki/lib/CPAN/lib//Error.pm line 372
 eval {...} called at /var/www/twiki/lib/CPAN/lib//Error.pm line 371
 Error::subs::try('CODE(0x9928bf4)', 'HASH(0x8ef6d20)') called at /usr/lib/perl5/site_perl/5.8.5/Test/Unit/TestCase.pm line 66
 Test::Unit::TestCase::run_bare('InitFormTests=HASH(0x8d9c088)') called at /usr/lib/perl5/site_perl/5.8.5/Test/Unit/Result.pm line 103
 Test::Unit::Result::__ANON__() called at /usr/lib/perl5/site_perl/5.8.5/Test/Unit/Result.pm line 119
 Test::Unit::Result::__ANON__() called at /var/www/twiki/lib/CPAN/lib//Error.pm line 379
 eval {...} called at /var/www/twiki/lib/CPAN/lib//Error.pm line 371
 Error::subs::try('CODE(0x96f3f4c)', 'HASH(0x96f50f8)') called at /usr/lib/perl5/site_perl/5.8.5/Test/Unit/Result.pm line 133
 Test::Unit::Result::run_protected('Test::Unit::Result=HASH(0x8d9c118)', 'InitFormTests=HASH(0x8d9c088)', 'CODE(0x96f3ee0)') called at /usr/lib/perl5/site_perl/5.8.5/Test/Unit/Result.pm line 107
 Test::Unit::Result::run('Test::Unit::Result=HASH(0x8d9c118)', 'InitFormTests=HASH(0x8d9c088)') called at /usr/lib/perl5/site_perl/5.8.5/Test/Unit/TestCase.pm line 51
 Test::Unit::TestCase::run('InitFormTests=HASH(0x8d9c088)', 'Test::Unit::Result=HASH(0x8d9c118)', 'Test::Unit::TestRunner=HASH(0x8d83c20)') called at /usr/lib/perl5/site_perl/5.8.5/Test/Unit/TestSuite.pm line 278
 Test::Unit::TestSuite::run('Test::Unit::TestSuite=HASH(0x96f3348)', 'Test::Unit::Result=HASH(0x8d9c118)', 'Test::Unit::TestRunner=HASH(0x8d83c20)') called at /usr/lib/perl5/site_perl/5.8.5/Test/Unit/TestRunner.pm line 54
 Test::Unit::TestRunner::do_run('Test::Unit::TestRunner=HASH(0x8d83c20)', 'Test::Unit::TestSuite=HASH(0x96f3348)', 0) called at /usr/lib/perl5/site_perl/5.8.5/Test/Unit/TestRunner.pm line 183
 Test::Unit::TestRunner::start('Test::Unit::TestRunner=HASH(0x8d83c20)', 'InitFormTests.pm') called

So something to fix - yes.

And maybe also later find out why running the unit tests does not enable asserts.

KJL


That's easy: The unit tests do everything to convince you that they enable asserts by printing

exporting TWIKI_ASSERTS=1 for extra checking; disable by exporting TWIKI_ASSERTS=0
Assert checking on 1
...but that's a plain lie.

There's a line in test/bin/TestRunner.pl just before these print statements which is responsible for the behaviour:

use TWiki;   # If you take this out then TestRunner.pl will fail on IndigoPerl

...but if you use TWiki, then that happens at compile time, before the environment variable is set at runtime. TWiki.pm uses Assert.pm without $ENV{TWiki_ASSERTS} set if you don't do it manually.

If you comment out that line then assertions work as they should. For IndigoPerl another route should be investigated.

-- HJ

On the actual problem.

I do not have a solution but I see where things go wrong.

It starts at InitFormTests.pm line line 325.

my $text = setup_formtests( $this, $testweb, "", "formtemplate=\"$testweb.$testform\" templatetopic=\"$testweb.$testtmpl\" IssueName=\"My first defect\" IssueDescription=\"Simple description of problem\" IssueType=\"Enhancement\" History1=\"%ATTACHURL%\" History2=\"%ATTACHURL%\" History3=\"\$percntATTACHURL%\" History4=\"\$percntATTACHURL%\" text=\"\"" );

Note the 3rd parameter is ""

The setup_formtests starts like this (line 173)..

sub setup_formtests {
  my ( $this, $web, $topic, $params ) = @_;

  $twiki->{webName} = $web;
  $twiki->{topicName} = $topic;

So the topic is never set!

And a little further down in line 189

my ( $text, $tmpl ) = TWiki::UI::Edit::init_edit( $twiki, 'myedit' );

So we rush to lib/UI/Edit.pm and find the init_edit sub and it starts like

sub init_edit {
    my ( $session, $templateName )  = @_;

    my $query = $session->{cgiQuery};
    my $webName = $session->{webName};
    my $topic = $session->{topicName};
    my $user = $session->{user};

So the $topic is never set.

$topic is used quite many places in init_edit and it does not seem like this sub is supposed to work without a $topic defined. If it is it is not documented in any comments.

At line 319 we get ready for the kill. We call

    $tmpl = $session->handleCommonTags( $tmpl, $webName, $topic );

So we rush to lib/TWiki.pm where we find at line 2555

sub handleCommonTags {
    my( $this, $text, $theWeb, $theTopic ) = @_;

    ASSERT($this->isa( 'TWiki')) if DEBUG;
    ASSERT($theWeb) if DEBUG;
    ASSERT($theTopic) if DEBUG;

So no $theTopic and we have the error.

What I cannot see is why the author of the unit test case tried to call the function without a topic name defined.

But it seems like this is a test case error more than a code error to me.

Last step in the analysis is to blame it on someone with svn blame. wink

12444 ThomasWeigert   my $text = setup_formtests( $this, $testweb, "", "formtemplate=\"$testweb.$testform\" templatetopic=\"$testweb.$testtmpl\" IssueName=\"My first defect\" IssueDescription=\"Simple description of problem\" IssueType=\"Enhancement\" History1=\"%ATTACHURL%\" History2=\"%ATTACHURL%\" History3=\"\$percntATTACHURL%\" History4=\"\$percntATTACHURL%\" text=\"\"" );

KJL

Based on my analysis above I am not considering this a release blocker. Downgrading to normal.

KJL


Sorry, did not notice this excitement... will handle..... -- TW
Look at the analysis above....

I am not sure why you think this is a problem. Based on my experience, I don't think it is required that a $web or $topic are passed to handleCommonTags. Maybe these ASSERT are a little to overzelous? -- TW


They are presented in the documentation as required parameters. so you should honour that. They are required for a good reason; they are used in expanding tags, and if you don't provide values, some tag will expand incorrectly. They are also passed on to plugins, which may go belly-up if they are not present.

CC

As of 13599, these tests pass, so closing this.

CC

ItemTemplate
Summary InitFormTests fail
ReportedBy TWiki:Main.ThomasWeigert, TWiki:Main.CrawfordCurrie
Codebase

SVN Range TWiki-4.1.0, Wed, 10 Jan 2007, build 12474
AppliesTo Engine
Component

Priority Normal
CurrentState Closed
WaitingFor

Checkins

TargetRelease n/a
ReleasedIn

Edit | Attach | Watch | Print version | History: r18 < r17 < r16 < r15 < r14 | Backlinks | Raw View |  Raw edit | More topic actions
Topic revision: r18 - 2007-05-01 - TWikiUserMapping_CrawfordCurrie
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback