From 89aec557796a3a404f3458b8643a85d49a789b83 Mon Sep 17 00:00:00 2001 From: UebelAndre Date: Thu, 19 Dec 2024 16:22:27 -0800 Subject: [PATCH] Added bzlmod support to rust-analyzer tests (#3125) --- MODULE.bazel | 6 +- WORKSPACE.bazel | 11 ---- test/deps.bzl | 2 + test/{ => rust_analyzer}/3rdparty/BUILD.bazel | 8 +-- .../3rdparty/crates/BUILD.bazel | 6 +- .../3rdparty/crates/BUILD.itoa-1.0.14.bazel | 2 +- .../3rdparty/crates/BUILD.memchr-2.7.4.bazel | 2 +- .../crates/BUILD.proc-macro2-1.0.92.bazel | 6 +- .../3rdparty/crates/BUILD.quote-1.0.37.bazel | 4 +- .../3rdparty/crates/BUILD.ryu-1.0.18.bazel | 2 +- .../crates/BUILD.serde-1.0.216.bazel} | 10 +-- .../crates/BUILD.serde_derive-1.0.216.bazel} | 10 +-- .../crates/BUILD.serde_json-1.0.133.bazel | 12 ++-- .../3rdparty/crates/BUILD.syn-2.0.90.bazel | 8 +-- .../crates/BUILD.unicode-ident-1.0.14.bazel | 2 +- .../3rdparty/crates/alias_rules.bzl | 0 .../3rdparty/crates/crates.bzl | 10 +-- .../3rdparty/crates/defs.bzl | 62 +++++++++---------- test/rust_analyzer/3rdparty/extensions.bzl | 21 +++++++ .../aspect_traversal_test/BUILD.bazel | 4 +- .../generated_srcs_test/BUILD.bazel | 4 +- .../merging_crates_test/BUILD.bazel | 4 +- .../rust_analyzer_test_runner.sh | 49 +++++++++++---- .../static_and_shared_lib_test/BUILD.bazel | 4 +- test/test_extensions.bzl | 2 - 25 files changed, 144 insertions(+), 107 deletions(-) rename test/{ => rust_analyzer}/3rdparty/BUILD.bazel (63%) rename test/{ => rust_analyzer}/3rdparty/crates/BUILD.bazel (83%) rename test/{ => rust_analyzer}/3rdparty/crates/BUILD.itoa-1.0.14.bazel (98%) rename test/{ => rust_analyzer}/3rdparty/crates/BUILD.memchr-2.7.4.bazel (98%) rename test/{ => rust_analyzer}/3rdparty/crates/BUILD.proc-macro2-1.0.92.bazel (96%) rename test/{ => rust_analyzer}/3rdparty/crates/BUILD.quote-1.0.37.bazel (96%) rename test/{ => rust_analyzer}/3rdparty/crates/BUILD.ryu-1.0.18.bazel (98%) rename test/{3rdparty/crates/BUILD.serde-1.0.215.bazel => rust_analyzer/3rdparty/crates/BUILD.serde-1.0.216.bazel} (95%) rename test/{3rdparty/crates/BUILD.serde_derive-1.0.215.bazel => rust_analyzer/3rdparty/crates/BUILD.serde_derive-1.0.216.bazel} (94%) rename test/{ => rust_analyzer}/3rdparty/crates/BUILD.serde_json-1.0.133.bazel (94%) rename test/{ => rust_analyzer}/3rdparty/crates/BUILD.syn-2.0.90.bazel (94%) rename test/{ => rust_analyzer}/3rdparty/crates/BUILD.unicode-ident-1.0.14.bazel (98%) rename test/{ => rust_analyzer}/3rdparty/crates/alias_rules.bzl (100%) rename test/{ => rust_analyzer}/3rdparty/crates/crates.bzl (72%) rename test/{ => rust_analyzer}/3rdparty/crates/defs.bzl (89%) create mode 100644 test/rust_analyzer/3rdparty/extensions.bzl diff --git a/MODULE.bazel b/MODULE.bazel index 225ff3318f..d30562763c 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -69,11 +69,11 @@ use_repo( "buildkite_config", "generated_inputs_in_external_repo", "libc", + "rtra", + "rtra__serde-1.0.216", + "rtra__serde_json-1.0.133", "rules_rust_test_load_arbitrary_tool", "rules_rust_toolchain_test_target_json", - "t3p", - "t3p__serde-1.0.215", - "t3p__serde_json-1.0.133", ) bazel_dep( diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index 483d238984..1a5e55696e 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -49,14 +49,3 @@ http_archive( # # load("@bazel_ci_rules//:rbe_repo.bzl", "rbe_preconfig") # rbe_preconfig(name = "buildkite_config", toolchain = "ubuntu2004-bazel-java11") - -http_archive( - name = "rules_testing", - sha256 = "02c62574631876a4e3b02a1820cb51167bb9cdcdea2381b2fa9d9b8b11c407c4", - strip_prefix = "rules_testing-0.6.0", - url = "https://github.com/bazelbuild/rules_testing/releases/download/v0.6.0/rules_testing-v0.6.0.tar.gz", -) - -load("//test/3rdparty/crates:crates.bzl", test_crate_repositories = "crate_repositories") - -test_crate_repositories() diff --git a/test/deps.bzl b/test/deps.bzl index abf8a97c56..210fe64518 100644 --- a/test/deps.bzl +++ b/test/deps.bzl @@ -4,6 +4,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") load("//test/generated_inputs:external_repo.bzl", "generated_inputs_in_external_repo") load("//test/load_arbitrary_tool:load_arbitrary_tool_test.bzl", "load_arbitrary_tool_test") +load("//test/rust_analyzer/3rdparty/crates:crates.bzl", rust_analyzer_test_crate_repositories = "crate_repositories") load("//test/unit/toolchain:toolchain_test_utils.bzl", "rules_rust_toolchain_test_target_json_repository") _LIBC_BUILD_FILE_CONTENT = """\ @@ -38,6 +39,7 @@ def rules_rust_test_deps(is_bzlmod = False): direct_deps = load_arbitrary_tool_test() direct_deps.extend(generated_inputs_in_external_repo()) + direct_deps.extend(rust_analyzer_test_crate_repositories()) maybe( http_archive, diff --git a/test/3rdparty/BUILD.bazel b/test/rust_analyzer/3rdparty/BUILD.bazel similarity index 63% rename from test/3rdparty/BUILD.bazel rename to test/rust_analyzer/3rdparty/BUILD.bazel index 82fa7ddbd3..cb8e307821 100644 --- a/test/3rdparty/BUILD.bazel +++ b/test/rust_analyzer/3rdparty/BUILD.bazel @@ -1,4 +1,4 @@ -load("//crate_universe:defs.bzl", "crate", "crates_vendor") +load("@rules_rust//crate_universe:defs.bzl", "crate", "crates_vendor") package(default_visibility = ["//visibility:public"]) @@ -14,10 +14,10 @@ crates_vendor( version = "1", ), }, - # Short for 'test 3rdparty'. Keep this short to reduce the risk to - # bump into absolute path length issues on Windows. See: + # Short for 'rust_test_rust_analyzer'. Keep this short to reduce + # the risk to bump into absolute path length issues on Windows. See: # https://github.com/bazelbuild/rules_rust/issues/1120 - repository_name = "t3p", + repository_name = "rtra", tags = ["manual"], vendor_path = "crates", ) diff --git a/test/3rdparty/crates/BUILD.bazel b/test/rust_analyzer/3rdparty/crates/BUILD.bazel similarity index 83% rename from test/3rdparty/crates/BUILD.bazel rename to test/rust_analyzer/3rdparty/crates/BUILD.bazel index 9937e705f1..a7f6ad0a27 100644 --- a/test/3rdparty/crates/BUILD.bazel +++ b/test/rust_analyzer/3rdparty/crates/BUILD.bazel @@ -3,7 +3,7 @@ # DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To # regenerate this file, run the following: # -# bazel run @@//test/3rdparty:crates_vendor +# bazel run @@//test/rust_analyzer/3rdparty:crates_vendor ############################################################################### package(default_visibility = ["//visibility:public"]) @@ -33,12 +33,12 @@ filegroup( # Workspace Member Dependencies alias( name = "serde", - actual = "@t3p__serde-1.0.215//:serde", + actual = "@rtra__serde-1.0.216//:serde", tags = ["manual"], ) alias( name = "serde_json", - actual = "@t3p__serde_json-1.0.133//:serde_json", + actual = "@rtra__serde_json-1.0.133//:serde_json", tags = ["manual"], ) diff --git a/test/3rdparty/crates/BUILD.itoa-1.0.14.bazel b/test/rust_analyzer/3rdparty/crates/BUILD.itoa-1.0.14.bazel similarity index 98% rename from test/3rdparty/crates/BUILD.itoa-1.0.14.bazel rename to test/rust_analyzer/3rdparty/crates/BUILD.itoa-1.0.14.bazel index bb69d78339..da6796a6f1 100644 --- a/test/3rdparty/crates/BUILD.itoa-1.0.14.bazel +++ b/test/rust_analyzer/3rdparty/crates/BUILD.itoa-1.0.14.bazel @@ -3,7 +3,7 @@ # DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To # regenerate this file, run the following: # -# bazel run @@//test/3rdparty:crates_vendor +# bazel run @@//test/rust_analyzer/3rdparty:crates_vendor ############################################################################### load("@rules_rust//rust:defs.bzl", "rust_library") diff --git a/test/3rdparty/crates/BUILD.memchr-2.7.4.bazel b/test/rust_analyzer/3rdparty/crates/BUILD.memchr-2.7.4.bazel similarity index 98% rename from test/3rdparty/crates/BUILD.memchr-2.7.4.bazel rename to test/rust_analyzer/3rdparty/crates/BUILD.memchr-2.7.4.bazel index 749f0260e5..3fc53eed20 100644 --- a/test/3rdparty/crates/BUILD.memchr-2.7.4.bazel +++ b/test/rust_analyzer/3rdparty/crates/BUILD.memchr-2.7.4.bazel @@ -3,7 +3,7 @@ # DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To # regenerate this file, run the following: # -# bazel run @@//test/3rdparty:crates_vendor +# bazel run @@//test/rust_analyzer/3rdparty:crates_vendor ############################################################################### load("@rules_rust//rust:defs.bzl", "rust_library") diff --git a/test/3rdparty/crates/BUILD.proc-macro2-1.0.92.bazel b/test/rust_analyzer/3rdparty/crates/BUILD.proc-macro2-1.0.92.bazel similarity index 96% rename from test/3rdparty/crates/BUILD.proc-macro2-1.0.92.bazel rename to test/rust_analyzer/3rdparty/crates/BUILD.proc-macro2-1.0.92.bazel index baf0723286..24f51b4982 100644 --- a/test/3rdparty/crates/BUILD.proc-macro2-1.0.92.bazel +++ b/test/rust_analyzer/3rdparty/crates/BUILD.proc-macro2-1.0.92.bazel @@ -3,7 +3,7 @@ # DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To # regenerate this file, run the following: # -# bazel run @@//test/3rdparty:crates_vendor +# bazel run @@//test/rust_analyzer/3rdparty:crates_vendor ############################################################################### load("@rules_rust//cargo:defs.bzl", "cargo_build_script") @@ -83,8 +83,8 @@ rust_library( }), version = "1.0.92", deps = [ - "@t3p__proc-macro2-1.0.92//:build_script_build", - "@t3p__unicode-ident-1.0.14//:unicode_ident", + "@rtra__proc-macro2-1.0.92//:build_script_build", + "@rtra__unicode-ident-1.0.14//:unicode_ident", ], ) diff --git a/test/3rdparty/crates/BUILD.quote-1.0.37.bazel b/test/rust_analyzer/3rdparty/crates/BUILD.quote-1.0.37.bazel similarity index 96% rename from test/3rdparty/crates/BUILD.quote-1.0.37.bazel rename to test/rust_analyzer/3rdparty/crates/BUILD.quote-1.0.37.bazel index 34e045aaa9..d8c3db7b4a 100644 --- a/test/3rdparty/crates/BUILD.quote-1.0.37.bazel +++ b/test/rust_analyzer/3rdparty/crates/BUILD.quote-1.0.37.bazel @@ -3,7 +3,7 @@ # DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To # regenerate this file, run the following: # -# bazel run @@//test/3rdparty:crates_vendor +# bazel run @@//test/rust_analyzer/3rdparty:crates_vendor ############################################################################### load("@rules_rust//rust:defs.bzl", "rust_library") @@ -82,6 +82,6 @@ rust_library( }), version = "1.0.37", deps = [ - "@t3p__proc-macro2-1.0.92//:proc_macro2", + "@rtra__proc-macro2-1.0.92//:proc_macro2", ], ) diff --git a/test/3rdparty/crates/BUILD.ryu-1.0.18.bazel b/test/rust_analyzer/3rdparty/crates/BUILD.ryu-1.0.18.bazel similarity index 98% rename from test/3rdparty/crates/BUILD.ryu-1.0.18.bazel rename to test/rust_analyzer/3rdparty/crates/BUILD.ryu-1.0.18.bazel index 35cf522e65..902782183f 100644 --- a/test/3rdparty/crates/BUILD.ryu-1.0.18.bazel +++ b/test/rust_analyzer/3rdparty/crates/BUILD.ryu-1.0.18.bazel @@ -3,7 +3,7 @@ # DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To # regenerate this file, run the following: # -# bazel run @@//test/3rdparty:crates_vendor +# bazel run @@//test/rust_analyzer/3rdparty:crates_vendor ############################################################################### load("@rules_rust//rust:defs.bzl", "rust_library") diff --git a/test/3rdparty/crates/BUILD.serde-1.0.215.bazel b/test/rust_analyzer/3rdparty/crates/BUILD.serde-1.0.216.bazel similarity index 95% rename from test/3rdparty/crates/BUILD.serde-1.0.215.bazel rename to test/rust_analyzer/3rdparty/crates/BUILD.serde-1.0.216.bazel index 2acc229feb..051ff35b1d 100644 --- a/test/3rdparty/crates/BUILD.serde-1.0.215.bazel +++ b/test/rust_analyzer/3rdparty/crates/BUILD.serde-1.0.216.bazel @@ -3,7 +3,7 @@ # DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To # regenerate this file, run the following: # -# bazel run @@//test/3rdparty:crates_vendor +# bazel run @@//test/rust_analyzer/3rdparty:crates_vendor ############################################################################### load("@rules_rust//cargo:defs.bzl", "cargo_build_script") @@ -38,7 +38,7 @@ rust_library( crate_root = "src/lib.rs", edition = "2018", proc_macro_deps = [ - "@t3p__serde_derive-1.0.215//:serde_derive", + "@rtra__serde_derive-1.0.216//:serde_derive", ], rustc_flags = [ "--cap-lints=allow", @@ -87,9 +87,9 @@ rust_library( "@rules_rust//rust/platform:x86_64-unknown-none": [], "//conditions:default": ["@platforms//:incompatible"], }), - version = "1.0.215", + version = "1.0.216", deps = [ - "@t3p__serde-1.0.215//:build_script_build", + "@rtra__serde-1.0.216//:build_script_build", ], ) @@ -144,7 +144,7 @@ cargo_build_script( "noclippy", "norustfmt", ], - version = "1.0.215", + version = "1.0.216", visibility = ["//visibility:private"], ) diff --git a/test/3rdparty/crates/BUILD.serde_derive-1.0.215.bazel b/test/rust_analyzer/3rdparty/crates/BUILD.serde_derive-1.0.216.bazel similarity index 94% rename from test/3rdparty/crates/BUILD.serde_derive-1.0.215.bazel rename to test/rust_analyzer/3rdparty/crates/BUILD.serde_derive-1.0.216.bazel index 49a1626b01..9f142d57bf 100644 --- a/test/3rdparty/crates/BUILD.serde_derive-1.0.215.bazel +++ b/test/rust_analyzer/3rdparty/crates/BUILD.serde_derive-1.0.216.bazel @@ -3,7 +3,7 @@ # DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To # regenerate this file, run the following: # -# bazel run @@//test/3rdparty:crates_vendor +# bazel run @@//test/rust_analyzer/3rdparty:crates_vendor ############################################################################### load("@rules_rust//rust:defs.bzl", "rust_proc_macro") @@ -80,10 +80,10 @@ rust_proc_macro( "@rules_rust//rust/platform:x86_64-unknown-none": [], "//conditions:default": ["@platforms//:incompatible"], }), - version = "1.0.215", + version = "1.0.216", deps = [ - "@t3p__proc-macro2-1.0.92//:proc_macro2", - "@t3p__quote-1.0.37//:quote", - "@t3p__syn-2.0.90//:syn", + "@rtra__proc-macro2-1.0.92//:proc_macro2", + "@rtra__quote-1.0.37//:quote", + "@rtra__syn-2.0.90//:syn", ], ) diff --git a/test/3rdparty/crates/BUILD.serde_json-1.0.133.bazel b/test/rust_analyzer/3rdparty/crates/BUILD.serde_json-1.0.133.bazel similarity index 94% rename from test/3rdparty/crates/BUILD.serde_json-1.0.133.bazel rename to test/rust_analyzer/3rdparty/crates/BUILD.serde_json-1.0.133.bazel index 616615b8d6..2865425f79 100644 --- a/test/3rdparty/crates/BUILD.serde_json-1.0.133.bazel +++ b/test/rust_analyzer/3rdparty/crates/BUILD.serde_json-1.0.133.bazel @@ -3,7 +3,7 @@ # DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To # regenerate this file, run the following: # -# bazel run @@//test/3rdparty:crates_vendor +# bazel run @@//test/rust_analyzer/3rdparty:crates_vendor ############################################################################### load("@rules_rust//cargo:defs.bzl", "cargo_build_script") @@ -84,11 +84,11 @@ rust_library( }), version = "1.0.133", deps = [ - "@t3p__itoa-1.0.14//:itoa", - "@t3p__memchr-2.7.4//:memchr", - "@t3p__ryu-1.0.18//:ryu", - "@t3p__serde-1.0.215//:serde", - "@t3p__serde_json-1.0.133//:build_script_build", + "@rtra__itoa-1.0.14//:itoa", + "@rtra__memchr-2.7.4//:memchr", + "@rtra__ryu-1.0.18//:ryu", + "@rtra__serde-1.0.216//:serde", + "@rtra__serde_json-1.0.133//:build_script_build", ], ) diff --git a/test/3rdparty/crates/BUILD.syn-2.0.90.bazel b/test/rust_analyzer/3rdparty/crates/BUILD.syn-2.0.90.bazel similarity index 94% rename from test/3rdparty/crates/BUILD.syn-2.0.90.bazel rename to test/rust_analyzer/3rdparty/crates/BUILD.syn-2.0.90.bazel index 5f5b44d7a7..f108bdbae3 100644 --- a/test/3rdparty/crates/BUILD.syn-2.0.90.bazel +++ b/test/rust_analyzer/3rdparty/crates/BUILD.syn-2.0.90.bazel @@ -3,7 +3,7 @@ # DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To # regenerate this file, run the following: # -# bazel run @@//test/3rdparty:crates_vendor +# bazel run @@//test/rust_analyzer/3rdparty:crates_vendor ############################################################################### load("@rules_rust//rust:defs.bzl", "rust_library") @@ -86,8 +86,8 @@ rust_library( }), version = "2.0.90", deps = [ - "@t3p__proc-macro2-1.0.92//:proc_macro2", - "@t3p__quote-1.0.37//:quote", - "@t3p__unicode-ident-1.0.14//:unicode_ident", + "@rtra__proc-macro2-1.0.92//:proc_macro2", + "@rtra__quote-1.0.37//:quote", + "@rtra__unicode-ident-1.0.14//:unicode_ident", ], ) diff --git a/test/3rdparty/crates/BUILD.unicode-ident-1.0.14.bazel b/test/rust_analyzer/3rdparty/crates/BUILD.unicode-ident-1.0.14.bazel similarity index 98% rename from test/3rdparty/crates/BUILD.unicode-ident-1.0.14.bazel rename to test/rust_analyzer/3rdparty/crates/BUILD.unicode-ident-1.0.14.bazel index d56a953a6b..cd4ec2adce 100644 --- a/test/3rdparty/crates/BUILD.unicode-ident-1.0.14.bazel +++ b/test/rust_analyzer/3rdparty/crates/BUILD.unicode-ident-1.0.14.bazel @@ -3,7 +3,7 @@ # DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To # regenerate this file, run the following: # -# bazel run @@//test/3rdparty:crates_vendor +# bazel run @@//test/rust_analyzer/3rdparty:crates_vendor ############################################################################### load("@rules_rust//rust:defs.bzl", "rust_library") diff --git a/test/3rdparty/crates/alias_rules.bzl b/test/rust_analyzer/3rdparty/crates/alias_rules.bzl similarity index 100% rename from test/3rdparty/crates/alias_rules.bzl rename to test/rust_analyzer/3rdparty/crates/alias_rules.bzl diff --git a/test/3rdparty/crates/crates.bzl b/test/rust_analyzer/3rdparty/crates/crates.bzl similarity index 72% rename from test/3rdparty/crates/crates.bzl rename to test/rust_analyzer/3rdparty/crates/crates.bzl index 86308f2e9f..70f09d47eb 100644 --- a/test/3rdparty/crates/crates.bzl +++ b/test/rust_analyzer/3rdparty/crates/crates.bzl @@ -12,7 +12,7 @@ load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") load("@rules_rust//crate_universe/private:crates_vendor.bzl", "crates_vendor_remote_repository") # buildifier: disable=bzl-visibility -load("//test/3rdparty/crates:defs.bzl", _crate_repositories = "crate_repositories") +load("//test/rust_analyzer/3rdparty/crates:defs.bzl", _crate_repositories = "crate_repositories") def crate_repositories(): """Generates repositories for vendored crates. @@ -22,11 +22,11 @@ def crate_repositories(): """ maybe( crates_vendor_remote_repository, - name = "t3p", - build_file = Label("//test/3rdparty/crates:BUILD.bazel"), - defs_module = Label("//test/3rdparty/crates:defs.bzl"), + name = "rtra", + build_file = Label("//test/rust_analyzer/3rdparty/crates:BUILD.bazel"), + defs_module = Label("//test/rust_analyzer/3rdparty/crates:defs.bzl"), ) - direct_deps = [struct(repo = "t3p", is_dev_dep = False)] + direct_deps = [struct(repo = "rtra", is_dev_dep = False)] direct_deps.extend(_crate_repositories()) return direct_deps diff --git a/test/3rdparty/crates/defs.bzl b/test/rust_analyzer/3rdparty/crates/defs.bzl similarity index 89% rename from test/3rdparty/crates/defs.bzl rename to test/rust_analyzer/3rdparty/crates/defs.bzl index ac2eceeb0e..572691abe6 100644 --- a/test/3rdparty/crates/defs.bzl +++ b/test/rust_analyzer/3rdparty/crates/defs.bzl @@ -3,7 +3,7 @@ # DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To # regenerate this file, run the following: # -# bazel run @@//test/3rdparty:crates_vendor +# bazel run @@//test/rust_analyzer/3rdparty:crates_vendor ############################################################################### """ # `crates_repository` API @@ -295,8 +295,8 @@ def aliases( _NORMAL_DEPENDENCIES = { "": { _COMMON_CONDITION: { - "serde": Label("@t3p__serde-1.0.215//:serde"), - "serde_json": Label("@t3p__serde_json-1.0.133//:serde_json"), + "serde": Label("@rtra__serde-1.0.216//:serde"), + "serde_json": Label("@rtra__serde_json-1.0.133//:serde_json"), }, }, } @@ -405,105 +405,105 @@ def crate_repositories(): """ maybe( http_archive, - name = "t3p__itoa-1.0.14", + name = "rtra__itoa-1.0.14", sha256 = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674", type = "tar.gz", urls = ["https://static.crates.io/crates/itoa/1.0.14/download"], strip_prefix = "itoa-1.0.14", - build_file = Label("//test/3rdparty/crates:BUILD.itoa-1.0.14.bazel"), + build_file = Label("//test/rust_analyzer/3rdparty/crates:BUILD.itoa-1.0.14.bazel"), ) maybe( http_archive, - name = "t3p__memchr-2.7.4", + name = "rtra__memchr-2.7.4", sha256 = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3", type = "tar.gz", urls = ["https://static.crates.io/crates/memchr/2.7.4/download"], strip_prefix = "memchr-2.7.4", - build_file = Label("//test/3rdparty/crates:BUILD.memchr-2.7.4.bazel"), + build_file = Label("//test/rust_analyzer/3rdparty/crates:BUILD.memchr-2.7.4.bazel"), ) maybe( http_archive, - name = "t3p__proc-macro2-1.0.92", + name = "rtra__proc-macro2-1.0.92", sha256 = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0", type = "tar.gz", urls = ["https://static.crates.io/crates/proc-macro2/1.0.92/download"], strip_prefix = "proc-macro2-1.0.92", - build_file = Label("//test/3rdparty/crates:BUILD.proc-macro2-1.0.92.bazel"), + build_file = Label("//test/rust_analyzer/3rdparty/crates:BUILD.proc-macro2-1.0.92.bazel"), ) maybe( http_archive, - name = "t3p__quote-1.0.37", + name = "rtra__quote-1.0.37", sha256 = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af", type = "tar.gz", urls = ["https://static.crates.io/crates/quote/1.0.37/download"], strip_prefix = "quote-1.0.37", - build_file = Label("//test/3rdparty/crates:BUILD.quote-1.0.37.bazel"), + build_file = Label("//test/rust_analyzer/3rdparty/crates:BUILD.quote-1.0.37.bazel"), ) maybe( http_archive, - name = "t3p__ryu-1.0.18", + name = "rtra__ryu-1.0.18", sha256 = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f", type = "tar.gz", urls = ["https://static.crates.io/crates/ryu/1.0.18/download"], strip_prefix = "ryu-1.0.18", - build_file = Label("//test/3rdparty/crates:BUILD.ryu-1.0.18.bazel"), + build_file = Label("//test/rust_analyzer/3rdparty/crates:BUILD.ryu-1.0.18.bazel"), ) maybe( http_archive, - name = "t3p__serde-1.0.215", - sha256 = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f", + name = "rtra__serde-1.0.216", + sha256 = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e", type = "tar.gz", - urls = ["https://static.crates.io/crates/serde/1.0.215/download"], - strip_prefix = "serde-1.0.215", - build_file = Label("//test/3rdparty/crates:BUILD.serde-1.0.215.bazel"), + urls = ["https://static.crates.io/crates/serde/1.0.216/download"], + strip_prefix = "serde-1.0.216", + build_file = Label("//test/rust_analyzer/3rdparty/crates:BUILD.serde-1.0.216.bazel"), ) maybe( http_archive, - name = "t3p__serde_derive-1.0.215", - sha256 = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0", + name = "rtra__serde_derive-1.0.216", + sha256 = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e", type = "tar.gz", - urls = ["https://static.crates.io/crates/serde_derive/1.0.215/download"], - strip_prefix = "serde_derive-1.0.215", - build_file = Label("//test/3rdparty/crates:BUILD.serde_derive-1.0.215.bazel"), + urls = ["https://static.crates.io/crates/serde_derive/1.0.216/download"], + strip_prefix = "serde_derive-1.0.216", + build_file = Label("//test/rust_analyzer/3rdparty/crates:BUILD.serde_derive-1.0.216.bazel"), ) maybe( http_archive, - name = "t3p__serde_json-1.0.133", + name = "rtra__serde_json-1.0.133", sha256 = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377", type = "tar.gz", urls = ["https://static.crates.io/crates/serde_json/1.0.133/download"], strip_prefix = "serde_json-1.0.133", - build_file = Label("//test/3rdparty/crates:BUILD.serde_json-1.0.133.bazel"), + build_file = Label("//test/rust_analyzer/3rdparty/crates:BUILD.serde_json-1.0.133.bazel"), ) maybe( http_archive, - name = "t3p__syn-2.0.90", + name = "rtra__syn-2.0.90", sha256 = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31", type = "tar.gz", urls = ["https://static.crates.io/crates/syn/2.0.90/download"], strip_prefix = "syn-2.0.90", - build_file = Label("//test/3rdparty/crates:BUILD.syn-2.0.90.bazel"), + build_file = Label("//test/rust_analyzer/3rdparty/crates:BUILD.syn-2.0.90.bazel"), ) maybe( http_archive, - name = "t3p__unicode-ident-1.0.14", + name = "rtra__unicode-ident-1.0.14", sha256 = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83", type = "tar.gz", urls = ["https://static.crates.io/crates/unicode-ident/1.0.14/download"], strip_prefix = "unicode-ident-1.0.14", - build_file = Label("//test/3rdparty/crates:BUILD.unicode-ident-1.0.14.bazel"), + build_file = Label("//test/rust_analyzer/3rdparty/crates:BUILD.unicode-ident-1.0.14.bazel"), ) return [ - struct(repo = "t3p__serde-1.0.215", is_dev_dep = False), - struct(repo = "t3p__serde_json-1.0.133", is_dev_dep = False), + struct(repo = "rtra__serde-1.0.216", is_dev_dep = False), + struct(repo = "rtra__serde_json-1.0.133", is_dev_dep = False), ] diff --git a/test/rust_analyzer/3rdparty/extensions.bzl b/test/rust_analyzer/3rdparty/extensions.bzl new file mode 100644 index 0000000000..e0d949ea86 --- /dev/null +++ b/test/rust_analyzer/3rdparty/extensions.bzl @@ -0,0 +1,21 @@ +"""Bzlmod test extensions""" + +load("//test/rust_analyzer/3rdparty/crates:crates.bzl", "crate_repositories") + +def _rust_analyzer_test_impl(module_ctx): + deps = [] + + deps.extend(crate_repositories()) + + # is_dev_dep is ignored here. It's not relevant for internal_deps, as dev + # dependencies are only relevant for module extensions that can be used + # by other MODULES. + return module_ctx.extension_metadata( + root_module_direct_deps = [], + root_module_direct_dev_deps = [repo.repo for repo in deps], + ) + +rust_analyzer_test = module_extension( + doc = "An extension for rust_analyzer tests of rules_rust.", + implementation = _rust_analyzer_test_impl, +) diff --git a/test/rust_analyzer/aspect_traversal_test/BUILD.bazel b/test/rust_analyzer/aspect_traversal_test/BUILD.bazel index faabf829ee..737621201c 100644 --- a/test/rust_analyzer/aspect_traversal_test/BUILD.bazel +++ b/test/rust_analyzer/aspect_traversal_test/BUILD.bazel @@ -104,7 +104,7 @@ rust_test( # that target to execute this test. tags = ["manual"], deps = [ - "@rules_rust//test/3rdparty/crates:serde", - "@rules_rust//test/3rdparty/crates:serde_json", + "//test/rust_analyzer/3rdparty/crates:serde", + "//test/rust_analyzer/3rdparty/crates:serde_json", ], ) diff --git a/test/rust_analyzer/generated_srcs_test/BUILD.bazel b/test/rust_analyzer/generated_srcs_test/BUILD.bazel index 884169ab31..6df7f0660e 100644 --- a/test/rust_analyzer/generated_srcs_test/BUILD.bazel +++ b/test/rust_analyzer/generated_srcs_test/BUILD.bazel @@ -35,7 +35,7 @@ rust_test( # that target to execute this test. tags = ["manual"], deps = [ - "@rules_rust//test/3rdparty/crates:serde", - "@rules_rust//test/3rdparty/crates:serde_json", + "//test/rust_analyzer/3rdparty/crates:serde", + "//test/rust_analyzer/3rdparty/crates:serde_json", ], ) diff --git a/test/rust_analyzer/merging_crates_test/BUILD.bazel b/test/rust_analyzer/merging_crates_test/BUILD.bazel index 1e2a8caab1..dc2bb3b0fa 100644 --- a/test/rust_analyzer/merging_crates_test/BUILD.bazel +++ b/test/rust_analyzer/merging_crates_test/BUILD.bazel @@ -37,7 +37,7 @@ rust_test( # that target to execute this test. tags = ["manual"], deps = [ - "@rules_rust//test/3rdparty/crates:serde", - "@rules_rust//test/3rdparty/crates:serde_json", + "//test/rust_analyzer/3rdparty/crates:serde", + "//test/rust_analyzer/3rdparty/crates:serde_json", ], ) diff --git a/test/rust_analyzer/rust_analyzer_test_runner.sh b/test/rust_analyzer/rust_analyzer_test_runner.sh index e602a6ff6d..90e1cfe064 100755 --- a/test/rust_analyzer/rust_analyzer_test_runner.sh +++ b/test/rust_analyzer/rust_analyzer_test_runner.sh @@ -17,24 +17,39 @@ if [[ -z "${PACKAGE_NAME:-}" ]]; then fi function generate_workspace() { + local workspace_root="$1" + local package_dir="$2" local temp_dir="$(mktemp -d -t rules_rust_test_rust_analyzer-XXXXXXXXXX)" local new_workspace="${temp_dir}/rules_rust_test_rust_analyzer" mkdir -p "${new_workspace}" - cat <"${new_workspace}/WORKSPACE.bazel" -workspace(name = "rules_rust_test_rust_analyzer") -local_repository( - name = "rules_rust", + cat <"${new_workspace}/MODULE.bazel" +module( + name = "rules_rust_test_rust_analyzer", + version = "0.0.0", +) +bazel_dep(name = "rules_rust", version = "0.0.0") +local_path_override( + module_name = "rules_rust", path = "${BUILD_WORKSPACE_DIRECTORY}", ) -load("@rules_rust//rust:repositories.bzl", "rust_repositories") -rust_repositories() -load("@rules_rust//tools/rust_analyzer:deps.bzl", "rust_analyzer_dependencies") -rust_analyzer_dependencies() -load("@rules_rust//test/3rdparty/crates:crates.bzl", test_crate_repositories = "crate_repositories") +bazel_dep( + name = "bazel_skylib", + version = "1.7.1", +) + +rust = use_extension("@rules_rust//rust:extensions.bzl", "rust") +use_repo(rust, "rust_toolchains") +register_toolchains("@rust_toolchains//:all") -test_crate_repositories() +rust_analyzer_test = use_extension("//test/rust_analyzer/3rdparty:extensions.bzl", "rust_analyzer_test", dev_dependency = True) +use_repo( + rust_analyzer_test, + "rtra", + "rtra__serde-1.0.216", + "rtra__serde_json-1.0.133", +) EOF cat <"${new_workspace}/.bazelrc" @@ -49,6 +64,13 @@ build:strict --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect build:strict --output_groups=+clippy_checks EOF + if [[ -f "${workspace_root}/.bazelversion" ]]; then + cp "${workspace_root}/.bazelversion" "${new_workspace}/.bazelversion" + fi + + mkdir -p "${new_workspace}/${package_dir}" + cp -r "${workspace_root}/${package_dir}/3rdparty" "${new_workspace}/${package_dir}/" + echo "${new_workspace}" } @@ -94,7 +116,7 @@ function cleanup() { } function run_test_suite() { - local temp_workspace="$(generate_workspace)" + local temp_workspace="$(generate_workspace "${BUILD_WORKSPACE_DIRECTORY}" "${PACKAGE_NAME}")" echo "Generated workspace: ${temp_workspace}" for test_dir in "${BUILD_WORKSPACE_DIRECTORY}/${PACKAGE_NAME}"/*; do @@ -103,6 +125,11 @@ function run_test_suite() { continue fi + # Skip the 3rdparty directory + if [[ "${test_dir}" == *"3rdparty"* ]]; then + continue + fi + # Some tests have arguments that need to be passed to the rust-project.json generator. if [[ "${test_dir}" = "aspect_traversal_test" ]]; then test_arg="//mylib_test" diff --git a/test/rust_analyzer/static_and_shared_lib_test/BUILD.bazel b/test/rust_analyzer/static_and_shared_lib_test/BUILD.bazel index da4a7ebd32..78286c722b 100644 --- a/test/rust_analyzer/static_and_shared_lib_test/BUILD.bazel +++ b/test/rust_analyzer/static_and_shared_lib_test/BUILD.bazel @@ -36,7 +36,7 @@ rust_test( # that target to execute this test. tags = ["manual"], deps = [ - "@rules_rust//test/3rdparty/crates:serde", - "@rules_rust//test/3rdparty/crates:serde_json", + "//test/rust_analyzer/3rdparty/crates:serde", + "//test/rust_analyzer/3rdparty/crates:serde_json", ], ) diff --git a/test/test_extensions.bzl b/test/test_extensions.bzl index 078ce16479..62ece95f8d 100644 --- a/test/test_extensions.bzl +++ b/test/test_extensions.bzl @@ -2,13 +2,11 @@ load("@bazel_ci_rules//:rbe_repo.bzl", "rbe_preconfig") load("//test:deps.bzl", "rules_rust_test_deps") -load("//test/3rdparty/crates:crates.bzl", test_crate_repositories = "crate_repositories") def _rust_test_impl(module_ctx): deps = [] deps.extend(rules_rust_test_deps()) - deps.extend(test_crate_repositories()) rbe_preconfig( name = "buildkite_config",