Skip to content

Commit

Permalink
tests: Move more of tests/build into core
Browse files Browse the repository at this point in the history
Summary:
```
for p in tests/e2e/build/test_*.py
    rg 'inplace=True' $p && continue
    sl mv $p tests/core/build/
    set part (string sub -e -3 $p)
    sl mv "$part"_data tests/core/build
end
sl st -m -a -n | xargs sed -i -E 's|inplace=False,||'
sl st -m -a -n | xargs sed -i -E 's|inplace=False||'
arc f
```

And then split the targets file

I discovered after originally writing this diff that some of these tests are !inplace but actually depend on ovr_config and the prelude. Most of those were pretty straightforward to fix, but `test_build_isolated` is not and so was left out of this change

Reviewed By: IanChilds

Differential Revision: D63972135

fbshipit-source-id: 2ae7b84b935344a687740f64a599c6328d41a905
  • Loading branch information
JakobDegen authored and facebook-github-bot committed Oct 7, 2024
1 parent fb937af commit e443eed
Show file tree
Hide file tree
Showing 288 changed files with 310 additions and 327 deletions.
214 changes: 214 additions & 0 deletions tests/core/build/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
load("@fbcode//buck2/tests:buck_e2e.bzl", "buck2_e2e_test")

oncall("build_infra")

buck2_e2e_test(
name = "test_build_output_file_hashes",
srcs = ["test_build_output_file_hashes.py"],
data_dir = "test_build_output_file_hashes_data",
env = {
"OVR_CONFIG": "1",
"PRELUDE": "$(location prelude//:prelude)",
},
serialize_test_cases = False,
)

buck2_e2e_test(
name = "test_build_skip_incompatible_targets",
srcs = ["test_build_skip_incompatible_targets.py"],
data_dir = "test_build_skip_incompatible_targets_data",
)

buck2_e2e_test(
name = "test_build_root_executable",
srcs = ["test_build_root_executable.py"],
data_dir = "test_build_root_executable_data",
serialize_test_cases = False,
)

buck2_e2e_test(
name = "test_plugins",
srcs = ["test_plugins.py"],
data_dir = "test_plugins_data",
serialize_test_cases = False,
)

buck2_e2e_test(
name = "test_uncategorized",
srcs = ["test_uncategorized.py"],
data_dir = "test_uncategorized_data",
env = {
"RECLI": "$(location fbsource//xplat/remote_execution/dotslash:recli)",
},
serialize_test_cases = False,
deps = [
"fbcode//buck2/tests/e2e_util:utils",
],
)

buck2_e2e_test(
name = "test_hash_all_commands",
srcs = ["test_hash_all_commands.py"],
data_dir = "test_hash_all_commands_data",
# These tests heavily depend on watchman, which is flakey on non-Linux systems
skip_for_os = [
"darwin",
"windows",
],
deps = [
"fbcode//buck2/tests/e2e_util:utils",
],
)

buck2_e2e_test(
name = "test_dep_files",
srcs = ["test_dep_files.py"],
data_dir = "test_dep_files_data",
deps = [
"fbcode//buck2/tests/e2e_util:utils",
],
)

buck2_e2e_test(
name = "test_target_aliases",
srcs = ["test_target_aliases.py"],
data_dir = "test_target_aliases_data",
)

buck2_e2e_test(
name = "test_symlinks",
srcs = ["test_symlinks.py"],
data_dir = "test_symlinks_data",
deps = [
"fbcode//buck2/tests/e2e_util:utils",
],
)

buck2_e2e_test(
name = "test_out_flag",
srcs = ["test_out_flag.py"],
data_dir = "test_out_flag_data",
env = {
"OVR_CONFIG": "1",
"PRELUDE": "$(location prelude//:prelude)",
},
)

buck2_e2e_test(
name = "test_nested_subtargets",
srcs = ["test_nested_subtargets.py"],
data_dir = "test_nested_subtargets_data",
env = {
"OVR_CONFIG": "1",
"PRELUDE": "$(location prelude//:prelude)",
},
)

buck2_e2e_test(
name = "test_build_report",
srcs = ["test_build_report.py"],
data_dir = "test_build_report_data",
env = {
"OVR_CONFIG": "1",
"PRELUDE": "$(location prelude//:prelude)",
},
deps = [
"//buck2/tests/e2e_util:utils",
],
)

buck2_e2e_test(
name = "test_build_report_errors",
srcs = ["test_build_report_errors.py"],
data_dir = "test_build_report_errors_data",
deps = [
"fbcode//buck2/tests/e2e_util:golden",
],
)

buck2_e2e_test(
name = "test_build_id_env_var",
srcs = ["test_build_id_env_var.py"],
data_dir = "test_build_id_env_var_data",
deps = [
"//buck2/tests/e2e_util:utils",
],
)

buck2_e2e_test(
name = "test_cancellation",
srcs = ["test_cancellation.py"],
data_dir = "test_cancellation_data",
skip_for_os = ["windows"],
)

buck2_e2e_test(
name = "test_critical_path",
srcs = ["test_critical_path.py"],
data_dir = "test_critical_path_data",
deps = [
"//buck2/tests/e2e_util:utils",
],
)

buck2_e2e_test(
name = "test_build_response",
srcs = ["test_build_response.py"],
data_dir = "test_build_response_data",
env = {
"OVR_CONFIG": "1",
"PRELUDE": "$(location prelude//:prelude)",
},
deps = [
"//buck2/tests/e2e_util:utils",
],
)

buck2_e2e_test(
name = "test_build_rule_type_name_logging",
srcs = ["test_build_rule_type_name_logging.py"],
data_dir = "test_build_rule_type_name_logging_data",
env = {
"OVR_CONFIG": "1",
"PRELUDE": "$(location prelude//:prelude)",
},
deps = [
"//buck2/tests/e2e_util:utils",
],
)

buck2_e2e_test(
name = "test_executor_with_dependencies",
srcs = ["test_executor_with_dependencies.py"],
data_dir = "test_executor_with_dependencies_data",
deps = [
"//buck2/tests/e2e_util:utils",
],
)

buck2_e2e_test(
name = "test_action_error_handler_types",
srcs = ["test_action_error_handler_types.py"],
data_dir = "test_action_error_handler_types_data",
deps = [
"//buck2/tests/e2e_util:utils",
],
)

buck2_e2e_test(
name = "test_build_system_info",
srcs = ["test_build_system_info.py"],
data_dir = "test_build_system_info_data",
deps = [
"//buck2/tests/e2e_util:utils",
],
)

buck2_e2e_test(
name = "test_remote_execution",
srcs = ["test_remote_execution.py"],
data_dir = "test_remote_execution_data",
deps = [
"//buck2/tests/e2e_util:utils",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from buck2.tests.e2e_util.buck_workspace import buck_test


@buck_test(inplace=False)
@buck_test()
async def test_action_error_handler_types(buck: Buck) -> None:
await buck.bxl(
"//:test_action_error_handler_types.bxl:test_action_error_handler_types"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from buck2.tests.e2e_util.helper.utils import random_string


@buck_test(inplace=False)
@buck_test()
async def test_build_id_env_var_is_set_locally(buck: Buck) -> None:
result = await buck.build(
"root//:top",
Expand All @@ -29,7 +29,7 @@ async def test_build_id_env_var_is_set_locally(buck: Buck) -> None:
assert f.read().strip() == result.buck_build_id


@buck_test(inplace=False)
@buck_test()
async def test_build_id_env_var_is_set_remotely(buck: Buck) -> None:
result = await buck.build(
"root//:top",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from buck2.tests.e2e_util.buck_workspace import buck_test


@buck_test(inplace=False)
@buck_test()
async def test_file_output(
buck: Buck,
tmp_path: Path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from buck2.tests.e2e_util.helper.utils import replace_hashes


@buck_test(inplace=False)
@buck_test()
async def test_build_report_format(buck: Buck) -> None:
await buck.build(
"//:rule1",
Expand Down Expand Up @@ -73,7 +73,7 @@ async def test_build_report_format(buck: Buck) -> None:
assert rule2_configured["configured_graph_size"] == 3


@buck_test(inplace=False)
@buck_test()
async def test_build_report_format_skip_unconfigured(buck: Buck) -> None:
await buck.build(
"//:rule1",
Expand Down Expand Up @@ -102,7 +102,7 @@ async def test_build_report_format_skip_unconfigured(buck: Buck) -> None:
assert rule1_configured["other_outputs"] == {}


@buck_test(inplace=False)
@buck_test()
async def test_build_report_package_project_relative_path(buck: Buck) -> None:
await buck.build(
"//:rule1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async def impl(buck: Buck, tmp_path: Path) -> None:

globals()[name] = impl

return buck_test(inplace=False)(impl)
return buck_test()(impl)


build_report_test(
Expand Down Expand Up @@ -149,7 +149,7 @@ def running_on_mac() -> bool:
["//fail_action:fail_one_with_error_handler_no_op"],
)

@buck_test(inplace=False)
@buck_test()
async def test_stderr_with_empty_error_diagnostics(buck: Buck) -> None:
result = await expect_failure(
buck.build("//fail_action:fail_one_with_error_handler_no_op")
Expand All @@ -160,7 +160,7 @@ async def test_stderr_with_empty_error_diagnostics(buck: Buck) -> None:
rel_path="fixtures/test_stderr_with_empty_error_diagnostics.golden.txt",
)

@buck_test(inplace=False)
@buck_test()
async def test_stderr_with_error_diagnostics(buck: Buck) -> None:
result = await expect_failure(
buck.build("//fail_action:error_handler_produced_multiple_categories")
Expand All @@ -171,7 +171,7 @@ async def test_stderr_with_error_diagnostics(buck: Buck) -> None:
rel_path="fixtures/test_stderr_with_error_diagnostics.golden.txt",
)

@buck_test(inplace=False)
@buck_test()
async def test_stderr_with_no_error_diagnostics(buck: Buck) -> None:
result = await expect_failure(buck.build("//fail_action:fail_script"))

Expand All @@ -180,7 +180,7 @@ async def test_stderr_with_no_error_diagnostics(buck: Buck) -> None:
rel_path="fixtures/test_stderr_with_no_error_diagnostics.golden.txt",
)

@buck_test(inplace=False)
@buck_test()
async def test_stderr_could_not_produce_error_diagnostics(buck: Buck) -> None:
result = await expect_failure(buck.build("//fail_action:error_handler_failed"))

Expand Down Expand Up @@ -251,7 +251,7 @@ async def test_stderr_could_not_produce_error_diagnostics(buck: Buck) -> None:
)


@buck_test(inplace=False, setup_eden=True)
@buck_test(setup_eden=True)
async def test_two_action_dep_failures(buck: Buck, tmp_path: Path) -> None:
# When we pass `--keep-going`, we should get error reports for both dependencies of the action.
# However, we don't. Instead, we just get one error non-deterministically. This is also why we
Expand Down Expand Up @@ -279,7 +279,7 @@ async def test_two_action_dep_failures(buck: Buck, tmp_path: Path) -> None:
assert "fail_two_deps" in errors[0]["action_error"]["key"]["owner"]


@buck_test(inplace=False)
@buck_test()
async def test_error_handler_failed(buck: Buck, tmp_path: Path) -> None:
# Starlark error messages change across different modes for some reason (ex: opt-asan vs opt).
# We have a fair amount of coverage for other functionalities of error handler/build report,
Expand All @@ -302,7 +302,7 @@ async def test_error_handler_failed(buck: Buck, tmp_path: Path) -> None:
assert "fail: something went wrong" in report


@buck_test(inplace=False)
@buck_test()
async def test_error_handler_wrong_return_type(buck: Buck, tmp_path: Path) -> None:
# Starlark error messages change across different modes for some reason (ex: opt-asan vs opt).
# We have a fair amount of coverage for other functionalities of error handler/build report,
Expand All @@ -328,7 +328,7 @@ async def test_error_handler_wrong_return_type(buck: Buck, tmp_path: Path) -> No
)


@buck_test(inplace=False)
@buck_test()
async def test_missing_report_on_wrong_package(buck: Buck, tmp_path: Path) -> None:
# If we specify a non-existent package, we don't get an error report
report = tmp_path / "build-report.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async def check_targets(
assert expected in actual_msg["message"]


@buck_test(inplace=False)
@buck_test()
async def test_build_one_fails(buck: Buck, tmp_path: Path) -> None:
report = tmp_path / "build-report.json"
await expect_failure(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
"""


@buck_test(inplace=False)
@buck_test()
async def test_build_root_executable_local(buck: Buck) -> None:
await buck.build(":top", "--local-only")


@buck_test(inplace=False)
@buck_test()
async def test_build_root_executable_remote(buck: Buck) -> None:
await buck.build(":top", "--remote-only")
Loading

0 comments on commit e443eed

Please sign in to comment.