-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patterns: Add test for attrocious default coercion error
Summary: The things you find when you start looking, incredible (only a little bit sorry about the diff title) Reviewed By: IanChilds Differential Revision: D69713854 fbshipit-source-id: 495afee7364c0ea46bf1e2de40ab629dc19d0ef9
- Loading branch information
1 parent
0780249
commit 7d4cd43
Showing
6 changed files
with
78 additions
and
0 deletions.
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,23 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under both the MIT license found in the | ||
# LICENSE-MIT file in the root directory of this source tree and the Apache | ||
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory | ||
# of this source tree. | ||
|
||
# pyre-strict | ||
|
||
|
||
from buck2.tests.e2e_util.api.buck import Buck | ||
from buck2.tests.e2e_util.asserts import expect_failure | ||
from buck2.tests.e2e_util.buck_workspace import buck_test | ||
from buck2.tests.e2e_util.helper.golden import golden | ||
|
||
|
||
@buck_test() | ||
async def test_default_not_a_label(buck: Buck) -> None: | ||
res = await expect_failure(buck.uquery("root//:", "--console=none", "-v0")) | ||
golden( | ||
output=res.stderr, | ||
rel_path="golden/default_not_a_label.golden.stderr", | ||
) |
5 changes: 5 additions & 0 deletions
5
tests/core/interpreter/test_attr_default_coercion_data/.buckconfig
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,5 @@ | ||
[cells] | ||
root = . | ||
|
||
[buildfile] | ||
name = TARGETS.fixture |
Empty file.
5 changes: 5 additions & 0 deletions
5
tests/core/interpreter/test_attr_default_coercion_data/TARGETS.fixture
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,5 @@ | ||
load(":error_rule.bzl", "error_rule") | ||
|
||
error_rule( | ||
name = "foo", | ||
) |
24 changes: 24 additions & 0 deletions
24
tests/core/interpreter/test_attr_default_coercion_data/error_rule.bzl
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,24 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under both the MIT license found in the | ||
# LICENSE-MIT file in the root directory of this source tree and the Apache | ||
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory | ||
# of this source tree. | ||
|
||
def _transition_impl(**_kwargs): | ||
pass | ||
|
||
_transition = transition( | ||
impl = _transition_impl, | ||
refs = {}, | ||
) | ||
|
||
def _impl(): | ||
pass | ||
|
||
error_rule = rule( | ||
impl = _impl, | ||
attrs = { | ||
"someattr": attrs.transition_dep(default = "notaproperlabel", cfg = _transition), | ||
}, | ||
) |
21 changes: 21 additions & 0 deletions
21
...core/interpreter/test_attr_default_coercion_data/golden/default_not_a_label.golden.stderr
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,21 @@ | ||
# This file is @generated, regenerate by re-running test with `-- --env BUCK2_UPDATE_GOLDEN=1` appended to the test command | ||
|
||
Command failed: | ||
Error evaluating expression: | ||
root//: | ||
^-----^ | ||
|
||
|
||
Caused by: | ||
0: From load at TARGETS.fixture:1 | ||
1: Error evaluating module: `root//error_rule.bzl` | ||
2: Traceback (most recent call last): | ||
* error_rule.bzl:22, in <module> | ||
"someattr": attrs.transition_dep(default = "notaproperlabel", cfg = _transiti... | ||
error: Type of parameters mismatch | ||
--> error_rule.bzl:22:21 | ||
| | ||
22 | "someattr": attrs.transition_dep(default = "notaproperlabel", cfg = _transition), | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
|