| 1 |
import os |
| 2 |
import urllib2, py |
| 3 |
from os.path import join |
| 4 |
|
| 5 |
RVMPROF = py.path.local(__file__).join('..', '..') |
| 6 |
|
| 7 |
def github_raw_file(repo, path, branch='master'): |
| 8 |
url = "https://raw.githubusercontent.com/{repo}/{branch}/{path}" |
| 9 |
return url.format(repo=repo, path=path, branch=branch) |
| 10 |
|
| 11 |
def get_list_of_files(shared): |
| 12 |
files = list(shared.visit('*.[ch]')) |
| 13 |
|
| 14 |
|
| 15 |
files.remove(shared.join('libbacktrace', 'config-x86_32.h')) |
| 16 |
files.remove(shared.join('libbacktrace', 'config-x86_64.h')) |
| 17 |
files.remove(shared.join('libbacktrace', 'gstdint.h')) |
| 18 |
try: |
| 19 |
files.remove(shared.join('libbacktrace', 'config.h')) |
| 20 |
except ValueError: |
| 21 |
pass |
| 22 |
return files |
| 23 |
|
| 24 |
def test_same_file(): |
| 25 |
shared = RVMPROF.join('src', 'shared') |
| 26 |
files = get_list_of_files(shared) |
| 27 |
assert files, 'cannot find any C file, probably the directory is wrong?' |
| 28 |
no_matches = [] |
| 29 |
print |
| 30 |
for file in files: |
| 31 |
path = file.relto(shared) |
| 32 |
url = github_raw_file("vmprof/vmprof-python", "src/%s" % path) |
| 33 |
source = urllib2.urlopen(url).read() |
| 34 |
dest = file.read() |
| 35 |
shortname = file.relto(RVMPROF) |
| 36 |
if source == dest: |
| 37 |
print '%s matches' % shortname |
| 38 |
else: |
| 39 |
print '%s does NOT match' % shortname |
| 40 |
no_matches.append(file) |
| 41 |
|
| 42 |
if no_matches: |
| 43 |
print |
| 44 |
print 'The following file did NOT match' |
| 45 |
for f in no_matches: |
| 46 |
print ' ', f.relto(RVMPROF) |
| 47 |
raise AssertionError("some files were updated on github, " |
| 48 |
"but were not copied here") |