From b2fad37386e42a7b8f1284c81bf866373605dad7 Mon Sep 17 00:00:00 2001 From: Ace Nassri Date: Mon, 13 Aug 2018 10:37:39 -0700 Subject: [PATCH] Fix nox not recognizing directories Change-Id: I25f7768c35564f12c26cfec084993c84723ab16f --- nox.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/nox.py b/nox.py index e4fb2d1ef2e..03c865a48b1 100644 --- a/nox.py +++ b/nox.py @@ -40,8 +40,9 @@ def _list_files(folder, pattern): def _collect_dirs( start_dir, - blacklist=set(['conftest.py', 'nox.py']), - suffix='_test.py'): + blacklist=set(['conftest.py', 'nox.py', 'lib']), + suffix='_test.py', + recurse_further=False): """Recursively collects a list of dirs that contain a file matching the given suffix. @@ -50,17 +51,20 @@ def _collect_dirs( """ # Collect all the directories that have tests in them. for parent, subdirs, files in os.walk(start_dir): - if any(f for f in files if f.endswith(suffix) and f not in blacklist): - # Don't recurse further, since py.test will do that. - del subdirs[:] - # This dir has tests in it. yield it. + if './.' in parent: + continue # Skip top-level dotfiles + elif any(f for f in files if f.endswith(suffix) and f not in blacklist): + # Don't recurse further for tests, since py.test will do that. + if not recurse_further: + del subdirs[:] + # This dir has desired files in it. yield it. yield parent else: # Filter out dirs we don't want to recurse into subdirs[:] = [ s for s in subdirs if s[0].isalpha() and - os.path.join(parent, s) not in blacklist] + s not in blacklist] def _get_changed_files(): @@ -149,7 +153,7 @@ def _setup_appengine_sdk(session): # Collect sample directories. ALL_TESTED_SAMPLES = sorted(list(_collect_dirs('.'))) -ALL_SAMPLE_DIRECTORIES = sorted(list(_collect_dirs('.', suffix='.py'))) +ALL_SAMPLE_DIRECTORIES = sorted(list(_collect_dirs('.', suffix='.py', recurse_further=True))) GAE_STANDARD_SAMPLES = [ sample for sample in ALL_TESTED_SAMPLES if sample.startswith('./appengine/standard/')]