[PATCH 4 of 5 V3] tests: introduce check-perf-code.py to add extra checks on perf.py

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Fri Jul 15 11:29:43 EDT 2016


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1463705255 -32400
#      Fri May 20 09:47:35 2016 +0900
# Node ID e9f592ae6c0b6f38e168d8dff0407415720861dc
# Parent  58e094219484a69088a7b1c93251dc2fc31f7cda
tests: introduce check-perf-code.py to add extra checks on perf.py

This patch introduces tests/check-perf-code.py as a preparation for
adding extra checks on contrib/perf.py in subsequent patches (mainly,
for historical portability).

At this change, check-perf-code.py doesn't add any extra check, and is
equal to check-code.py. This makes subsequent patch focus only on
adding an extra check on perf.py check-perf-code.py.

check-perf-code.py adds extra checks on perf.py by wrapping
contrib/check-code.py, because "filtering" by check-code.py (e.g.
normalize characters in string literal or comment line) is useful to
simplify regexp for check, and avoid false positive matching.

diff --git a/tests/check-perf-code.py b/tests/check-perf-code.py
new file mode 100755
--- /dev/null
+++ b/tests/check-perf-code.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+#
+# check-perf-code - (historical) portability checker for contrib/perf.py
+
+from __future__ import absolute_import
+
+import os
+import sys
+
+# write static check patterns here
+perfpypats = [
+  [
+  ],
+  # warnings
+  [
+  ]
+]
+
+if __name__ == "__main__":
+    # import contrib/check-code.py as checkcode
+    assert 'RUNTESTDIR' in os.environ, "use check-perf-code.py in *.t script"
+    contribpath = os.path.join(os.environ['RUNTESTDIR'], '..', 'contrib')
+    sys.path.insert(0, contribpath)
+    checkcode = __import__('check-code')
+
+    # register perf.py specific entry with "checks" in check-code.py
+    checkcode.checks.append(('perf.py', r'contrib/perf.py$', '',
+                             checkcode.pyfilters, perfpypats))
+
+    sys.exit(checkcode.main())
diff --git a/tests/test-contrib-perf.t b/tests/test-contrib-perf.t
--- a/tests/test-contrib-perf.t
+++ b/tests/test-contrib-perf.t
@@ -148,3 +148,8 @@ perfstatus
   $ hg perfwalk
   $ hg perfparents
 
+Check perf.py for historical portability
+
+  $ cd "$TESTDIR/.."
+
+  $ "$TESTDIR"/check-perf-code.py contrib/perf.py


More information about the Mercurial-devel mailing list