[PATCH] run-tests: disable color on Windows

Matt Harbison mharbison72 at gmail.com
Sat Jul 15 04:55:13 UTC 2017


# HG changeset patch
# User Matt Harbison <matt_harbison at 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.

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


More information about the Mercurial-devel mailing list