File: test_file.py

package info (click to toggle)
pypy3 7.3.19%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 212,236 kB
  • sloc: python: 2,098,316; ansic: 540,565; sh: 21,462; asm: 14,419; cpp: 4,451; makefile: 4,209; objc: 761; xml: 530; exp: 499; javascript: 314; pascal: 244; lisp: 45; csh: 12; awk: 4
file content (48 lines) | stat: -rw-r--r-- 1,725 bytes parent folder | download | duplicates (4)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import os
import urllib2, py
from os.path import join

RVMPROF = py.path.local(__file__).join('..', '..')

def github_raw_file(repo, path, branch='master'):
    url = "https://raw.githubusercontent.com/{repo}/{branch}/{path}"
    return url.format(repo=repo, path=path, branch=branch)

def get_list_of_files(shared):
    files = list(shared.visit('*.[ch]'))
    # in PyPy we checkin the result of ./configure; as such, these files are
    # not in github or different and can be skipped
    files.remove(shared.join('libbacktrace', 'config-x86_32.h'))
    files.remove(shared.join('libbacktrace', 'config-x86_64.h'))
    files.remove(shared.join('libbacktrace', 'gstdint.h'))
    try:
        files.remove(shared.join('libbacktrace', 'config.h'))
    except ValueError:
        pass # might not be there
    return files

def test_same_file():
    shared = RVMPROF.join('src', 'shared')
    files = get_list_of_files(shared)
    assert files, 'cannot find any C file, probably the directory is wrong?'
    no_matches = []
    print
    for file in files:
        path = file.relto(shared)
        url = github_raw_file("vmprof/vmprof-python", "src/%s" % path)
        source = urllib2.urlopen(url).read()
        dest = file.read()
        shortname = file.relto(RVMPROF)
        if source == dest:
            print '%s matches' % shortname
        else:
            print '%s does NOT match' % shortname
            no_matches.append(file)
    #
    if no_matches:
        print
        print 'The following file did NOT match'
        for f in no_matches:
            print '   ', f.relto(RVMPROF)
        raise AssertionError("some files were updated on github, "
                             "but were not copied here")