.test files are PHP files that modules can include in order to do SimpleTest testing. They are subject to the same coding standards rules as .module/.install/etc. files. Test files are always located in $path_to_module/tests/*.test.

I tried adding this to line 650 but it made my system hang, so I'm not sure where the proper place is to add this.

CommentFileSizeAuthor
#5 coder-test-files-212388-5.patch838 byteswebchick

Comments

webchick’s picture

In looking at the code in Coder module, it looks like maybe instead this should be a hook_reviews implementation in SimpleTest module. But I'm curious about whether or not we can say basically, "Use all of the regular code style rules EXCEPT the following changes" (as for example, setUp and tearDown are perfectly valid function names).

stella’s picture

Do you want to be able to say "apply this rule except to these function names" or "apply all of these rules except x and y"? I don't think either is possible at the minute, but I can have a look at seeing what's involved.

Cheers,
Stella

webchick’s picture

I think "apply all of these rules except x and y." Basically, every single normal rule that applies to all PHP files applies also to SimpleTest tests, except for the noCamelCaseFunctionNames rule.

If we were going to go CRAZY ;) I'd suggest that rulesets were created as classes, and I could derive a subclass that inherited all of the rules of the "CodingStandards" class, but with special rules specifically for SimpleTest. That would be insane, however.

A *really* simple fix for this particular issue might be to apply the "noCamelCaseFunctionNames" to all PHP unless it's in a class definition. This is consistent with the PEAR Coding Standards, on which the Drupal coding standards are based.

douggreen’s picture

The easiest way to do this is to implement another coder rule attribute(s). Just like we have the #module attribute, we should probably have a #file attribute, which only matches certain files. I think that we can make the regex to not match something, so to exclude test files, we'd say '#file' => '!.test$' or something like that. I think that the ! processing will have to be figured out, and we may need to do some special processing for this. Once this is perfected, it should also be added to the #module attribute.

webchick’s picture

Priority: Normal » Critical
Status: Active » Needs review
StatusFileSize
new838 bytes

Well, Dries has officially advocated for testing as a core component of the Drupal 7 release, and since Coder module is our guardian of QA, it looks like this is a bit higher priority now.

This one-liner patch lets Coder scan .test files, but I don't know the code well enough to know if there's a more comprehensive way to do it.

douggreen’s picture

Status: Needs review » Fixed

Thanks! I think that's it. I committed the patch to 5.x and 6.x. However, when looking at the 5.x code, I noticed that it's still looking for .schema files. I think that this was an interim solution, that's no longer used, and never in 5.x. Do we use .schema in 5.x?

webchick’s picture

Nope, we definitely don't. So that can be removed from the 5.x version as well.

Thanks!

douggreen’s picture

removed, thanks!

nancydru’s picture

Yes, there is a schema module back port for 5.x, so it is valid to have schema files in the .install code. I use it to pre-build all my schemas before converting to 6.x and to make sure they are all valid.

douggreen’s picture

Does the 5.x schema module use .schema files?

nancydru’s picture

Yes, it does, and matches them against reality.

douggreen’s picture

ok, thanks nancy, I've restored the processing of .schema files to the 5.x branch.

nancydru’s picture

Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.