Skip to content

Commit 7d4cd43

Browse files
JakobDegenfacebook-github-bot
authored andcommitted
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
1 parent 0780249 commit 7d4cd43

File tree

6 files changed

+78
-0
lines changed

6 files changed

+78
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
#
3+
# This source code is licensed under both the MIT license found in the
4+
# LICENSE-MIT file in the root directory of this source tree and the Apache
5+
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory
6+
# of this source tree.
7+
8+
# pyre-strict
9+
10+
11+
from buck2.tests.e2e_util.api.buck import Buck
12+
from buck2.tests.e2e_util.asserts import expect_failure
13+
from buck2.tests.e2e_util.buck_workspace import buck_test
14+
from buck2.tests.e2e_util.helper.golden import golden
15+
16+
17+
@buck_test()
18+
async def test_default_not_a_label(buck: Buck) -> None:
19+
res = await expect_failure(buck.uquery("root//:", "--console=none", "-v0"))
20+
golden(
21+
output=res.stderr,
22+
rel_path="golden/default_not_a_label.golden.stderr",
23+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[cells]
2+
root = .
3+
4+
[buildfile]
5+
name = TARGETS.fixture

tests/core/interpreter/test_attr_default_coercion_data/.buckroot

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
load(":error_rule.bzl", "error_rule")
2+
3+
error_rule(
4+
name = "foo",
5+
)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
#
3+
# This source code is licensed under both the MIT license found in the
4+
# LICENSE-MIT file in the root directory of this source tree and the Apache
5+
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory
6+
# of this source tree.
7+
8+
def _transition_impl(**_kwargs):
9+
pass
10+
11+
_transition = transition(
12+
impl = _transition_impl,
13+
refs = {},
14+
)
15+
16+
def _impl():
17+
pass
18+
19+
error_rule = rule(
20+
impl = _impl,
21+
attrs = {
22+
"someattr": attrs.transition_dep(default = "notaproperlabel", cfg = _transition),
23+
},
24+
)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# This file is @generated, regenerate by re-running test with `-- --env BUCK2_UPDATE_GOLDEN=1` appended to the test command
2+
3+
Command failed:
4+
Error evaluating expression:
5+
root//:
6+
^-----^
7+
8+
9+
Caused by:
10+
0: From load at TARGETS.fixture:1
11+
1: Error evaluating module: `root//error_rule.bzl`
12+
2: Traceback (most recent call last):
13+
* error_rule.bzl:22, in <module>
14+
"someattr": attrs.transition_dep(default = "notaproperlabel", cfg = _transiti...
15+
error: Type of parameters mismatch
16+
--> error_rule.bzl:22:21
17+
|
18+
22 | "someattr": attrs.transition_dep(default = "notaproperlabel", cfg = _transition),
19+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20+
|
21+

0 commit comments

Comments
 (0)