-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Move
test_build_configured
to core
Summary: And isolate it at the same time Reviewed By: IanChilds Differential Revision: D63972124 fbshipit-source-id: d7a24e28926ad5b9042a2324459e04e81ea8ee6f
- Loading branch information
1 parent
37c2413
commit f459c08
Showing
8 changed files
with
104 additions
and
110 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# 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 json | ||
import re | ||
import typing | ||
|
||
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 | ||
|
||
|
||
# Obtain hashes of `<astrologer>` and `<vagabond>` configurations. | ||
async def _obtain_cfg_hashes(buck: Buck) -> typing.Tuple[str, str]: | ||
result = await buck.cquery( | ||
"root//:simple", | ||
"--target-universe", | ||
"root//:universe", | ||
) | ||
[astrologer, vagabond] = result.stdout.splitlines() | ||
assert astrologer.startswith("root//:simple (<astrologer>#") | ||
assert vagabond.startswith("root//:simple (<vagabond>#") | ||
astrologer_hash = re.sub(r".*#(.*)\)", r"\1", astrologer) | ||
vagabond_hash = re.sub(r".*#(.*)\)", r"\1", vagabond) | ||
assert re.fullmatch("[0-9a-f]{16}", astrologer_hash), astrologer | ||
assert re.fullmatch("[0-9a-f]{16}", vagabond_hash), vagabond | ||
return (astrologer_hash, vagabond_hash) | ||
|
||
|
||
@buck_test() | ||
async def test_build_configured_full_configuration(buck: Buck) -> None: | ||
(astrologer_hash, _) = await _obtain_cfg_hashes(buck) | ||
|
||
result = await buck.build( | ||
f"root//:simple (<astrologer>#{astrologer_hash})", | ||
"--target-universe", | ||
"root//:universe", | ||
) | ||
out = result.get_build_report().output_for_target("root//:simple").read_text() | ||
assert f"$$$root//:simple (<astrologer>#{astrologer_hash})$$$" == out | ||
|
||
|
||
@buck_test() | ||
async def test_build_configured_no_hash(buck: Buck) -> None: | ||
(_, vagabond_hash) = await _obtain_cfg_hashes(buck) | ||
result = await buck.build( | ||
"root//:simple (<vagabond>)", | ||
"--target-universe", | ||
"root//:universe", | ||
) | ||
out = result.get_build_report().output_for_target("root//:simple").read_text() | ||
assert f"$$$root//:simple (<vagabond>#{vagabond_hash})$$$" == out | ||
|
||
|
||
@buck_test() | ||
async def test_build_configured_wrong_hash(buck: Buck) -> None: | ||
result = await buck.build( | ||
"root//:simple (<vagabond>#0123456789abcdef)", | ||
"--target-universe", | ||
"root//:universe", | ||
) | ||
# TODO(nga): this should either fail or emit a warning. | ||
assert "root//:simple" not in json.loads(result.stdout)["results"] | ||
|
||
|
||
@buck_test() | ||
async def test_build_configured_no_universe(buck: Buck) -> None: | ||
await expect_failure( | ||
buck.build( | ||
"root//:simple (<vagabond>)", | ||
), | ||
stderr_regex="Targets with explicit configuration can only be built when the", | ||
) |
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,12 @@ | ||
[cells] | ||
root = . | ||
nano_prelude = nano_prelude | ||
|
||
[cell_aliases] | ||
prelude = nano_prelude | ||
|
||
[external_cells] | ||
nano_prelude = bundled | ||
|
||
[buildfile] | ||
name = TARGETS.fixture |
Empty file.
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
File renamed without changes.
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 was deleted.
Oops, something went wrong.