File: test_file.py

package info (click to toggle)
pypy 7.3.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 113,660 kB
  • sloc: python: 1,419,707; ansic: 64,313; cpp: 3,290; sh: 2,763; makefile: 540; xml: 256; asm: 213; lisp: 45; awk: 4
file content (45 lines) | stat: -rw-r--r-- 1,655 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
34
35
36
37
38
39
40
41
42
43
44
45
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'))
    files.remove(shared.join('libbacktrace', 'config.h'))
    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")