Bug 1281918 - make runcppunittests filter out non-executable files when given a directory; r=chmanchester
authorNathan Froyd <froydnj@gmail.com>
Fri, 24 Jun 2016 04:02:18 -0400
changeset 302508 a83f7715e54a6bf5f3685fc01a199b87ce7de4f0
parent 302507 b0ed81adfff696a0128e535fe5780340129462ad
child 302509 51afa8a10978606c13111c929d2ba68015ee3951
push idunknown
push userunknown
push dateunknown
reviewerschmanchester
bugs1281918
milestone50.0a1
Bug 1281918 - make runcppunittests filter out non-executable files when given a directory; r=chmanchester When runcppunittest (resp. |mach cppunittest|) is passed a directory, it attempts to indiscriminately run all the files found in that directory. This is unhelpful, as directories containing compiled cppunittests also tend to have other things: Makefiles, object files, etc. Let's filter out non-executable files from the directory listing and make the user experience more pleasant.
testing/runcppunittests.py
old mode 100644
new mode 100755
--- a/testing/runcppunittests.py
+++ b/testing/runcppunittests.py
@@ -199,17 +199,19 @@ def extract_unittests_from_args(args, en
         mp.read(manifest_path)
         binary_path = os.path.abspath(args[0])
     else:
         for p in args:
             if os.path.isdir(p):
                 try:
                     mp.read(os.path.join(p, 'cppunittest.ini'))
                 except IOError:
-                    tests.extend([(os.path.abspath(os.path.join(p, x)), 1) for x in os.listdir(p)])
+                    files = [os.path.abspath(os.path.join(p, x)) for x in os.listdir(p)]
+                    tests.extend((f, 1) for f in files
+                                 if os.access(f, os.R_OK | os.X_OK))
             else:
                 tests.append((os.path.abspath(p), 1))
 
     # we skip the existence check here because not all tests are built
     # for all platforms (and it will fail on Windows anyway)
     active_tests = mp.active_tests(exists=False, disabled=False, **environ)
     suffix = '.exe' if mozinfo.isWin else ''
     if binary_path: