Item1247: assert_matches and assert_does_not_match test in list context, therefore are wrong

pencil
Priority: Urgent
Current State: Closed
Released In: 1.0.4
Target Release: patch
Applies To: Engine
Component: UnitTestContrib
Branches:
Reported By: OlivierRaginel
Waiting For:
Last Change By: KennethLavrsen
assert_matches and assert_does_not_match use the ~ and operator in list context, which is bad.

Made a table for easy assigning so we can collaborate on fixing these:
Module Failures Assigned to Status
RequestTests 8 OlivierRaginel Fixed, buggy test with -path
ExceptionTests 4 OlivierRaginel Fixed. Template was missing PARAM5
TWikiFuncTests 2 OlivierRaginel Fixed, buggy test
RegisterTests 122 OlivierRaginel Fixed, buggy test (missing parameter to assert_matches, and/or assuming ->stringify encodes @ to its HTML equivalent @)
HierarchicalWebsTests 6 OlivierRaginel Test was still using class="foswikiLink" for <a>
FuncTests 2 OlivierRaginel Fixed, buggy test
PreferencesPluginTests 2 OlivierRaginel Fixed, buggy test
CommentPluginTests 2 OlivierRaginel Fixed, buggy test
WysiwygPluginTests 16 CrawfordCurrie Fixed, buggy test
Only in trunk
StoreSmokeTests 4 OlivierRaginel Fixed. Test was using foswikiConflict whereas it was still twikiConflict in the code. Now it's all fatwilly'd
Fn_WEBLIST 4 OlivierRaginel Fixed, buggy test
Fn_SEARCH 6 CrawfordCurrie Fixed, buggy test

-- Babar

Therefore, all tests that are using this and provide a description will never fail, as the description will be tested as the test, and the failing test will be lost by the comma operator.

Demonstration:
$ perl -wle 'my $a="foo";sub assert{my($test,$comment)=@_;print "Testing $test: $comment\n";}assert( $a =~ /bar/, "Should fail" )'
Use of uninitialized value $comment in concatenation (.) or string at -e line 1.
Testing Should fail: 

$ perl -wle 'my $a="foo";sub assert{my($test,$comment)=@_;print "Testing $test: $comment\n";}assert( scalar( $a =~ /bar/ ), "Should fail" )'
Testing : Should fail

This shows also that the fix is really simple: force scalar context for =~.

I did it on trunk, and it exposes loads of failures ... frown, sad smile

95 failures
ExceptionTests::test_redirectOopsException
ExceptionTests::test_oopsScript
Fn_SEARCH::verify_quote_word_ForkingSearch
Fn_SEARCH::verify_quote_word_PurePerlSearch
Fn_SEARCH::verify_quote_word_BruteForceQuery
FuncTests::test_getExternalResource
FuncTests::test_getViewUrl
FuncUsersTests::verify_topic_meta_usermapping_NoLoginManager_AllowLoginName_NonePasswordManager_TopicUserMapping
FuncUsersTests::verify_topic_meta_usermapping_NoLoginManager_AllowLoginName_HtPasswordPasswordManager_TopicUserMapping
FuncUsersTests::verify_topic_meta_usermapping_ApacheLoginManager_AllowLoginName_NonePasswordManager_TopicUserMapping
FuncUsersTests::verify_topic_meta_usermapping_ApacheLoginManager_AllowLoginName_HtPasswordPasswordManager_TopicUserMapping
FuncUsersTests::verify_topic_meta_usermapping_TemplateLoginManager_AllowLoginName_NonePasswordManager_TopicUserMapping
FuncUsersTests::verify_topic_meta_usermapping_TemplateLoginManager_AllowLoginName_HtPasswordPasswordManager_TopicUserMapping
HierarchicalWebsTests::test_squab_subweb_wih_topic
HierarchicalWebsTests::test_squab_path_to_topic_in_subweb
HierarchicalWebsTests::test_WEBLIST_all
HierarchicalWebsTests::test_squab_full_path_with_topic
RegisterTests::test_3951
RegisterTests::verify_userTopicWithoutPMWithForm_TemplateLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_registerBadVerify_TemplateLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_duplicateActivation_TemplateLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_resetEmailOkay_TemplateLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_resetPasswordNoPassword_TemplateLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_resetPasswordOkay_TemplateLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_resetPassword_NoWikiUsersEntry_TemplateLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_userTopicWithoutPMWithoutForm_TemplateLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_userTopicWithPMWithoutForm_TemplateLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_userTopicWithPMWithForm_TemplateLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_userTopicWithoutPMWithForm_TemplateLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_registerBadVerify_TemplateLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_duplicateActivation_TemplateLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_resetEmailOkay_TemplateLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_resetPasswordNoPassword_TemplateLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_resetPasswordOkay_TemplateLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_resetPassword_NoWikiUsersEntry_TemplateLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_userTopicWithoutPMWithoutForm_TemplateLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_userTopicWithPMWithoutForm_TemplateLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_userTopicWithPMWithForm_TemplateLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_userTopicWithoutPMWithForm_ApacheLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_registerBadVerify_ApacheLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_duplicateActivation_ApacheLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_resetEmailOkay_ApacheLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_resetPasswordNoPassword_ApacheLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_resetPasswordOkay_ApacheLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_resetPassword_NoWikiUsersEntry_ApacheLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_userTopicWithoutPMWithoutForm_ApacheLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_userTopicWithPMWithoutForm_ApacheLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_userTopicWithPMWithForm_ApacheLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_userTopicWithoutPMWithForm_ApacheLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_registerBadVerify_ApacheLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_duplicateActivation_ApacheLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_resetEmailOkay_ApacheLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_resetPasswordNoPassword_ApacheLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_resetPasswordOkay_ApacheLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_resetPassword_NoWikiUsersEntry_ApacheLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_userTopicWithoutPMWithoutForm_ApacheLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_userTopicWithPMWithoutForm_ApacheLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_userTopicWithPMWithForm_ApacheLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_userTopicWithoutPMWithForm_NoLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_registerBadVerify_NoLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_duplicateActivation_NoLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_resetEmailOkay_NoLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_resetPasswordNoPassword_NoLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_resetPasswordOkay_NoLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_resetPassword_NoWikiUsersEntry_NoLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_userTopicWithoutPMWithoutForm_NoLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_userTopicWithPMWithoutForm_NoLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_userTopicWithPMWithoutForm_NoLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_userTopicWithPMWithForm_NoLoginManager_AllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_userTopicWithoutPMWithForm_NoLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_registerBadVerify_NoLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_duplicateActivation_NoLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_resetEmailOkay_NoLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_resetPasswordNoPassword_NoLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_resetPasswordOkay_NoLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_resetPassword_NoWikiUsersEntry_NoLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_userTopicWithoutPMWithoutForm_NoLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_userTopicWithPMWithoutForm_NoLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RegisterTests::verify_userTopicWithPMWithForm_NoLoginManager_DontAllowLoginName_HtPasswdManager_TopicUserMapping
RequestTests::test_url_cgi_suffix
RequestTests::test_url_no_suffix
RequestTests::test_url_alien_suffix
RequestTests::test_url_pl_suffix
StoreSmokeTests::verify_releaselocksonsave_RcsLite
StoreSmokeTests::verify_releaselocksonsave_RcsWrap
CommentPluginTests::test_LocationRE
PreferencesPluginTests::test_save
WysiwygPluginTests::test_restHTML2TML_undef
WysiwygPluginTests::test_restTML2HTML_undef
WysiwygPluginTests::test_restHTML2TML_utf_8
WysiwygPluginTests::test_restHTML2TML_iso_8859_15
WysiwygPluginTests::test_restTML2HTML_utf_8
WysiwygPluginTests::test_restTML2HTML_iso_8859_1
WysiwygPluginTests::test_restHTML2TML_iso_8859_1
WysiwygPluginTests::test_restTML2HTML_iso_8859_15
TWikiFuncTests::test_getViewUrl
1460 of 1555 test cases passed

-- OlivierRaginel - 11 Mar 2009

Thank you Crawford for your support!

-- OlivierRaginel - 11 Mar 2009

Re-opening as I had issues with a perl 5.8 bug: http://rt.perl.org/rt3/Public/Bug/Display.html?id=22354

-- OlivierRaginel - 14 Mar 2009
Topic revision: r40 - 15 Mar 2009, KennethLavrsen
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy