Skip to content

Commit 742fc6f

Browse files
Ace Nassritheacodes
Ace Nassri
authored andcommitted
Fix nox not recognizing directories (GoogleCloudPlatform#1630)
Change-Id: I25f7768c35564f12c26cfec084993c84723ab16f
1 parent de34571 commit 742fc6f

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

nox.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ def _list_files(folder, pattern):
4040

4141
def _collect_dirs(
4242
start_dir,
43-
blacklist=set(['conftest.py', 'nox.py']),
44-
suffix='_test.py'):
43+
blacklist=set(['conftest.py', 'nox.py', 'lib']),
44+
suffix='_test.py',
45+
recurse_further=False):
4546
"""Recursively collects a list of dirs that contain a file matching the
4647
given suffix.
4748
@@ -50,17 +51,20 @@ def _collect_dirs(
5051
"""
5152
# Collect all the directories that have tests in them.
5253
for parent, subdirs, files in os.walk(start_dir):
53-
if any(f for f in files if f.endswith(suffix) and f not in blacklist):
54-
# Don't recurse further, since py.test will do that.
55-
del subdirs[:]
56-
# This dir has tests in it. yield it.
54+
if './.' in parent:
55+
continue # Skip top-level dotfiles
56+
elif any(f for f in files if f.endswith(suffix) and f not in blacklist):
57+
# Don't recurse further for tests, since py.test will do that.
58+
if not recurse_further:
59+
del subdirs[:]
60+
# This dir has desired files in it. yield it.
5761
yield parent
5862
else:
5963
# Filter out dirs we don't want to recurse into
6064
subdirs[:] = [
6165
s for s in subdirs
6266
if s[0].isalpha() and
63-
os.path.join(parent, s) not in blacklist]
67+
s not in blacklist]
6468

6569

6670
def _get_changed_files():
@@ -149,7 +153,7 @@ def _setup_appengine_sdk(session):
149153

150154
# Collect sample directories.
151155
ALL_TESTED_SAMPLES = sorted(list(_collect_dirs('.')))
152-
ALL_SAMPLE_DIRECTORIES = sorted(list(_collect_dirs('.', suffix='.py')))
156+
ALL_SAMPLE_DIRECTORIES = sorted(list(_collect_dirs('.', suffix='.py', recurse_further=True)))
153157
GAE_STANDARD_SAMPLES = [
154158
sample for sample in ALL_TESTED_SAMPLES
155159
if sample.startswith('./appengine/standard/')]

0 commit comments

Comments
 (0)