Patchwork [stable] tests: add support in run-tests.py for an environment variable to stop color

login
register
mail settings
Submitter Augie Fackler
Date July 26, 2017, 9:58 p.m.
Message ID <bf9183f48b08e1bde191.1501106318@augie-macbookpro2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/22559/
State Accepted
Headers show

Comments

Augie Fackler - July 26, 2017, 9:58 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1501106204 14400
#      Wed Jul 26 17:56:44 2017 -0400
# Branch stable
# Node ID bf9183f48b08e1bde191139b0c83b766fe13cba5
# Parent  99277f2f93979456860e5a619b819b64e813b81c
tests: add support in run-tests.py for an environment variable to stop color

I don't like the color output, so this gives me a way to easily never
see it while still having pygments on my machine.
Yuya Nishihara - July 27, 2017, 1:59 p.m.
On Wed, 26 Jul 2017 17:58:38 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1501106204 14400
> #      Wed Jul 26 17:56:44 2017 -0400
> # Branch stable
> # Node ID bf9183f48b08e1bde191139b0c83b766fe13cba5
> # Parent  99277f2f93979456860e5a619b819b64e813b81c
> tests: add support in run-tests.py for an environment variable to stop color

Seems reasonable. Queued, thanks.

> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -269,7 +269,7 @@ def getparser():
>      parser.add_option("-c", "--cover", action="store_true",
>          help="print a test coverage report")
>      parser.add_option("--color", choices=["always", "auto", "never"],
> -                      default="auto",
> +                      default=os.environ.get('HGRUNTESTSCOLOR', 'auto'),

Nit: HGRUNTESTSCOLOR=whatever raises exception because possible values are
restricted.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -269,7 +269,7 @@  def getparser():
     parser.add_option("-c", "--cover", action="store_true",
         help="print a test coverage report")
     parser.add_option("--color", choices=["always", "auto", "never"],
-                      default="auto",
+                      default=os.environ.get('HGRUNTESTSCOLOR', 'auto'),
                       help="colorisation: always|auto|never (default: auto)")
     parser.add_option("-d", "--debug", action="store_true",
         help="debug mode: write output of test scripts to console"