Tester: print tests environment

5 years ago

Milo
Nette Core | 1118
+
0
-

Reason

Using a Nette Tester is easy (at least for me). But for a familiarization it can seem to be tricky, mainly part with default -n or -n -c php.ini options. It would be helpful to show how the environment really looks from running tests point of view.

Propose

Add new option -i Print environment info. If runned with this option, Tester prints and exits:

Nette Tester (v0.0.0)
---------------------
PHP version:
    5.5.4 (CGI)

PHP binary:
    /home/milo/php/5.5.4/php-cgi

INI files:
    /home/milo/tester/php.ini
    /etc/php/conf.d/*

Extensions:
    core
    dom
    pdo
    pdo_pgsql
    ...

Implementation

Add new file Tester/Runner/dump-environment.php which will contain something like:

echo json_encode(array(
    'version' => PHP_VERSION,
    'binary' => defined('PHP_BINARY') ? PHP_BINARY : NULL,
    'extensions' => get_loaded_extensions(),
    ...
));

This file will be runned as a Runner\Job when tester -i invoked.

To be discussed

Propose seems to me pretty straightforward, but there is a few things I would like to discuss:

  • which next important info sould be printed
  • output text sould be short, well, there can be a lot of extensions
  • maybe better option name, seems to me waste of short option -i for this, on the other hand it is handy and fast to write

Last edited by Milo (2014-02-11 11:36)

5 years ago

David Grudl
Nette Core | 6797
+
0
-

Looks great!

Maybe -i (like info) is better than -e. And it be implemented without dump-environment.php, via php -r.

What about write extensions separated by comma?

5 years ago

Milo
Nette Core | 1118
+
0
-

David Grudl wrote:

Maybe -i (like info) is better than -e.

Agree, it's better. RFC updated.

And it be implemented without dump-environment.php, via php -r.

Unfortunately -r works with CLI only.

What about write extensions separated by comma?

Sounds good.

Last edited by Milo (2014-01-21 21:23)

5 years ago

nAS
Member | 279
+
0
-

I like it, especially printing parsed .ini files can be very useful. Few month ago I spent some time by debugging our test environment because wrong .ini files were used.

5 years ago

David Grudl
Nette Core | 6797
+
0
-

@nAS Used ini file is displayed by default:

Nette Tester (v0.9.5)
---------------------
Log: W:\Nette\_nette\tests\test.log
PHP 5.3.6 | "C:\PHP\versions\php-5.3.6\php-cgi.exe" -n -c "W:\Nette\_nette\tests\php-win.ini" | 50 threads

5 years ago

hrach
Member | 1810
+
0
-

+1

5 years ago

Filip Procházka
Moderator | 4693
+
0
-

+1

5 years ago

Patrik Votoček
Member | 2249
+
0
-

+1

5 years ago

Pavel Macháň
Member | 285
+
0
-

+1

5 years ago

tomas.lang
Member | 54
+
0
-

+1

5 years ago

David Grudl
Nette Core | 6797
+
0
-

Myslím, že shoda je jednomyslná, takže bude fajn, když to implementuješ.

5 years ago

Milo
Nette Core | 1118
+
0
-

Thanks to all. I'll send PR soon.

EDIT: RFC implemented

Last edited by Milo (2014-02-11 11:39)