diff options
author | 2021-10-06 10:45:34 -0700 | |
---|---|---|
committer | 2021-10-06 19:39:06 +0000 | |
commit | af96f99d83c8ee0dfc1b880bd7a0a6d443b94627 (patch) | |
tree | 77c86ced45676bb2c4a5412ab7be9d9749c8a34e /rust/project_json_test.go | |
parent | f79f4c319988051f21dfa815f0d8eef3f4aca70b (diff) |
Include proc macro crates in rust-project.json
These crates were skipped before, leaving dependencies missing in
rust-project.json. Include them and mark them as `"is_proc_macro": true`
so that rust-analyzer can process them.
Fixes: 202290038
Test: SOONG_GEN_RUST_PROJECT=1 m nothing
Change-Id: Ia80e6f5e2f56a76608ba057075600e6b4424281b
Diffstat (limited to 'rust/project_json_test.go')
-rw-r--r-- | rust/project_json_test.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/rust/project_json_test.go b/rust/project_json_test.go index f7b668122..255b2e537 100644 --- a/rust/project_json_test.go +++ b/rust/project_json_test.go @@ -117,6 +117,58 @@ func TestProjectJsonDep(t *testing.T) { validateJsonCrates(t, jsonContent) } +func TestProjectJsonProcMacroDep(t *testing.T) { + bp := ` + rust_proc_macro { + name: "libproc_macro", + srcs: ["a/src/lib.rs"], + crate_name: "proc_macro" + } + rust_library { + name: "librust", + srcs: ["b/src/lib.rs"], + crate_name: "rust", + proc_macros: ["libproc_macro"], + } + ` + jsonContent := testProjectJson(t, bp) + crates := validateJsonCrates(t, jsonContent) + libproc_macro_count := 0 + librust_count := 0 + for _, c := range crates { + crate := validateCrate(t, c) + procMacro, ok := crate["is_proc_macro"].(bool) + if !ok { + t.Fatalf("Unexpected type for is_proc_macro: %v", crate["is_proc_macro"]) + } + + name, ok := crate["display_name"].(string) + if !ok { + t.Fatalf("Unexpected type for display_name: %v", crate["display_name"]) + } + + switch name { + case "libproc_macro": + libproc_macro_count += 1 + if !procMacro { + t.Fatalf("'libproc_macro' is marked with is_proc_macro=false") + } + case "librust": + librust_count += 1 + if procMacro { + t.Fatalf("'librust' is not a proc macro crate, but is marked with is_proc_macro=true") + } + default: + break + } + } + + if libproc_macro_count != 1 || librust_count != 1 { + t.Fatalf("Unexpected crate counts: libproc_macro_count: %v, librust_count: %v", + libproc_macro_count, librust_count) + } +} + func TestProjectJsonFeature(t *testing.T) { bp := ` rust_library { |