tests/check-perf-code.py
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Fri, 20 May 2016 09:47:35 +0900
changeset 29570 cbd240188e4e
child 29571 d1a7d9c279bb
permissions -rwxr-xr-x
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.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29570
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     1
#!/usr/bin/env python
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     2
#
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     3
# check-perf-code - (historical) portability checker for contrib/perf.py
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     4
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     5
from __future__ import absolute_import
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     6
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     7
import os
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     8
import sys
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     9
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    10
# write static check patterns here
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    11
perfpypats = [
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    12
  [
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    13
  ],
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    14
  # warnings
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    15
  [
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    16
  ]
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    17
]
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    18
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    19
if __name__ == "__main__":
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    20
    # import contrib/check-code.py as checkcode
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    21
    assert 'RUNTESTDIR' in os.environ, "use check-perf-code.py in *.t script"
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    22
    contribpath = os.path.join(os.environ['RUNTESTDIR'], '..', 'contrib')
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    23
    sys.path.insert(0, contribpath)
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    24
    checkcode = __import__('check-code')
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    25
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    26
    # register perf.py specific entry with "checks" in check-code.py
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    27
    checkcode.checks.append(('perf.py', r'contrib/perf.py$', '',
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    28
                             checkcode.pyfilters, perfpypats))
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    29
cbd240188e4e tests: introduce check-perf-code.py to add extra checks on perf.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    30
    sys.exit(checkcode.main())