[pypy-commit] pypy vmprof-0.4.10: bah, I think that this test did not actually test anything because on buildbot the cwd was different that the test expects, and thus os.walk returned an empty list O_o. Make it more robust, and actually check all files instead of stopping at the first one

antocuni pypy.commits at gmail.com
Sat Nov 4 07:10:09 EDT 2017


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: vmprof-0.4.10
Changeset: r92925:0317d4f69638
Date: 2017-11-04 12:03 +0100
http://bitbucket.org/pypy/pypy/changeset/0317d4f69638/

Log:	bah, I think that this test did not actually test anything because
	on buildbot the cwd was different that the test expects, and thus
	os.walk returned an empty list O_o. Make it more robust, and
	actually check all files instead of stopping at the first one

diff --git a/rpython/rlib/rvmprof/test/test_file.py b/rpython/rlib/rvmprof/test/test_file.py
--- a/rpython/rlib/rvmprof/test/test_file.py
+++ b/rpython/rlib/rvmprof/test/test_file.py
@@ -2,6 +2,7 @@
 import urllib2, py
 from os.path import join
 
+RVMPROF = py.path.local(__file__).join('..', '..')
 
 def github_raw_file(repo, path, branch='master'):
     return "https://raw.githubusercontent.com/{repo}/{branch}/{path}".format(**dict(
@@ -10,17 +11,26 @@
 
 
 def test_same_file():
-    for root, dirs, files in os.walk('rpython/rlib/rvmprof/src/shared'):
-        for file in files:
-            if not (file.endswith(".c") or file.endswith(".h")):
-                continue
-            url = github_raw_file("vmprof/vmprof-python", "src/%s" % file)
-            source = urllib2.urlopen(url).read()
-            #
-            dest = py.path.local(join(root, file)).read()
-            if source != dest:
-                raise AssertionError("%s was updated, but changes were"
-                                     "not copied over to PyPy" % url)
-            else:
-                print("%s matches" % url)
-        break # do not walk dirs
+    shared = RVMPROF.join('src', 'shared')
+    files = shared.listdir('*.[ch]')
+    assert files, 'cannot find any C file, probably the directory is wrong?'
+    no_matches = []
+    print
+    for file in files:
+        url = github_raw_file("vmprof/vmprof-python", "src/%s" % file.basename)
+        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 dit NOT match'
+        for f in no_matches:
+            print '   ', f.relto(RVMPROF)
+        raise AssertionError("some files were updated on github, "
+                             "but were not copied here")


More information about the pypy-commit mailing list