-
Notifications
You must be signed in to change notification settings - Fork 3k
Share test discovery logic #2107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,7 @@ | |
| from tools.config import Config | ||
|
|
||
| from multiprocessing import Pool, cpu_count | ||
| from tools.utils import run_cmd, mkdir, rel_path, ToolException, NotSupportedException, split_path | ||
| from tools.utils import run_cmd, mkdir, rel_path, ToolException, NotSupportedException, split_path, directory_in_path, is_test_directory | ||
| from tools.settings import BUILD_OPTIONS, MBED_ORG_USER | ||
| import tools.hooks as hooks | ||
| from tools.memap import MemapParser | ||
|
|
@@ -94,6 +94,10 @@ def __init__(self, base_path=None): | |
|
|
||
| # Features | ||
| self.features = {} | ||
|
|
||
| # Tests | ||
| self.test_directories = [] | ||
|
|
||
|
|
||
| def __add__(self, resources): | ||
| if resources is None: | ||
|
|
@@ -496,7 +500,7 @@ def _add_dir(self, path, resources, base_path, exclude_paths=None): | |
| for d in copy(dirs): | ||
| dir_path = join(root, d) | ||
| # Add internal repo folders/files. This is needed for exporters | ||
| if d == '.hg': | ||
| if d == '.hg' and not directory_in_path('TESTS', relpath(root, path)): | ||
| resources.repo_dirs.append(dir_path) | ||
| resources.repo_files.extend(self.scan_repository(dir_path)) | ||
|
|
||
|
|
@@ -506,10 +510,11 @@ def _add_dir(self, path, resources, base_path, exclude_paths=None): | |
| # Ignore toolchain that do not match the current TOOLCHAIN | ||
| (d.startswith('TOOLCHAIN_') and d[10:] not in labels['TOOLCHAIN']) or | ||
| # Ignore .mbedignore files | ||
| self.is_ignored(join(dir_path,"")) or | ||
| # Ignore TESTS dir | ||
| (d == 'TESTS')): | ||
| self.is_ignored(join(dir_path,""))): | ||
| dirs.remove(d) | ||
| elif is_test_directory(relpath(dir_path, path)): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not have similar logic to features discovery/accumulation? |
||
| resources.test_directories.append(dir_path) | ||
| dirs.remove(d) | ||
| elif d.startswith('FEATURE_'): | ||
| # Recursively scan features but ignore them in the current scan. | ||
| # These are dynamically added by the config system if the conditions are matched | ||
|
|
@@ -525,9 +530,10 @@ def _add_dir(self, path, resources, base_path, exclude_paths=None): | |
| # Add root to include paths | ||
| resources.inc_dirs.append(root) | ||
|
|
||
| for file in files: | ||
| file_path = join(root, file) | ||
| self._add_file(file_path, resources, base_path) | ||
| if not directory_in_path('TESTS', relpath(root, path)): | ||
| for file in files: | ||
| file_path = join(root, file) | ||
| self._add_file(file_path, resources, base_path) | ||
|
|
||
| # A helper function for both scan_resources and _add_dir. _add_file adds one file | ||
| # (*file_path*) to the resources object based on the file type. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed