-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Enable --resource-type
and --exclude-resource-type
CLI flags and environment variables for dbt test
#10706
Merged
Merged
Enable --resource-type
and --exclude-resource-type
CLI flags and environment variables for dbt test
#10706
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
3e19e62
Adding logic to TestSelector to remove unit tests if they are in excl…
TowardOliver 4914cc9
Adding change log
TowardOliver 9ab1c0d
Respect `--resource-type` and `--exclude-resource-type` CLI flags and…
dbeatty10 57fed01
Test CLI flag for excluding unit tests for the `dbt test` command
dbeatty10 7cf2e2e
Satisy isort pre-commit hook
dbeatty10 1d5d1dc
Fix mypy for positional argument "resource_types" in call to "TestSel…
dbeatty10 bd74613
Replace `TestSelector` with `ResourceTypeSelector`
dbeatty10 ed79666
Add co-author
dbeatty10 f9f563b
Update changelog description
dbeatty10 c8e363e
Merge branch 'main' into dbeatty/fix-10656
dbeatty10 01ba1b6
Add functional tests for new feature
dbeatty10 0c966e6
Compare the actual results, not just the count
dbeatty10 3864740
Remove test case covered elsewhere
dbeatty10 0856e85
Test for `DBT_EXCLUDE_RESOURCE_TYPES` environment variable for `dbt t…
dbeatty10 4e7a3c3
Update per pre-commit hook
dbeatty10 98249eb
Restore to original form (until we refactor extraneous `ResourceTypeS…
dbeatty10 8186042
Merge branch 'main' into dbeatty/fix-10656
dbeatty10 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 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Features | ||
body: Enable `--resource-type` and `--exclude-resource-type` CLI flags and environment variables for `dbt test` | ||
time: 2024-09-03T13:24:28.592837+01:00 | ||
custom: | ||
Author: TowardOliver dbeatty10 | ||
Issue: "10656" |
This file contains 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 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 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 |
---|---|---|
|
@@ -3,7 +3,17 @@ | |
import re | ||
import threading | ||
from dataclasses import dataclass | ||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Type, Union | ||
from typing import ( | ||
TYPE_CHECKING, | ||
Any, | ||
Collection, | ||
Dict, | ||
List, | ||
Optional, | ||
Tuple, | ||
Type, | ||
Union, | ||
) | ||
|
||
import daff | ||
|
||
|
@@ -25,9 +35,9 @@ | |
from dbt.exceptions import BooleanError, DbtInternalError | ||
from dbt.flags import get_flags | ||
from dbt.graph import ResourceTypeSelector | ||
from dbt.node_types import NodeType | ||
from dbt.node_types import TEST_NODE_TYPES, NodeType | ||
from dbt.parser.unit_tests import UnitTestManifestLoader | ||
from dbt.task.base import BaseRunner | ||
from dbt.task.base import BaseRunner, resource_types_from_args | ||
from dbt.utils import _coerce_decimal, strtobool | ||
from dbt_common.dataclass_schema import dbtClassMixin | ||
from dbt_common.events.format import pluralize | ||
|
@@ -387,14 +397,24 @@ class TestTask(RunTask): | |
def raise_on_first_error(self) -> bool: | ||
return False | ||
|
||
@property | ||
def resource_types(self) -> List[NodeType]: | ||
resource_types: Collection[NodeType] = resource_types_from_args( | ||
self.args, set(TEST_NODE_TYPES), set(TEST_NODE_TYPES) | ||
) | ||
|
||
# filter out any non-test node types | ||
resource_types = [rt for rt in resource_types if rt in TEST_NODE_TYPES] | ||
return list(resource_types) | ||
|
||
def get_node_selector(self) -> ResourceTypeSelector: | ||
if self.manifest is None or self.graph is None: | ||
raise DbtInternalError("manifest and graph must be set to get perform node selection") | ||
return ResourceTypeSelector( | ||
graph=self.graph, | ||
manifest=self.manifest, | ||
previous_state=self.previous_state, | ||
resource_types=[NodeType.Test, NodeType.Unit], | ||
resource_types=self.resource_types, | ||
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. |
||
) | ||
|
||
def get_runner_type(self, _) -> Optional[Type[BaseRunner]]: | ||
|
This file contains 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 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
Oops, something went wrong.
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.
This is basically the same thing as here and here.