Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add colours to run-test #5901

Closed
wants to merge 2 commits into from
Closed

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Jul 28, 2020

Based from: xdebug/xdebug@296f31d

Not sure if "BORK" actually deserves it's special category/colour

@cmb69
Copy link
Contributor

cmb69 commented Jul 28, 2020

I like that very much, but at least for Windows it would make sense to check sapi_windows_vt100_support(), and to not print ANSI escape codes in that case. Or perhaps even better let the user control that with a command line option.

@Girgias
Copy link
Member Author

Girgias commented Jul 28, 2020

I like that very much, but at least for Windows it would make sense to check sapi_windows_vt100_support(), and to not print ANSI escape codes in that case. Or perhaps even better let the user control that with a command line option.

The command line option is indeed something which I should add.

Just to be clear in regards to Windows, as I'm not familiar with it's console env, I should not print the ANSI escape code in case VT100 is not support and default back to the previous behaviour?

@twose
Copy link
Member

twose commented Jul 29, 2020

I did the same in my own extension, hope this help :)

// namespace XXX;

const COLOR_NONE = 0;
const COLOR_RED = 1;
const COLOR_GREEN = 2;
const COLOR_YELLOW = 3;
const COLOR_BLUE = 4;
const COLOR_MAGENTA = 5;
const COLOR_CYAN = 6;
const COLOR_WHITE = 7;

function dye(string $string, int $color): string
{
    // check if it is available here?
    return ($color !== COLOR_NONE ? "\033[3{$color}m{$string}\033[0m" : $string);
}

BTW, isn't LEAK worth having color? 😂

@cmb69
Copy link
Contributor

cmb69 commented Jul 29, 2020

[…] I should not print the ANSI escape code in case VT100 is not support and default back to the previous behaviour?

Yes. :)

@Girgias
Copy link
Member Author

Girgias commented Jul 31, 2020

Added checks for Windows and added a Dark Blue colouring for LEAK.

@theodorejb
Copy link
Contributor

Should the American spelling of color be used? That seems to be the typical spelling elsewhere in the source code: https://github.com/php/php-src/search?q=color

@KalleZ
Copy link
Member

KalleZ commented Aug 1, 2020

Should the American spelling of color be used? That seems to be the typical spelling elsewhere in the source code: https://github.com/php/php-src/search?q=color

I agree, we tend to use more Americanized naming, would prefer to stick to that for consistency

@cmb69
Copy link
Contributor

cmb69 commented Aug 1, 2020

The Windows specific changes look good to me. I also would prefer the American English spelling.

@Girgias
Copy link
Member Author

Girgias commented Aug 1, 2020

Will use the Americanized version the.
Should I enable the --no-color flag in CI or not?

@KalleZ
Copy link
Member

KalleZ commented Aug 1, 2020

@Girgias If our CIs support it and it looks good, then I do not see why not

@Girgias
Copy link
Member Author

Girgias commented Aug 1, 2020

Just looks like AppVeyor doesn't enable VT100, and Travis and Azure only show skipped/XFAIL/FAIL so seems reasonable to keep it on CI

run-tests.php Outdated
@@ -114,6 +114,8 @@ function show_usage()

--no-clean Do not execute clean section if any.

--no-color Do not colorise the result type in the test result
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

colorise should be colorize (here and elsewhere)

Copy link
Contributor

@carusogabriel carusogabriel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I suggest to add colors to the summary table as well? Something like:

image

or

image

run-tests.php Outdated
case 'PASS': // Light Green
$color = "\e[1;32m{$result}\e[0m"; break;
case 'SKIP': // Light Gray
$color = "\e[0;37m{$result}"; break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing

Suggested change
$color = "\e[0;37m{$result}"; break;
$color = "\e[0;37m{$result}\e[0m"; break;

?

@carusogabriel carusogabriel added this to the PHP 8.0 milestone Aug 2, 2020
@nikic nikic removed this from the PHP 8.0 milestone Aug 3, 2020
@Girgias
Copy link
Member Author

Girgias commented Aug 5, 2020

Can I suggest to add colors to the summary table as well? Something like:

image

or

image

The get_summary() function is quite a mess so adding this is pretty annoying as it would need a bunch of conditionals and more splitting it up. I'd rather leave that for later after a possible refactor of this function.

@Girgias Girgias force-pushed the coulourize-test-runner branch 2 times, most recently from 1c7fb6e to 2bef7cd Compare August 6, 2020 19:17
@cmb69
Copy link
Contributor

cmb69 commented Aug 6, 2020

FWIW, the AppVeyor CI failure is unrelated to this PR.

run-tests.php Outdated
case 'PASS': // Light Green
$color = "\e[1;32m{$result}\e[0m"; break;
case 'SKIP': // Light Gray
$color = "\e[0;37m{$result}\e[0m"; break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ends up being pretty much the same as the normal text color :/ Maybe use yellow or orange?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, let this fall through the the default case that also handles XFAIL. XFAIL and SKIP seems pretty similar.

run-tests.php Outdated
case 'BORK': // Purple
$color = "\e[0;35m{$result}\e[0m"; break;
case 'LEAK': // Dark Blue
$color = "\e[2;34m{$result}\e[0m"; break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just make all of these red, they're all effectively a failure.

run-tests.php Outdated
$color = "\e[1;33m{$result}\e[0m"; break;
}

echo "$color $tested [$tested_file] $extra\e[0m\n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there an \e[0m here?

The test runner will attempt to colourise the result of each test

The --no-color option is introduced to disable this feature.
echo "$result $tested [$tested_file] $extra\n";
if ($colorize) {
/* Use ANSI escape codes for coloring test result */
switch ( $result ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
switch ( $result ) {
switch ($result) {

@php-pulls php-pulls closed this in 5d72e40 Aug 7, 2020
@Girgias Girgias deleted the coulourize-test-runner branch August 7, 2020 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants