File: CheckTests.py

package info (click to toggle)
swift-im 5.0~alpha2.145.g12d031cf8%2Bdfsg-4.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,256 kB
  • sloc: cpp: 134,640; python: 2,701; sh: 774; xml: 561; javascript: 69; makefile: 59
file content (33 lines) | stat: -rwxr-xr-x 1,417 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python

import os, sys, re

foundUnregisteredTests = False

for (path, dirs, files) in os.walk(".") :
    if not "3rdParty" in path :
        for filename in [os.path.join(path, file) for file in files if file.endswith("Test.cpp") and file != "IdleQuerierTest.cpp" and file != "NotifierTest.cpp" and file != "ClientTest.cpp" and file != "ConnectivityTest.cpp" and file != "ReconnectTest.cpp"] :
            file = open(filename, "r")
            isRegistered = False
            registeredTests = set()
            declaredTests = set()
            for line in file.readlines() :
                m = re.match("\s*CPPUNIT_TEST_SUITE_REGISTRATION\((.*)\)", line)
                if m :
                    isRegistered = True
                m = re.match("\s*CPPUNIT_TEST\((.*)\)", line)
                if m :
                    registeredTests.add(m.group(1))
                    continue
                m = re.match("\s*void (test.*)\(\)", line)
                if m :
                    declaredTests.add(m.group(1))
            if not isRegistered :
                print filename + ": Registration missing"
                foundUnregisteredTests = True
            if registeredTests - declaredTests != set([]) :
                print filename + ": " + str(registeredTests - declaredTests)
                foundUnregisteredTests = True
            file.close()

sys.exit(foundUnregisteredTests)