in focus/internals/src/lib/target_resolver/bazel_de.rs [128:381]
fn test_deserialize_bazel_query() -> anyhow::Result<()> {
let payload = r#"
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<query version="2">
<rule class="third_party_jvm_import" location="/home/project/BUILD:108:12" name="//:scala-collection-compat">
<string name="name" value="scala-collection-compat"/>
<list name="visibility">
<label value="//visibility:public"/>
</list>
<string name="generator_name" value="scala-collection-compat"/>
<string name="generator_function" value="jar_library"/>
<string name="generator_location" value="/home/project/BUILD:108:12"/>
<list name="deps">
<label value="@maven//:_scala-collection-compat"/>
</list>
<rule-input name="@maven//:_scala-collection-compat"/>
</rule>
<rule class="alias" location="/home/project/3rdparty/jvm/com/fasterxml/jackson/BUILD:16:7" name="//3rdparty/jvm/com/fasterxml/jackson:jackson-module-scala">
<string name="name" value="jackson-module-scala"/>
<list name="tags">
<string value="bazel-compatible"/>
</list>
<list name="visibility">
<label value="//visibility:public"/>
</list>
<dict name="dummy-testing-dict" />
<string name="generator_name" value="jackson-module-scala"/>
<string name="generator_function" value="target"/>
<string name="generator_location" value="3rdparty/jvm/com/fasterxml/jackson/BUILD:16:7"/>
<label name="actual" value="//3rdparty/jvm/com/fasterxml/jackson/module:jackson-module-scala"/>
<label value="//3rdparty/jvm/com/fasterxml/jackson/module:jackson-module-scala"/>
<rule-input name="//3rdparty/jvm/com/fasterxml/jackson/module:jackson-module-scala"/>
<output name="dummy-output" value="//foo/bar:baz"/>
<int name="dummy-int" value="10"/>
<tristate name="dummy-tristate" value="-1"/>
</rule>
<source-file location="/private/var/tmp/user/edb2428c3d1a64c0af66dd62c2299134/external/zlib/trees.c:1:1" name="@zlib//:trees.c">
<visibility-label name="//visibility:public"/>
</source-file>
<generated-file generating-rule="@zlib//:copy_public_headers" location="/private/var/tmp/user/edb2428c3d1a64c0af66dd62c2299134/external/zlib/BUILD.bazel:24:8" name="@zlib//:zlib/include/inftrees.h"/>
<package-group location="/private/var/tmp/user/07c5cb75abc6d06390f255c356743280/external/bazel_tools/tools/build_defs/cc/whitelists/starlark_hdrs_check/BUILD:3:14" name="@bazel_tools//tools/build_defs/cc/whitelists/starlark_hdrs_check:loose_header_check_allowed_in_toolchain">
<list name="includes"/>
<list name="packages"/>
</package-group>
</query>
"#;
let result: Query = serde_xml_rs::from_str(payload)
.map_err(|e| anyhow::anyhow!("deserialization error: {:?}", e))?;
insta::assert_debug_snapshot!(result, @r###"
Query {
rules: [
Rule(
Rule {
name: "//:scala-collection-compat",
location: Some(
"/home/project/BUILD:108:12",
),
elements: [
String {
name: Some(
"name",
),
value: Some(
"scala-collection-compat",
),
},
List(
List {
name: "visibility",
values: [
Label(
Label {
name: None,
value: Some(
"//visibility:public",
),
},
),
],
},
),
String {
name: Some(
"generator_name",
),
value: Some(
"scala-collection-compat",
),
},
String {
name: Some(
"generator_function",
),
value: Some(
"jar_library",
),
},
String {
name: Some(
"generator_location",
),
value: Some(
"/home/project/BUILD:108:12",
),
},
List(
List {
name: "deps",
values: [
Label(
Label {
name: None,
value: Some(
"@maven//:_scala-collection-compat",
),
},
),
],
},
),
RuleInput {
name: "@maven//:_scala-collection-compat",
},
],
},
),
Rule(
Rule {
name: "//3rdparty/jvm/com/fasterxml/jackson:jackson-module-scala",
location: Some(
"/home/project/3rdparty/jvm/com/fasterxml/jackson/BUILD:16:7",
),
elements: [
String {
name: Some(
"name",
),
value: Some(
"jackson-module-scala",
),
},
List(
List {
name: "tags",
values: [
String {
name: None,
value: Some(
"bazel-compatible",
),
},
],
},
),
List(
List {
name: "visibility",
values: [
Label(
Label {
name: None,
value: Some(
"//visibility:public",
),
},
),
],
},
),
Dict {
name: "dummy-testing-dict",
},
String {
name: Some(
"generator_name",
),
value: Some(
"jackson-module-scala",
),
},
String {
name: Some(
"generator_function",
),
value: Some(
"target",
),
},
String {
name: Some(
"generator_location",
),
value: Some(
"3rdparty/jvm/com/fasterxml/jackson/BUILD:16:7",
),
},
Label(
Label {
name: Some(
"actual",
),
value: Some(
"//3rdparty/jvm/com/fasterxml/jackson/module:jackson-module-scala",
),
},
),
Label(
Label {
name: None,
value: Some(
"//3rdparty/jvm/com/fasterxml/jackson/module:jackson-module-scala",
),
},
),
RuleInput {
name: "//3rdparty/jvm/com/fasterxml/jackson/module:jackson-module-scala",
},
Output {
name: Some(
"dummy-output",
),
},
Int {
name: Some(
"dummy-int",
),
value: Some(
10,
),
},
Tristate {
name: "dummy-tristate",
},
],
},
),
SourceFile {
name: "@zlib//:trees.c",
body: (),
},
GeneratedFile {
name: "@zlib//:zlib/include/inftrees.h",
body: (),
},
PackageGroup {
body: (),
},
],
}
"###);
Ok(())
}