2 problems - the code comments for this script are wrong. Also, it should NOT have a .sh ending, since by design for any such file our .htaccess gives us a 403

Forbidden
You don't have permission to access /drupal-7/scripts/run-functional-tests.sh on this server.

The code comments however indicate that this script can be run from the browser - so if that's true the file needs to be renamed back to having a .php extension

Comments

dries’s picture

The script is not intended to run from the browser. I think we should update the docs.

When in Paris, we didn't manage to fix all bugs with this script. It needs some more TLC. When I run the script from my command line, I get Test cases run: 42/42, Passes: 2127, Failures: 2744, Exceptions: 324. I haven't investigated the problem yet, but it seems like it isn't smart enough about checking whether it run/configured properly

I'd like to fix this (or see it fixed) so I can run the script automatically as part of my commits. Right now that isn't possible yet.

dries’s picture

Another example of why it needs TLC -- I does funny things like:

$ ./scripts/run-functional-tests.sh --help
Drupal Unit Tests
OK
Test cases run: 0/0, Passes: 0, Failures: 0, Exceptions: 0

The output could also be improved. You don't see what tests are running and/or failing.

Incremental improvements are welcome.

dries’s picture

See http://drupal.org/node/252920#comment-831489 for more recommendations.

pwolanin’s picture

Title: bad docs, rename scripts/run-functional-tests.sh » bad code comments, other problems in run-functional-tests.sh
StatusFileSize
new3.96 KB

this patch is still a work in progress, but starting to add help and other options.

dries’s picture

Looks like a great start. :)

pwolanin’s picture

Title: bad code comments, other problems in run-functional-tests.sh » improve and clean up scripts/run-functional-tests.sh
StatusFileSize
new6.58 KB

with help from cwgordon7, tracked down the reason tests were failing: I'm running drupal in a subdirectory, so either $base_url needs to be set, or I need the --url parameter. e.g. I need to run it like:
$php scripts/run-functional-tests.sh --url http://127.0.0.1/drupal-7 Profile

Lots of other improvements in the attached patch, in addition to the added help text which now points out the above concern.

pwolanin’s picture

Status: Needs work » Needs review
dries’s picture

Status: Needs review » Needs work

I had a close look at this and it looks like an excellent start. After spending 50 minutes on this patch, I've decided to commit it "as is". I get identical test results when running all tests from the command line, or when running all tests from within the browser, and the code looks good -- minus some indentation issues that I fixed myself.

That said, I'm setting this back to 'code needs work' as there might be room for improvement. It sounds as if you have additional plans for it.

This script is important for me as it has the potential of drastically helping me test and review patches. I'm confident that it will help many others as well. Keep up the great work.

pwolanin’s picture

@Dries - thanks for putting it in - took several hours last night to get it to that point.

My motivation was the same yours - to be able to more readily run some or all of the tests without the browser timing out. I have no major additional plans at this point (except possible code cleanup/refactoring to improve logical flow), but I will poll the testing folks to see if there is any missing functionality.

pwolanin’s picture

one thing that needs to be checked better is the case when the group name includes a space. I think you'll need quotes. I guess that may also depend on your shell, however.

boombatower’s picture

Status: Needs work » Needs review
StatusFileSize
new2.44 KB

I think being able to list all the tests that can be run would be useful.

Cleaned up spacing on help text.

pwolanin’s picture

Seems like we are accessing a private variable there?

pwolanin’s picture

StatusFileSize
new2.65 KB

In any case, the list functionality is a very good idea. Re-rolled using the public method, minor other text changes.

boombatower’s picture

Status: Needs review » Reviewed & tested by the community

Ah...yes...good eye.

I think we both agree on this patch so we can say one of us reviewed it. :)

dries’s picture

Status: Reviewed & tested by the community » Needs work

I've committed the latest patch. We still need to better check cases where the group name includes a space. Therefore, I'm putting this back at 'code needs work' instead of 'fixed'. Thanks all.

boombatower’s picture

Title: improve and clean up scripts/run-functional-tests.sh » improve and clean up scripts/run-tests.sh
Assigned: Unassigned » boombatower
Status: Needs work » Postponed

I have a number of things I would like to improve once #274794: Fix run_tests and make it multi-threaded makes it in allowing the script to actually run with new Batch API stuff.

boombatower’s picture

Status: Postponed » Needs review
StatusFileSize
new2.36 KB

This patch adds color with an optional parameter --color and formats the output to a 80 character max to fit the default console width.

boombatower’s picture

StatusFileSize
new4.66 KB

This patch includes coloring of summary messages, message output clean up, and --verbose parameter to suppress all the assertion output if not specified.

Edit: The coloring on summary messages doesn't work with --all looking into.

boombatower’s picture

StatusFileSize
new5.25 KB

This now works will --all.

boombatower’s picture

Working on a complete cleanup.

boombatower’s picture

StatusFileSize
new13.78 KB
new20.54 KB

This is a massive code and comment cleanup over the previous script.

The code has been split up into functions that allow for the logic to be condensed and more easily read and understood.

I have added the following features:

  • --color argument to display results with color highlighting.
  • --verbose display detailed assertion messages.

Things that still need to be improvement:

  • Reporter system
  • Add XML reporter
  • Deal with groups that have spaces
  • Give error messages with invalid groups/classes found

Due to the fact that the script is basically completely re-organized and sections re-written I have included and copy of the script as well as a patch.

dries’s picture

This looks good and is a small but important improvement to the script. Both failures and exceptions show in red though, so I think there might be something wrong with the exception detection logic and/or the coloring. I didn't get to see any brown lines. Otherwise looks great!

boombatower’s picture

I see brown for notices.

The summary messages are displayed in either green or red just like the web interface. The individual assertions are displayed in either green, red, or brown.

dries’s picture

Ah, you're right. After reviewing the code, I was also expecting the summary lines to be brown. My wrong.

dries’s picture

Status: Needs review » Fixed

Committed to CVS HEAD. Thanks.

damien tournoud’s picture

I had no time to comment on that before it was committed, but I think this is a very good job, boombatower. We are one step closer to awesomeness!

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

damien tournoud’s picture

Title: improve and clean up scripts/run-tests.sh » Improve and clean up scripts/run-tests.sh
Assigned: boombatower » Unassigned
Status: Closed (fixed) » Needs review
StatusFileSize
new2.32 KB

Reopening, because that patch has not been tested with parallel execution before being committed, and broke everything badly.

Here is a fix. At the same time, I also add a meaningful error message when the user try to use concurrency while the required extension is not available.

boombatower’s picture

Suppose that should have been looked at, I don't run dual core so didn't think about it.

dries’s picture

Status: Needs review » Fixed

Committed to CVS HEAD. Thanks Damien.

damien tournoud’s picture

@boombatower: no problem, error handling was bad anyway, so you couldn't have known.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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