[PATCH 3 of 5] run-tests: let paths automatically match on Windows

Simon Heimberg simohe at besonet.ch
Fri Oct 12 11:43:22 CDT 2012


# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1350059460 -7200
# Node ID 8643d349a776196e42ff9ac7c5fbba090794f50f
# Parent  6c31cb28b26af2f883892ed831373e27815d8941
run-tests: let paths automatically match on Windows

This makes writing tests easier. And it could speed up the test suite a little
bit because more lines will match without a glob comparison.

When a path MUST be written with / on every os, the (esc) syntax can be used.

diff -r 6c31cb28b26a -r 8643d349a776 tests/run-tests.py
--- a/tests/run-tests.py	Fre Okt 12 18:31:00 2012 +0200
+++ b/tests/run-tests.py	Fre Okt 12 18:31:00 2012 +0200
@@ -540,6 +540,14 @@
     el = el.decode('string-escape')
     return el == l or os.name == 'nt' and el.replace('\r', '') == l
 
+if os.name == 'nt':
+    def pathmatch(el, l):
+        "match paths when \\ is used for / on windows"
+        return len(el) == len(l) and el == l.replace('\\', '/')
+else:
+    def pathmatch(el, l):
+        return False
+
 def linematch(el, l):
     if el == l: # perfect match (fast)
         return True
@@ -547,7 +555,8 @@
         return False
     if el.endswith(" (re)\n") and rematch(el[:-6] + '\n', l) or
          el.endswith(" (glob)\n") and globmatch(el[:-8] + '\n', l) or
-         el.endswith(" (esc)\n") and escmatch(el[:-7] + '\n', l)
+         el.endswith(" (esc)\n") and escmatch(el[:-7] + '\n', l) or
+         pathmatch(el, l)
         return True
     return False
 


More information about the Mercurial-devel mailing list