Patchwork run-tests: disable color on Windows

login
register
mail settings
Submitter Matt Harbison
Date July 15, 2017, 4:55 a.m.
Message ID <00e59d5ca0a7c5610695.1500094513@Envy>
Download mbox | patch
Permalink /patch/22389/
State Accepted
Headers show

Comments

Matt Harbison - July 15, 2017, 4:55 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1500094356 14400
#      Sat Jul 15 00:52:36 2017 -0400
# Node ID 00e59d5ca0a7c5610695250a7955615ef49138ee
# Parent  c2549b5ffd77029d78ef92d8fb5cd5b5bdbbb254
run-tests: disable color on Windows

More Windows sadness.  Maybe someone can figure out how to make win32 color
work, but I think we avoid importing stuff from the mercurial package in this
module.  On the plus side, this conditionalizes away a test failure.
Yuya Nishihara - July 15, 2017, 6:12 a.m.
On Sat, 15 Jul 2017 00:55:13 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1500094356 14400
> #      Sat Jul 15 00:52:36 2017 -0400
> # Node ID 00e59d5ca0a7c5610695250a7955615ef49138ee
> # Parent  c2549b5ffd77029d78ef92d8fb5cd5b5bdbbb254
> run-tests: disable color on Windows

Queued, thanks.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -89,13 +89,16 @@ 
 processlock = threading.Lock()
 
 with_color = False
-try: # is pygments installed
-    import pygments
-    import pygments.lexers as lexers
-    import pygments.formatters as formatters
-    with_color = True
-except ImportError:
-    pass
+
+# ANSI color is unsupported prior to Windows 10
+if os.name != 'nt':
+    try: # is pygments installed
+        import pygments
+        import pygments.lexers as lexers
+        import pygments.formatters as formatters
+        with_color = True
+    except ImportError:
+        pass
 
 if not sys.stderr.isatty(): # check if the terminal is capable
     with_color = False
diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t
--- a/tests/test-run-tests.t
+++ b/tests/test-run-tests.t
@@ -121,6 +121,7 @@ 
 
 test diff colorisation
 
+#if no-windows
   $ rt test-failure.t --color always
   
   \x1b[38;5;124m--- $TESTTMP/test-failure.t\x1b[39m (esc)
@@ -155,6 +156,7 @@ 
   Failed test-failure.t: output changed
   # Ran 1 tests, 0 skipped, 1 failed.
   python hash seed: * (glob)
+#endif
 
 basic failing test
   $ cat > test-failure.t << EOF