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.
This commit is contained in:
Nathan Froyd 2016-06-24 04:02:18 -04:00
parent 4eb82c0b30
commit 120cdf42f2

4
testing/runcppunittests.py Normal file → Executable file
View File

@ -204,7 +204,9 @@ def extract_unittests_from_args(args, environ, manifest_path):
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))