File: checkUnitTests.py

package info (click to toggle)
libvigraimpex 1.11.1%2Bdfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 50,356 kB
  • sloc: cpp: 57,785; python: 8,603; ansic: 1,798; makefile: 97; javascript: 65; sh: 50
file content (24 lines) | stat: -rw-r--r-- 882 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
def hook(ui, repo, **args):
    import os
    repoPath = repo.url()[5:] + '/' # cut-off 'file:' prefix
    testSuccessFile = repoPath + 'test/testSuccess'
    if not os.path.exists(testSuccessFile):
        print("File 'test/testSuccess' is missing. Run the test suite before committing.")
        return True
    testTime = os.path.getmtime(testSuccessFile)
    stat = repo.status()
    files = stat[0]+stat[1]  # added or modified files
    modified = []
    for file in files:
        if file[-4:] not in ['.cxx', '.hxx']:
            continue
        fileTime =  os.path.getmtime(repoPath+file)
        if fileTime > testTime:
            modified.append(file)
    if len(modified) > 0:
        print("Run the test suite before committing. The following files are untested:")
        for file in modified:
            print('   ',file)
        return True
    return False