Add golden test for cc_bindings_from_rs.

PiperOrigin-RevId: 665486843
Change-Id: I81a60516061e83f890ccfedfe3358a24f0a043c0
diff --git a/cc_bindings_from_rs/bazel_support/cc_bindings_from_rust_cli_flag_aspect_hint.bzl b/cc_bindings_from_rs/bazel_support/cc_bindings_from_rust_cli_flag_aspect_hint.bzl
new file mode 100644
index 0000000..e4e88a1
--- /dev/null
+++ b/cc_bindings_from_rs/bazel_support/cc_bindings_from_rust_cli_flag_aspect_hint.bzl
@@ -0,0 +1,55 @@
+# Part of the Crubit project, under the Apache License v2.0 with LLVM
+# Exceptions. See /LICENSE for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+"""The aspect hint, to be attached to a `rust_library`, specifies the command line flag to be passed
+to `cc_bindings_from_rust` when its Rust bindings are generated."""
+
+visibility([
+    "//cc_bindings_from_rs/bazel_support/...",
+    "//cc_bindings_from_rs/test/golden/...",
+])
+
+_CcBindingsFromRustCliFlagInfo = provider(
+    doc = "The provider that specifies the command line flags and values for `cc_bindings_from_rust`.",
+    fields = {
+        "flags": "The command line flags and values for `cc_bindings_from_rust`.",
+    },
+)
+
+def _cc_bindings_from_rust_cli_flag_impl(ctx):
+    return [_CcBindingsFromRustCliFlagInfo(
+        flags = ctx.attr.flags,
+    )]
+
+cc_bindings_from_rust_cli_flag = rule(
+    attrs = {
+        "flags": attr.string(
+            doc = "The command line flags and values for `cc_bindings_from_rust`",
+            mandatory = True,
+        ),
+    },
+    implementation = _cc_bindings_from_rust_cli_flag_impl,
+    doc = """
+Defines an aspect hint that is used to pass command line flags to the `cc_bindings_from_rust` tool,
+which affects the tool behavior when generating the C++ binding for the Rust target. This rule
+should only be used by Crubit developers.
+""",
+)
+
+def collect_cc_bindings_from_rust_cli_flags(_target, aspect_ctx):
+    """Returns the command line flags and values for `cc_bindings_from_rust`.
+
+    Args:
+        _target: The target, as seen in aspect_hint.
+        aspect_ctx: The ctx from an aspect_hint.
+
+    Returns:
+        A list of command line flags and values for `cc_bindings_from_rust`. The list is empty if no
+        command line flag is specified.
+    """
+    flags = []
+    for hint in aspect_ctx.rule.attr.aspect_hints:
+        if _CcBindingsFromRustCliFlagInfo in hint:
+            flags.append(hint[_CcBindingsFromRustCliFlagInfo].flags)
+    return flags
diff --git a/cc_bindings_from_rs/bazel_support/cc_bindings_from_rust_rule.bzl b/cc_bindings_from_rs/bazel_support/cc_bindings_from_rust_rule.bzl
index dc545ba..80a82e4 100644
--- a/cc_bindings_from_rs/bazel_support/cc_bindings_from_rust_rule.bzl
+++ b/cc_bindings_from_rs/bazel_support/cc_bindings_from_rust_rule.bzl
@@ -33,8 +33,13 @@
 )
 load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
 load(
+    "//cc_bindings_from_rs/bazel_support:cc_bindings_from_rust_cli_flag_aspect_hint.bzl",
+    "collect_cc_bindings_from_rust_cli_flags",
+)
+load(
     "//cc_bindings_from_rs/bazel_support:providers.bzl",
     "CcBindingsFromRustInfo",
+    "GeneratedBindingsInfo",
 )
 load(
     "//rs_bindings_from_cc/bazel_support:compile_rust.bzl",
@@ -72,11 +77,12 @@
         if CcBindingsFromRustInfo in dep
     ]
 
-def _generate_bindings(ctx, basename, inputs, args, rustc_env):
+def _generate_bindings(ctx, target, basename, inputs, args, rustc_env):
     """Invokes the `cc_bindings_from_rs` tool to generate C++ bindings for a Rust crate.
 
     Args:
       ctx: The rule context.
+      target: The target crate.
       basename: The basename for the generated files
       inputs: `cc_bindings_from_rs` inputs specific to the target `crate`
       args: `rustc` and `process_wrapper` arguments from construct_arguments.
@@ -114,6 +120,8 @@
         )
         outputs.append(error_report_output)
 
+    for flag in collect_cc_bindings_from_rust_cli_flags(target, ctx):
+        crubit_args.add(flag)
     ctx.actions.run(
         outputs = outputs,
         inputs = depset(
@@ -292,6 +300,7 @@
 
     (h_out_file, rs_out_file) = _generate_bindings(
         ctx,
+        target,
         basename,
         compile_inputs,
         args,
@@ -314,6 +323,10 @@
             crate_key = crate_info.name,
             headers = [h_out_file],
         ),
+        GeneratedBindingsInfo(
+            h_file = h_out_file,
+            rust_file = rs_out_file,
+        ),
         OutputGroupInfo(out = depset([h_out_file, rs_out_file])),
     ]
 
diff --git a/cc_bindings_from_rs/bazel_support/providers.bzl b/cc_bindings_from_rs/bazel_support/providers.bzl
index 836e2e4..c555f46 100644
--- a/cc_bindings_from_rs/bazel_support/providers.bzl
+++ b/cc_bindings_from_rs/bazel_support/providers.bzl
@@ -15,3 +15,11 @@
         "headers": "A list of C++ headers which correspond to this crate.",
     },
 )
+
+GeneratedBindingsInfo = provider(
+    doc = "A provider that contains the generated C++ and Rust files.",
+    fields = {
+        "h_file": "The generated C++ header file.",
+        "rust_file": "The generated Rust source file.",
+    },
+)
diff --git a/cc_bindings_from_rs/bindings.rs b/cc_bindings_from_rs/bindings.rs
index 12b52ae..52802f7 100644
--- a/cc_bindings_from_rs/bindings.rs
+++ b/cc_bindings_from_rs/bindings.rs
@@ -69,6 +69,9 @@
         #[input]
         fn errors(&self) -> Rc<dyn ErrorReporting>;
 
+        #[input]
+        fn no_thunk_name_mangling(&self) -> bool;
+
         // TODO(b/262878759): Provide a set of enabled/disabled Crubit features.
         #[input]
         fn _features(&self) -> ();
@@ -1478,13 +1481,18 @@
         || (tcx.get_attr(def_id, rustc_span::symbol::sym::no_mangle).is_none()
             && tcx.get_attr(def_id, rustc_span::symbol::sym::export_name).is_none());
     let thunk_name = {
-        let symbol_name = {
+        let symbol_name = if db.no_thunk_name_mangling() {
+            FullyQualifiedName::new(tcx, def_id)
+                .name
+                .expect("Functions are assumed to always have a name")
+                .to_string()
+        } else {
             // Call to `mono` is ok - `generics_of` have been checked above.
             let instance = ty::Instance::mono(tcx, def_id);
-            tcx.symbol_name(instance).name
+            tcx.symbol_name(instance).name.to_string()
         };
         if needs_thunk {
-            format!("__crubit_thunk_{}", &escape_non_identifier_chars(symbol_name))
+            format!("__crubit_thunk_{}", &escape_non_identifier_chars(&symbol_name))
         } else {
             symbol_name.to_string()
         }
@@ -2311,9 +2319,13 @@
         };
 
         let thunk_name = {
-            let instance = ty::Instance::new(method.def_id, substs);
-            let symbol = tcx.symbol_name(instance);
-            format!("__crubit_thunk_{}", &escape_non_identifier_chars(symbol.name))
+            if db.no_thunk_name_mangling() {
+                format!("__crubit_thunk_{}", &escape_non_identifier_chars(method.name.as_str()))
+            } else {
+                let instance = ty::Instance::new(method.def_id, substs);
+                let symbol = tcx.symbol_name(instance);
+                format!("__crubit_thunk_{}", &escape_non_identifier_chars(symbol.name))
+            }
         };
         method_name_to_cc_thunk_name.insert(method.name, format_cc_ident(&thunk_name)?);
 
@@ -9014,6 +9026,7 @@
             /* crubit_support_path_format= */ "<crubit/support/for/tests/{header}>".into(),
             /* crate_name_to_include_paths= */ Default::default(),
             /* errors = */ Rc::new(IgnoreErrors),
+            /* no_thunk_name_mangling= */ false,
             /* _features= */ (),
         )
     }
diff --git a/cc_bindings_from_rs/cc_bindings_from_rs.rs b/cc_bindings_from_rs/cc_bindings_from_rs.rs
index 4fe270b..e396fdf 100644
--- a/cc_bindings_from_rs/cc_bindings_from_rs.rs
+++ b/cc_bindings_from_rs/cc_bindings_from_rs.rs
@@ -47,6 +47,7 @@
         crubit_support_path_format,
         crate_name_to_include_paths.into(),
         errors,
+        cmdline.no_thunk_name_mangling,
         /* _features= */ (),
     )
 }
diff --git a/cc_bindings_from_rs/cmdline.rs b/cc_bindings_from_rs/cmdline.rs
index 692ece6..4cbd656 100644
--- a/cc_bindings_from_rs/cmdline.rs
+++ b/cc_bindings_from_rs/cmdline.rs
@@ -65,6 +65,11 @@
     /// Path to the error reporting output file.
     #[clap(long, value_parser, value_name = "FILE")]
     pub error_report_out: Option<PathBuf>,
+
+    /// This is for golden tests only. Using this in production may cause
+    /// undefined behavior.
+    #[clap(long, value_parser, value_name = "BOOL")]
+    pub no_thunk_name_mangling: bool,
 }
 
 impl Cmdline {
@@ -236,6 +241,8 @@
           Path to a rustfmt.toml file that should replace the default formatting of the .rs files generated by the tool
       --error-report-out <FILE>
           Path to the error reporting output file
+      --no-thunk-name-mangling
+          This is for golden tests only. Using this in production may cause undefined behavior
   -h, --help
           Print help
 "#;
diff --git a/cc_bindings_from_rs/test/golden/BUILD b/cc_bindings_from_rs/test/golden/BUILD
new file mode 100644
index 0000000..1c632e9
--- /dev/null
+++ b/cc_bindings_from_rs/test/golden/BUILD
@@ -0,0 +1,59 @@
+load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
+load(
+    "@rules_rust//rust:defs.bzl",
+    "rust_library",
+)
+load(
+    "//cc_bindings_from_rs/bazel_support:cc_bindings_from_rust_cli_flag_aspect_hint.bzl",
+    "cc_bindings_from_rust_cli_flag",
+)
+load(
+    "//cc_bindings_from_rs/test/golden:golden_test.bzl",
+    "golden_test",
+)
+
+package(default_applicable_licenses = ["//:license"])
+
+# These are needed by golden_test, which can be run in other packages.
+exports_files([
+    "test.sh",
+    "LICENSE_HEADER",
+])
+
+TESTS = [name[:-3] for name in glob(
+    ["*.rs"],
+    exclude = ["*cc_api_impl.rs"],
+)]
+
+cc_bindings_from_rust_cli_flag(
+    name = "no_thunk_name_mangling",
+    flags = "--no-thunk-name-mangling",
+)
+
+[rust_library(
+    name = name + "_rust",
+    srcs = [name + ".rs"],
+    aspect_hints = [
+        "//features:experimental",
+        ":no_thunk_name_mangling",
+    ],
+) for name in TESTS]
+
+# TODO(yongheng): Add a test to compile the generated bindings.
+
+[golden_test(
+    name = name + "_test",
+    basename = name,
+    golden_h = name + "_cc_api.h",
+    golden_rs = name + "_cc_api_impl.rs",
+    rust_library = name + "_rust",
+) for name in TESTS]
+
+bzl_library(
+    name = "golden_test",
+    srcs = ["golden_test.bzl"],
+    visibility = ["//visibility:private"],
+    deps = [
+        "//cc_bindings_from_rs/bazel_support:cc_bindings_from_rust_rule",
+    ],
+)
diff --git a/cc_bindings_from_rs/test/golden/README.md b/cc_bindings_from_rs/test/golden/README.md
new file mode 100644
index 0000000..0bec914
--- /dev/null
+++ b/cc_bindings_from_rs/test/golden/README.md
@@ -0,0 +1,12 @@
+# Golden file tests
+
+## Instructions
+
+*   Add a new test by adding a `foo.rs` file, create two empty files named
+    `foo_cc_api.h` and `foo_cc_api_impl.rs`, and then executing
+    `common/golden_update.sh`. This will generate the
+    corresponding bindings files.
+*   If a test in this directory fails, look at the output. It should contain a
+    diff of the failure.
+*   If you get spurious failures in this directory: Run
+    `common/golden_update.sh`.
diff --git a/cc_bindings_from_rs/test/golden/golden_test.bzl b/cc_bindings_from_rs/test/golden/golden_test.bzl
new file mode 100644
index 0000000..404cb90
--- /dev/null
+++ b/cc_bindings_from_rs/test/golden/golden_test.bzl
@@ -0,0 +1,121 @@
+# Part of the Crubit project, under the Apache License v2.0 with LLVM
+# Exceptions. See /LICENSE for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+"""A rule that generates bindings source files for a given Rust library."""
+
+load("@rules_rust//rust/private:providers.bzl", "CrateInfo")  # buildifier: disable=bzl-visibility
+load(
+    "//cc_bindings_from_rs/bazel_support:cc_bindings_from_rust_rule.bzl",
+    "cc_bindings_from_rust_aspect",
+)
+load(
+    "//cc_bindings_from_rs/bazel_support:providers.bzl",
+    "GeneratedBindingsInfo",
+)
+load(
+    "//common:crubit_wrapper_macros_oss.bzl",
+    "crubit_flavor_transition",
+)
+
+def _generate_bindings_impl(ctx):
+    rust_library = ctx.attr.rust_library[0]
+    if not GeneratedBindingsInfo in rust_library:
+        fail("Bindings were not generated for the given rust_library.")
+    bindings = rust_library[GeneratedBindingsInfo]
+    return OutputGroupInfo(
+        h_file = [bindings.h_file],
+        rust_file = [bindings.rust_file],
+    )
+
+_generate_bindings = rule(
+    attrs = {
+        "rust_library": attr.label(
+            providers = [CrateInfo],
+            aspects = [cc_bindings_from_rust_aspect],
+            cfg = crubit_flavor_transition,
+        ),
+    },
+    implementation = _generate_bindings_impl,
+)
+
+def golden_test(
+        name,
+        rust_library,
+        tags = None,
+        basename = None,
+        golden_h = None,
+        golden_rs = None):
+    """Generates a golden test for `rust_library`.
+
+    Args:
+        name: The name of the golden test.
+        rust_library: The Rust library whose outputs should be checked.
+        tags: The test tags.
+        basename: The name to use for generated files.
+        golden_h: The generated C++ source code for the bindings.
+        golden_rs: The generated Rust source code for the bindings.
+
+    """
+    if not basename:
+        basename = name
+    if not tags:
+        tags = []
+    tags.append("crubit_golden_test")
+
+    bindings_name = basename + ".generated_bindings"
+
+    _generate_bindings(
+        name = bindings_name,
+        rust_library = rust_library,
+    )
+    args = []
+    data = ["//common:LICENSE_HEADER"]
+    owned_files = []
+    if golden_h:
+        new_h = basename + ".h_file"
+        native.filegroup(
+            name = new_h,
+            srcs = [bindings_name],
+            output_group = "h_file",
+        )
+        args += [
+            "$(location %s)" % golden_h,
+            "$(location %s)" % new_h,
+        ]
+        data += [
+            golden_h,
+            new_h,
+        ]
+        owned_files.append(golden_h)
+
+    if golden_rs:
+        new_rs = basename + ".rs_file"
+        native.filegroup(
+            name = new_rs,
+            srcs = [bindings_name],
+            output_group = "rust_file",
+        )
+        args += [
+            "$(location %s)" % golden_rs,
+            "$(location %s)" % new_rs,
+        ]
+        data += [
+            golden_rs,
+            new_rs,
+        ]
+        owned_files.append(golden_rs)
+
+    native.sh_test(
+        name = name,
+        srcs = ["//common:golden_test.sh"],
+        args = args,
+        data = data,
+        tags = tags,
+    )
+    native.filegroup(
+        name = basename + ".build_cleaner_optout",
+        srcs = owned_files,
+        tags = ["ignore_srcs"],
+        visibility = ["//visibility:private"],
+    )
diff --git a/cc_bindings_from_rs/test/golden/type_aliases.rs b/cc_bindings_from_rs/test/golden/type_aliases.rs
new file mode 100644
index 0000000..6e27c77
--- /dev/null
+++ b/cc_bindings_from_rs/test/golden/type_aliases.rs
@@ -0,0 +1,17 @@
+// Part of the Crubit project, under the Apache License v2.0 with LLVM
+// Exceptions. See /LICENSE for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+pub mod test_type_aliases {
+    pub type TypeAlias2 = TypeAlias;
+    pub type TypeAlias = i32;
+
+    pub fn func_using_alias() -> TypeAlias {
+        0
+    }
+}
+
+pub mod test_deprecated_type_alias {
+    #[deprecated = "Use `OtherTypeAlias` instead"]
+    pub type TypeAlias = i32;
+}
diff --git a/cc_bindings_from_rs/test/golden/type_aliases_cc_api.h b/cc_bindings_from_rs/test/golden/type_aliases_cc_api.h
new file mode 100644
index 0000000..6415efb
--- /dev/null
+++ b/cc_bindings_from_rs/test/golden/type_aliases_cc_api.h
@@ -0,0 +1,41 @@
+// Part of the Crubit project, under the Apache License v2.0 with LLVM
+// Exceptions. See /LICENSE for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// Automatically @generated C++ bindings for the following Rust crate:
+// type_aliases_rust
+
+#pragma once
+
+#include <cstdint>
+
+namespace type_aliases_rust {
+
+namespace test_type_aliases {
+using TypeAlias2 = std::int32_t;
+using TypeAlias = std::int32_t;
+
+// Generated from:
+// cc_bindings_from_rs/test/golden/type_aliases.rs;l=9
+std::int32_t func_using_alias();
+
+}  // namespace test_type_aliases
+
+namespace test_deprecated_type_alias {
+using TypeAlias [[deprecated("Use `OtherTypeAlias` instead")]] = std::int32_t;
+}
+
+namespace test_type_aliases {
+
+namespace __crubit_internal {
+extern "C" std::int32_t __crubit_thunk_func_uusing_ualias();
+}
+inline std::int32_t func_using_alias() {
+  return __crubit_internal::__crubit_thunk_func_uusing_ualias();
+}
+
+}  // namespace test_type_aliases
+
+namespace test_deprecated_type_alias {}
+
+}  // namespace type_aliases_rust
diff --git a/cc_bindings_from_rs/test/golden/type_aliases_cc_api_impl.rs b/cc_bindings_from_rs/test/golden/type_aliases_cc_api_impl.rs
new file mode 100644
index 0000000..dd022fb
--- /dev/null
+++ b/cc_bindings_from_rs/test/golden/type_aliases_cc_api_impl.rs
@@ -0,0 +1,13 @@
+// Part of the Crubit project, under the Apache License v2.0 with LLVM
+// Exceptions. See /LICENSE for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// Automatically @generated C++ bindings for the following Rust crate:
+// type_aliases_rust
+
+#![allow(improper_ctypes_definitions)]
+
+#[no_mangle]
+extern "C" fn __crubit_thunk_func_uusing_ualias() -> i32 {
+    ::type_aliases_rust::test_type_aliases::func_using_alias()
+}
diff --git a/common/BUILD b/common/BUILD
index e02942d..364d8c5 100644
--- a/common/BUILD
+++ b/common/BUILD
@@ -13,6 +13,11 @@
     default_visibility = ["//:__subpackages__"],
 )
 
+exports_files([
+    "LICENSE_HEADER",
+    "golden_test.sh",
+])
+
 rust_library(
     name = "arc_anyhow",
     srcs = ["arc_anyhow.rs"],
diff --git a/common/LICENSE_HEADER b/common/LICENSE_HEADER
new file mode 100644
index 0000000..455c075
--- /dev/null
+++ b/common/LICENSE_HEADER
@@ -0,0 +1,4 @@
+// Part of the Crubit project, under the Apache License v2.0 with LLVM
+// Exceptions. See /LICENSE for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
diff --git a/rs_bindings_from_cc/test/golden/test.sh b/common/golden_test.sh
similarity index 84%
rename from rs_bindings_from_cc/test/golden/test.sh
rename to common/golden_test.sh
index 11765b1..e3e0deb 100755
--- a/rs_bindings_from_cc/test/golden/test.sh
+++ b/common/golden_test.sh
@@ -4,7 +4,7 @@
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 function prepend_license() {
-  cat rs_bindings_from_cc/test/golden/LICENSE_HEADER "$1"
+  cat common/LICENSE_HEADER "$1"
 }
 
 STATUS=0
@@ -27,6 +27,6 @@
 done
 
 if [ $STATUS != 0 ]; then
-  echo >&2 "To regenerate the goldens, run rs_bindings_from_cc/test/golden/update.sh"
+  echo >&2 "To regenerate the goldens, run cc_bindings_from_rs/test/golden/update.sh"
   exit 1
-fi
+fi
\ No newline at end of file
diff --git a/rs_bindings_from_cc/test/golden/update.sh b/common/golden_update.sh
similarity index 92%
rename from rs_bindings_from_cc/test/golden/update.sh
rename to common/golden_update.sh
index ecc3ace..8d08bc8 100755
--- a/rs_bindings_from_cc/test/golden/update.sh
+++ b/common/golden_update.sh
@@ -8,7 +8,8 @@
 bazel test \
   --test_tag_filters=crubit_golden_test,-manual \
   --build_tag_filters=crubit_golden_test,-manual \
+  --config=llvm-unstable \
   --test_strategy=local \
   --test_env=WRITE_GOLDENS=1 \
   -k \
-  //...
+  //...
\ No newline at end of file
diff --git a/rs_bindings_from_cc/README.md b/rs_bindings_from_cc/README.md
index 9b799b2..f3420eb 100644
--- a/rs_bindings_from_cc/README.md
+++ b/rs_bindings_from_cc/README.md
@@ -39,7 +39,7 @@
 to the [`golden`](test/golden) directory and regenerate the golden outputs:
 
 ```sh
-rs_bindings_from_cc/test/golden/update.sh
+common/golden_update.sh
 ```
 
 ### Running Crubit on a Bazel target
diff --git a/rs_bindings_from_cc/test/golden/BUILD b/rs_bindings_from_cc/test/golden/BUILD
index f7eaa4e..0a2010e 100644
--- a/rs_bindings_from_cc/test/golden/BUILD
+++ b/rs_bindings_from_cc/test/golden/BUILD
@@ -11,12 +11,6 @@
 
 package(default_applicable_licenses = ["//:license"])
 
-# These are needed by golden_test, which can be run in other packages.
-exports_files([
-    "test.sh",
-    "LICENSE_HEADER",
-])
-
 TESTS = [name[:-2] for name in glob(
     ["*.h"],
     exclude = [
diff --git a/rs_bindings_from_cc/test/golden/README.md b/rs_bindings_from_cc/test/golden/README.md
index 230c144..3252183 100644
--- a/rs_bindings_from_cc/test/golden/README.md
+++ b/rs_bindings_from_cc/test/golden/README.md
@@ -2,8 +2,11 @@
 
 ## Instructions
 
-*   Add a new test by adding a `foo.h` file and executing `./update.sh`. This
-    will generate the corresponding bindings files `foo.cc` and `foo.rs`.
+*   Add a new test by adding a `foo.h` file, create two empty files named
+    `foo_rs_api.rs` and `foo_rs_api_impl.cc`, and then executing
+    `cc_bindings_from_rs/test/golden/update.sh`. This will
+    generate the corresponding bindings files.
 *   If a test in this directory fails, look at the output. It should contain a
     diff of the failure.
-*   If you get spurious failures in this directory: Run `./update.sh`.
+*   If you get spurious failures in this directory: Run
+    `cc_bindings_from_rs/test/golden/update.sh`.
diff --git a/rs_bindings_from_cc/test/golden/golden_test.bzl b/rs_bindings_from_cc/test/golden/golden_test.bzl
index 49be6fa..d5c65ae 100644
--- a/rs_bindings_from_cc/test/golden/golden_test.bzl
+++ b/rs_bindings_from_cc/test/golden/golden_test.bzl
@@ -72,7 +72,7 @@
         cc_library = cc_library,
     )
     args = []
-    data = ["//rs_bindings_from_cc/test/golden:LICENSE_HEADER"]
+    data = ["//common:LICENSE_HEADER"]
     owned_files = []
     if golden_cc:
         new_cc = basename + ".cc_file"
@@ -127,7 +127,7 @@
 
     native.sh_test(
         name = name,
-        srcs = ["//rs_bindings_from_cc/test/golden:test.sh"],
+        srcs = ["//common:golden_test.sh"],
         args = args,
         data = data,
         tags = tags,