Fix test generated crate roots when modules have `..` path components [chromium/src : main]

1 view
Skip to first unread message

danakj (Gerrit)

unread,
Mar 30, 2022, 10:23:32 AM3/30/22
to rust...@chromium.org, Chromium LUCI CQ, Adrian Taylor, chromium...@chromium.org, Łukasz Anforowicz

Attention is currently required from: Adrian Taylor.

Patch set 2:Auto-Submit +1Commit-Queue +1

View Change

    To view, visit change 3560901. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I6a7e4db46c158b39c4e6df3f61ce8d9414b81f9e
    Gerrit-Change-Number: 3560901
    Gerrit-PatchSet: 2
    Gerrit-Owner: danakj <dan...@chromium.org>
    Gerrit-Reviewer: Adrian Taylor <adet...@chromium.org>
    Gerrit-Reviewer: danakj <dan...@chromium.org>
    Gerrit-CC: Łukasz Anforowicz <luk...@chromium.org>
    Gerrit-Attention: Adrian Taylor <adet...@chromium.org>
    Gerrit-Comment-Date: Wed, 30 Mar 2022 14:23:22 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    Gerrit-MessageType: comment

    danakj (Gerrit)

    unread,
    Mar 31, 2022, 1:30:30 PM3/31/22
    to rust...@chromium.org, Chromium LUCI CQ, Adrian Taylor, chromium...@chromium.org, Łukasz Anforowicz

    Attention is currently required from: Adrian Taylor.

    View Change

    1 comment:

    To view, visit change 3560901. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I6a7e4db46c158b39c4e6df3f61ce8d9414b81f9e
    Gerrit-Change-Number: 3560901
    Gerrit-PatchSet: 2
    Gerrit-Owner: danakj <dan...@chromium.org>
    Gerrit-Reviewer: Adrian Taylor <adet...@chromium.org>
    Gerrit-Reviewer: danakj <dan...@chromium.org>
    Gerrit-CC: Łukasz Anforowicz <luk...@chromium.org>
    Gerrit-Attention: Adrian Taylor <adet...@chromium.org>
    Gerrit-Comment-Date: Thu, 31 Mar 2022 17:30:19 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Gerrit-MessageType: comment

    Adrian Taylor (Gerrit)

    unread,
    Mar 31, 2022, 1:48:33 PM3/31/22
    to danakj, rust...@chromium.org, Chromium LUCI CQ, chromium...@chromium.org, Łukasz Anforowicz

    Attention is currently required from: danakj.

    Patch set 2:Code-Review +1Commit-Queue +2

    View Change

      To view, visit change 3560901. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I6a7e4db46c158b39c4e6df3f61ce8d9414b81f9e
      Gerrit-Change-Number: 3560901
      Gerrit-PatchSet: 2
      Gerrit-Owner: danakj <dan...@chromium.org>
      Gerrit-Reviewer: Adrian Taylor <adet...@chromium.org>
      Gerrit-Reviewer: danakj <dan...@chromium.org>
      Gerrit-CC: Łukasz Anforowicz <luk...@chromium.org>
      Gerrit-Attention: danakj <dan...@chromium.org>
      Gerrit-Comment-Date: Thu, 31 Mar 2022 17:48:25 +0000

      Chromium LUCI CQ (Gerrit)

      unread,
      Mar 31, 2022, 3:20:48 PM3/31/22
      to danakj, rust...@chromium.org, Adrian Taylor, chromium...@chromium.org, Łukasz Anforowicz

      Chromium LUCI CQ submitted this change.

      View Change


      Approvals: Adrian Taylor: Looks good to me; Commit danakj: Send CL to CQ automatically after approval
      Fix test generated crate roots when modules have `..` path components

      A `..` symbol can't be part of a Rust module name, so convert it into
      a string that is valid in a Rust identifier.

      This popped up when //content/test:content_unittests has modules at
      "../browser/..." and "../renderer/..." etc.

      R=adet...@chromium.org

      Bug: 1305396
      Change-Id: I6a7e4db46c158b39c4e6df3f61ce8d9414b81f9e
      Cq-Include-Trybots: luci.chromium.try:android-rust-arm-dbg,android-rust-arm-rel,linux-rust-x64-rel,linux-rust-x64-dbg
      Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3560901
      Auto-Submit: danakj <dan...@chromium.org>
      Reviewed-by: Adrian Taylor <adet...@chromium.org>
      Commit-Queue: Adrian Taylor <adet...@chromium.org>
      Cr-Commit-Position: refs/heads/main@{#987580}
      ---
      M build/rust/rust_target.gni
      1 file changed, 34 insertions(+), 1 deletion(-)

      diff --git a/build/rust/rust_target.gni b/build/rust/rust_target.gni
      index 63bae4c9..1117e07 100644
      --- a/build/rust/rust_target.gni
      +++ b/build/rust/rust_target.gni
      @@ -63,7 +63,16 @@
      foreach(rs, invoker.sources) {
      rs_path_from_root = rebase_path(rs, target_gen_dir)
      contents += [ "#[path = \"${rs_path_from_root}\"]" ]
      - rs_modname = string_replace(string_replace(rs, "/", "_"), ".rs", "")
      +
      + # Drop the file extension from the module name.
      + rs_modname = string_replace(rs, ".rs", "")
      +
      + # Replace invalid "/" chars in the source file path.
      + rs_modname = string_replace(rs_modname, "/", "_")
      +
      + # Since source files are specified relative to the BUILD.gn they may
      + # also have ".." path components.
      + rs_modname = string_replace(rs_modname, "..", "dotdot")
      contents += [
      "mod ${rs_modname};",
      "",

      To view, visit change 3560901. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I6a7e4db46c158b39c4e6df3f61ce8d9414b81f9e
      Gerrit-Change-Number: 3560901
      Gerrit-PatchSet: 3
      Gerrit-Owner: danakj <dan...@chromium.org>
      Gerrit-Reviewer: Adrian Taylor <adet...@chromium.org>
      Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
      Gerrit-Reviewer: danakj <dan...@chromium.org>
      Gerrit-CC: Łukasz Anforowicz <luk...@chromium.org>
      Gerrit-MessageType: merged
      Reply all
      Reply to author
      Forward
      0 new messages