Closed
Bug 324014
Opened 19 years ago
Closed 16 years ago
Testing suite (runtests.pl) needs to check Bugzilla->params usage to assure valid params
Categories
(Bugzilla :: Testing Suite, enhancement, P2)
Bugzilla
Testing Suite
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: u197037, Unassigned)
Details
Attachments
(1 file, 3 obsolete files)
5.68 KB,
patch
|
LpSolit
:
review-
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8) Gecko/20051219 Firefox/1.5
Build Identifier: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8) Gecko/20051219 Firefox/1.5
runtests.pl does not check for unused/misused parameters accessed via Param() method.
Reproducible: Always
Steps to Reproduce:
run ./runtests.pl
Actual Results:
None
Expected Results:
Report about misused parameters
Frederik, Could you please confirm the bug, reassign it to me and review the patch?
Attachment #208967 -
Flags: review?(LpSolit)
![]() |
||
Updated•19 years ago
|
Assignee: zach → dennis.melentyev
Status: UNCONFIRMED → NEW
Ever confirmed: true
![]() |
||
Comment 2•19 years ago
|
||
Comment on attachment 208967 [details] [diff] [review]
Initial version of patch
run your test on tip and you will notice a full list of errors.
Moreover, it doesn't catch this syntax, see process_bug.cgi:
my $ret = Param( "commenton" . $function );
Attachment #208967 -
Flags: review?(LpSolit) → review-
(In reply to comment #2)
...
> Moreover, it doesn't catch this syntax, see process_bug.cgi:
>
> my $ret = Param( "commenton" . $function );
Well I have no idea of how to test that. In order to do that, I will need also check for all possible values of $function.
M.b. I do need some sort of exceptions :/
Also, handling of rows like this one:
if (Param("mail_delivery_method") eq "sendmail" && !Param("sendmailnow"))
is quite complicated.
But in general, does the thing work right way?
Status: NEW → ASSIGNED
Revised version to process multiple Param("parname") functions in one line.
Added processing of files, excluded in %Support::Files::exclude_deps
Added hacks to not mention hackish processing of commenton* parameters in process_bug.cgi
Attachment #208967 -
Attachment is obsolete: true
Attachment #209691 -
Flags: review?(LpSolit)
Reworked variant:
Added non-critical warnings about [probably] unused parameters, usage of parameters with variables in their names including ones in templates.
Attachment #209691 -
Attachment is obsolete: true
Attachment #209714 -
Flags: review?(LpSolit)
Attachment #209691 -
Flags: review?(LpSolit)
![]() |
||
Updated•19 years ago
|
Target Milestone: --- → Bugzilla 2.20
![]() |
||
Comment 6•19 years ago
|
||
I didn't look at the script in great details yet, but here are some remarks already:
- Results about files should be displayed as soon as a file has been analyzed instead of waiting that all files have been analyzed. That's the way all other test scripts work (and this also avoid a long delay with no output).
- Most subroutines are called only once and some of them are one-liners. This doesn't make sense to me, this is confusing and makes the code harder to read. Please move the code inline.
![]() |
||
Comment 7•19 years ago
|
||
Comment on attachment 209714 [details] [diff] [review]
reworked error level handling
per my previous comment
Attachment #209714 -
Flags: review?(LpSolit)
![]() |
||
Comment 8•19 years ago
|
||
Two more things:
- __END__ always is at the beginning of the line, so the regexp should look for /^__END__/
- Be sure to correctly filter comments. # Param('inexistant_param') should not be detected as it's in a comment.
Fixed things:
1. /^__END__/
2. eval Test::More -> plan tests => $tests
3. CGI commandline hack removed
4. one-liners eliminated
5. ok(1,$file) got more text
6. comments got stripped before search for Param("blah")
7. Anything else I forgot?
Attachment #209714 -
Attachment is obsolete: true
Attachment #213739 -
Flags: review?(LpSolit)
![]() |
||
Comment 10•19 years ago
|
||
Comment on attachment 213739 [details] [diff] [review]
Fred's comments fixed
>+use Bugzilla::Constants;
>+use Bugzilla::Config qw(:DEFAULT :admin :params $datadir);
>+use Bugzilla::Config::Common;
>+use vars qw(@parampanels);
You only need :params from Config.pm. You don't the other lines or arguments.
>+# Hackaround to add files excluded by Support::Files::exclude_deps back
>+my @to_add = ();
>+foreach my $file (values %Support::Files::exclude_deps) {
>+ push @to_add, @$file;
>+}
Do not include excluded files, by definition. Tests should be based on what the installation is running. If you want to include all files, then install all required Perl modules.
>+# Define files to test. Each file would have a list of error messages, if any.
>+my @testitems = @Support::Files::testitems;
>+for my $path (@Support::Templates::include_paths) {
>+ push(@testitems, map(File::Spec->catfile($path, $_),
>+ Support::Templates::find_actual_files($path)));
>+}
Shouldn't you use $include_path{$langdir} as in 004template.t? Else you are scanning the template/ directory twice, aren't you?
>+# Find Param() usage
>+my %results = ();
>+foreach my $file (@testitems) {
IMO, you should scan files in the usual way, i.e. as other tests do (and not as you did in 012throwables.t).
>+ # Check for of undefined params in use
>+ foreach my $param (keys %file_params) {
>+ if (!defined $params{$param}{defined_in}) {
>+ $results{$file}{errtype} = $errtype;
>+ my $message = "--ERROR: ";
>+ $message = "--WARNING: Possible use of variables! Check this manually!\n"
>+ if $errtype;
I noted that if one parameter gets a WARNING because it's a variable and another one gets an ERROR because it's undefined, then both parameters get an ERROR.
>+sub Report {
>+ my ($file, $errtype, @errors) = @_;
>+ if (scalar @errors) {
>+ ok($errtype, "$file has ". scalar @errors ." " . ($errtype ? "warning" : "error") . "(s):\n" . join("\n", @errors));
If you report errors and warning as soon as they are detected, you probably don't need this routine.
Moreover, as you can use variables in Param(), you shouldn't report unsused parameters from Config/*.pm modules. This is confusing (e.g. all these commentonfoo parameters used in process_bug.cgi). IMO, this script should *only* report undefined parameters, not unused ones. This would simplify your test script a bit.
Attachment #213739 -
Flags: review?(LpSolit) → review-
![]() |
||
Comment 11•19 years ago
|
||
(In reply to comment #10)
> You only need :params from Config.pm. You don't the other lines or arguments.
Missing word: You don't *need* the other lines...
![]() |
||
Comment 12•19 years ago
|
||
Only security and dataloss fixes will be accepted on the 2.20 branch.
Target Milestone: Bugzilla 2.20 → Bugzilla 2.22
Updated•18 years ago
|
Priority: -- → P2
Summary: Testing suite (runtests.pl) need to check Param() usage → Testing suite (runtests.pl) needs to check Bugzilla->params usage to assure valid params
Target Milestone: Bugzilla 2.22 → Bugzilla 3.0
![]() |
||
Comment 13•17 years ago
|
||
Note that you have no chance now to catch invalid params as we sometimes write:
my $changes = Bugzilla->params;
my $foo = $params->{foo};
and so you won't be able to catch $params->{foo} as you have no way to know what $params is.
Reporter | ||
Comment 14•16 years ago
|
||
re-assign to default, since there were no time to work on Bugzilla in last two years, sorry.
Assignee: dennis.melentyev → testing
![]() |
||
Comment 15•16 years ago
|
||
WONTFIX per comment 13.
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → WONTFIX
Target Milestone: Bugzilla 3.0 → ---
You need to log in
before you can comment on or make changes to this bug.
Description
•