-
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.
buck2/dice: ignore overrides for buck2_re_client.override_use_case
Summary: Ignore changes to `buck2_re_client.override_use_case` for legacy config state in DICE. Reviewed By: JakobDegen Differential Revision: D64477014 fbshipit-source-id: ad909caee5211992150e0b23e0304b85bcf2bfc2
- Loading branch information
1 parent
3446b86
commit 074c833
Showing
10 changed files
with
212 additions
and
2 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
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
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 |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# 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 | ||
|
||
|
||
import tempfile | ||
|
||
from buck2.tests.e2e_util.api.buck import Buck | ||
from buck2.tests.e2e_util.buck_workspace import buck_test | ||
from buck2.tests.e2e_util.helper.utils import filter_events | ||
|
||
|
||
async def check_dice_equality(buck: Buck) -> None: | ||
dice_equal = await filter_events( | ||
buck, | ||
"Event", | ||
"data", | ||
"Instant", | ||
"data", | ||
"DiceEqualityCheck", | ||
"is_equal", | ||
) | ||
assert len(dice_equal) == 1 | ||
assert dice_equal[0] is True | ||
|
||
|
||
async def check_config_is_the_same(buck: Buck) -> None: | ||
diff_count = await filter_events( | ||
buck, | ||
"Event", | ||
"data", | ||
"Instant", | ||
"data", | ||
"CellConfigDiff", | ||
"config_diff_count", | ||
) | ||
assert len(diff_count) == 1 | ||
assert diff_count[0] == 0 | ||
|
||
|
||
@buck_test() | ||
async def test_ignore_state_invalidation_with_re_override_in_arg(buck: Buck) -> None: | ||
# Add arg to switch to buck2-user | ||
await buck.build( | ||
"root//:simple", | ||
"--config", | ||
"buck2_re_client.override_use_case=buck2-user", | ||
) | ||
# No arg, default is buck2-default | ||
await buck.build("root//:simple") | ||
await check_dice_equality(buck) | ||
# Add arg to switch to buck2-user again | ||
await buck.build( | ||
"root//:simple", | ||
"--config", | ||
"buck2_re_client.override_use_case=buck2-user", | ||
) | ||
await check_dice_equality(buck) | ||
|
||
|
||
@buck_test() | ||
async def test_ignore_state_invalidation_with_re_override_in_config(buck: Buck) -> None: | ||
# Default is buck2-default | ||
await buck.build("root//:simple") | ||
# Add config to switch to buck2-user | ||
with open(buck.cwd / ".buckconfig.local", "w") as f: | ||
f.write("[buck2_re_client]\n") | ||
f.write("override_use_case = buck2-user\n") | ||
await buck.build("root//:simple") | ||
await check_config_is_the_same(buck) | ||
# Add config to return to buck2-default | ||
with open(buck.cwd / ".buckconfig.local", "w") as f: | ||
f.write("[buck2_re_client]\n") | ||
f.write("override_use_case = buck2-default\n") | ||
await buck.build("root//:simple") | ||
await check_config_is_the_same(buck) | ||
|
||
|
||
@buck_test() | ||
async def test_ignore_state_invalidation_with_re_override_in_external_config( | ||
buck: Buck, | ||
) -> None: | ||
# Default is buck2-default | ||
await buck.build("root//:simple") | ||
# Add config to switch to buck2-user | ||
with tempfile.NamedTemporaryFile("w", delete=False) as f: | ||
f.write("[buck2_re_client]\n") | ||
f.write("override_use_case = buck2-user\n") | ||
f.close() | ||
await buck.build("root//:simple", "--config-file", f.name) | ||
await check_config_is_the_same(buck) | ||
# Add config to return to buck2-default | ||
with tempfile.NamedTemporaryFile("w", delete=False) as f: | ||
f.write("[buck2_re_client]\n") | ||
f.write("override_use_case = buck2-default\n") | ||
f.close() | ||
await buck.build("root//:simple", "--config-file", f.name) | ||
await check_config_is_the_same(buck) |
5 changes: 5 additions & 0 deletions
5
tests/core/cells/test_ignore_state_invalidation_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 @@ | ||
[buildfile] | ||
name=TARGETS.fixture | ||
|
||
[cells] | ||
root = . |
Empty file.
3 changes: 3 additions & 0 deletions
3
tests/core/cells/test_ignore_state_invalidation_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,3 @@ | ||
load(":defs.bzl", "simple") | ||
|
||
simple(name = "simple") |
30 changes: 30 additions & 0 deletions
30
tests/core/cells/test_ignore_state_invalidation_data/defs.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,30 @@ | ||
# 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 _simple(ctx): | ||
re_use_case = read_config("buck2_re_client", "override_use_case") | ||
if re_use_case != None: | ||
fail("RE use case is set to: {}".format(re_use_case)) | ||
output = ctx.actions.declare_output("output") | ||
run = ctx.actions.write( | ||
"run.py", | ||
[ | ||
"import os", | ||
"import sys", | ||
"build_id = os.environ[\"BUCK_BUILD_ID\"]", | ||
"with open(sys.argv[1], 'w') as f:", | ||
" f.write(f'{build_id}\\n')", | ||
], | ||
) | ||
ctx.actions.run( | ||
cmd_args(["python3", run, output.as_output()]), | ||
category = "test_category", | ||
) | ||
|
||
return [DefaultInfo(default_output = output)] | ||
|
||
simple = rule(impl = _simple, attrs = {}) |