Make run-tests.sh find PHP on Windows & Linux

sun - November 7, 2008 - 21:15
Project:Drupal
Version:7.x-dev
Component:simpletest.module
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Issue tags:Needs review on Windows
Description

I'm trying to get run-tests.sh working on Windows.

First step (this issue) is to auto-detect the PHP interpreter. Attached patch does this trick. Works for me on Windows Server 2003.

Next step (separate issue) is to find out why Drupal is invoked, but no tests are run at all.

AttachmentSizeStatusTest resultOperations
drupal.run-tests-php-windows.patch1.04 KBIdlePassed: 14738 passes, 0 fails, 0 exceptionsView details | Re-test

#1

sun - November 7, 2008 - 23:28

Missed to add "/php.exe" to the auto-discovered path.

Tests also start to run this way - however, they seem to break after 17 secs.

Thanks to DamZ for pointing out this nonsense. ;)

AttachmentSizeStatusTest resultOperations
drupal.run-tests-php-windows.patch1.1 KBIdleFailed: 9657 passes, 4 fails, 0 exceptionsView details | Re-test

#2

System Message - November 16, 2008 - 22:00
Status:needs review» needs work

The last submitted patch failed testing.

#3

lilou - November 17, 2008 - 13:40

#4

catch - January 16, 2009 - 13:27
Component:tests» simpletest.module

#5

System Message - February 7, 2009 - 13:15
Status:needs review» needs work

The last submitted patch failed testing.

#6

sun - October 13, 2009 - 02:59
Status:needs work» needs review

Wasn't able to test this yet, because, somehow, my PDO extension vanished from my CLI, so... ugh.

AttachmentSizeStatusTest resultOperations
drupal.run-tests-windows.patch1.13 KBIdlePassed: 14757 passes, 0 fails, 0 exceptionsView details | Re-test

#7

boombatower - October 21, 2009 - 03:19
Title:Make run-tests.sh find PHP on Windows» Make run-tests.sh find PHP on Windows & Linux

The script used to work without --php for me then the auto-detect was added and it messed it up. I checked it out and $_SERVER contains SUDO_COMMAND, not $_ENV so I added a case for that, although it can also be in ENV.

Merged with previous patch and changed title.

AttachmentSizeStatusTest resultOperations
331580-auto-detect-php.patch2.03 KBIdleFailed: Failed to apply patch.View details | Re-test

#8

sun - October 21, 2009 - 03:32
Status:needs review» reviewed & tested by the community

At least the Windows part is RTBC. It still doesn't properly run any tests, but at least it finds PHP and is able to list all tests. I can execute a test group, a single test class, or all tests, but everything is executed in 0.00 secs. My first reaction, of course, was: woah, awesome! How fast is that?! Then I found out that it's really too fast. :-D Though not sure, why.

#9

mooffie - November 5, 2009 - 13:41

Mmmm....

There are quite a few bugs in 'run-tests.sh' related to its "shell interaction".

I prepared a patch yesterday, to make it work on Unix-like systems, but it's only now that I see you too have been investing some efforts in this (My fault, I'm mostly off-line and not aware of what's going on here...).

I don't want to extend this patch's scope (it will cause delay in committing it), so I'll wait till it gets in and then I'll open a new issue. (Unless the maintainer (boombatower?) instructs me otherwise.)

I checked it out and $_SERVER contains SUDO_COMMAND, not $_ENV so I added a case for that, although it can also be in ENV.

Could you please investigate this issue? Is your $_ENV empty?

#10

boombatower - November 5, 2009 - 18:36
Category:task» bug report

I consider this to be a bug, also make it clear this should get in. No reasons why I should have to specify my php location when it is in standard location, run path, etc.

As for #9:
My $_ENV is empty and $_SERVER is loaded.

#11

mooffie - November 6, 2009 - 07:53
Status:reviewed & tested by the community» needs work

I don't want to extend this patch's scope (it will cause delay in committing it), so I'll wait till it gets in and then I'll open a new issue.

On the other hand, this issue purports to deal with Linux too, so it seems I'm on-topic in pointing out further bugs in this "Make run-tests.sh find PHP" mechanism (and escpecially since boombatower touches this same code in his patch):

  1. When the script is run directly as an executable (./run-tests.sh, or ./script/run-test.sh), the code for figuring out the location of the PHP interpreter fails. No indication to error is given and to the user it seems that everything runs fine.

    To fix this, code of the form elseif (!empty($_ENV['_'])) sould be changed to elseif (!empty($_ENV['_']) && (strstr($_ENV['_'], $args['script']) === FALSE)). Ditto for list($php, ) = explode(' ', $_ENV['SUDO_COMMAND'], 2).

    Alternatively, we shouldn't give the false impression direct execution is possible.

  2. A "shebang" line is missing. What's the point in giving the script a ".sh" extension, and shipping it with the executable bit set, and having the help text say "Usage: run-tests.sh [OPTIONS] {tests}", if this setup doesn't work?
  3. This:

    $command = "$php ./scripts/{$args['script']} --url {$args['url']}";

    should be changed to:

    $command = "$php ./scripts/{$args['script']} --url " . escapeshellarg($args['url']);

    Or else, when not explicitly providing a --url parameter, mysterious things happen because the starved `--url' eats up the next word (which happens to be '--php', so this bug is on-topic here).

  4. The help text insinuates you should run this script "from the root directory of your Drupal installation", but this isn't necessary because the script does chdir() to there. (This is also on-topic here, because this misleading data serves as red herring to the administratior who is going to investigate the `--php' issue when the script borks on him).
  5. The ", or root" should be removed from the help text.

#12

mooffie - November 6, 2009 - 08:06

BTW, what's wrong with the following solution?

To completely remove the auto-detecting stuff. $php will be set by default to 'php'. If the user wants some other interpreter (or, if the php interpreter isn't in $PATH), she'll specify it explicitly with "--php /path/to/some/other/php".

#13

boombatower - November 6, 2009 - 19:24

That's how it was...I much prefer that as anyone with a normal config will be able to just use "php". For the life of me I have no idea why it was changed.

#14

mooffie - November 8, 2009 - 05:37
Status:needs work» reviewed & tested by the community

BTW, what's wrong with the following solution?

To completely remove the auto-detecting stuff.

I found the issue that introduced this auto-detecting feature and I see people want it, so removing it isn't an option.

Most of my negative feelings towards run-tests.sh stem from trying to execute it directly (e.g. ./run-tests.sh), but I see that it was never meant to be invoked this way. I'll later open a new issue to address this "documentation" problem.

So I'm reverting the status to what it was before I came here: "reviewed & tested by the community".

#15

Dries - November 8, 2009 - 18:54

I wouldn't mind to remove the auto-detect feature. Maybe we can use an environment variable that people can set if they are sick and tired of specifying --php. That is how Java does it. People can either specify the classpath or set $CLASSPATH.

#16

boombatower - November 8, 2009 - 21:44

The main problem with auto-detect...is (at the moment) it breaks on more peoples machines then without. So either "fix" with patch, or I think #15 is best.

#17

mooffie - November 10, 2009 - 09:38
Status:reviewed & tested by the community» needs review

Maybe we can use an environment variable that people can set if they are sick and tired of specifying --php.

I was thinking about a variable that could contain any option, e.g. $ export RUNTESTS_OPTS='--color --php /path/to/php', but tokenizing this string isn't very easy because /path/to/php may contain spaces.

So here's a version that uses .ini file(s) instead.

(I'm marking this 'needs review' although I myself gave the code a very superficial check. sorry.)

AttachmentSizeStatusTest resultOperations
run-tests-remove-auto-detect.diff2.92 KBIdlePassed: 14758 passes, 0 fails, 0 exceptionsView details | Re-test
 
 

Drupal is a registered trademark of Dries Buytaert.