Skip to content

Added rust_wasm_bindgen_test rule #3267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1066,12 +1066,15 @@ tasks:
platform: ubuntu2004
name: Extensions wasm-bindgen
working_directory: extensions/wasm_bindgen
shell_commands:
- "sudo apt -y update && sudo apt -y install libxcb1 libatk1.0-0 libatk-bridge2.0-0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libpango-1.0-0 libxkbcommon-x11-0 libcairo2"
build_flags: *aspects_flags
test_flags: *aspects_flags
build_targets:
- "//..."
test_targets:
- "//..."
# TODO: Chromedriver cannot launch chrome on linux
Copy link
Collaborator Author

@UebelAndre UebelAndre Mar 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really frustrating but I cannot for the life of me figure out why chrome doesn't work.

I believe the actual failure is

[1741451642.254][INFO]: [e873c799d7d436738e4d96b0edc0bdce] RESPONSE InitSession ERROR session not created: probably user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir

I've tried not setting --user-data-dir and it still presents this issue but the logs then reference a different directory generated in the TMPDIR environment variable location.

Full log:
https://buildkite.com/bazel/rules-rust-rustlang/builds/14294#0195769a-560d-4337-9b93-10baf5cfc21e

exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //test:hello_world_bundler_wasm_bindgen_test
-----------------------------------------------------------------------------
Executing bindgen...                              
                                                  
Running headless tests in Chrome on `http://127.0.0.1:45965/`
Try find `webdriver.json` for configure browser's capabilities:
Ok
Starting new webdriver session...                 
Visiting http://127.0.0.1:38527...                
                                                  
driver status: signal: 9 (SIGKILL)
driver stdout:
    Starting ChromeDriver 136.0.7055.0 (c9f0c043062618e6fefb32dea24968ac6836536a-refs/branch-heads/7055@{#1}) on port 45965
    Only local connections are allowed.
    Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
    ChromeDriver was started successfully on port 45965.

driver stderr:
    [1741451641.986][INFO]: [e873c799d7d436738e4d96b0edc0bdce] COMMAND InitSession {
       "desiredCapabilities": {
          "goog:chromeOptions": {
             "args": [ "user-data-dir=/var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/44886e0696fee5410020d9bd8d8f80cb/sandbox/linux-sandbox/318/execroot/_main/bazel-out/k8-fastbuild-ST-5ff9f0c5ea46/testlogs/test/hello_world_bundler_wasm_bindgen_test/test.outputs/user_data_dir", "headless", "disable-dev-shm-usage", "no-sandbox" ],
             "binary": "/var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/44886e0696fee5410020d9bd8d8f80cb/sandbox/linux-sandbox/318/execroot/_main/bazel-out/k8-fastbuild-ST-5ff9f0c5ea46/bin/test/hello_world_bundler_wasm_bindgen_test.runfiles/_main~rust_ext~chrome_linux64/chrome"
          },
          "moz:firefoxOptions": {
             "args": [  ],
             "prefs": {
             }
          }
       },
       "requiredCapabilities": {
       }
    }
    [1741451641.986][INFO]: Populating Preferences file: {
       "alternate_error_pages": {
          "enabled": false
       },
       "autofill": {
          "enabled": false
       },
       "browser": {
          "check_default_browser": false
       },
       "distribution": {
          "import_bookmarks": false,
          "import_history": false,
          "import_search_engine": false,
          "make_chrome_default_for_user": false,
          "skip_first_run_ui": true
       },
       "dns_prefetching": {
          "enabled": false
       },
       "profile": {
          "content_settings": {
             "pattern_pairs": {
                "https://*,*": {
                   "media-stream": {
                      "audio": "Default",
                      "video": "Default"
                   }
                }
             }
          },
          "default_content_setting_values": {
             "geolocation": 1
          },
          "default_content_settings": {
             "geolocation": 1,
             "mouselock": 1,
             "notifications": 1,
             "popups": 1,
             "ppapi-broker": 1
          },
          "password_manager_enabled": false
       },
       "safebrowsing": {
          "enabled": false
       },
       "search": {
          "suggest_enabled": false
       },
       "translate": {
          "enabled": false
       }
    }
    [1741451641.987][INFO]: Populating Local State file: {
       "background_mode": {
          "enabled": false
       },
       "ssl": {
          "rev_checking": {
             "enabled": false
          }
       }
    }
    [1741451641.987][INFO]: ChromeDriver supports communication with Chrome via pipes. This is more reliable and more secure.
    [1741451641.987][INFO]: Use the --remote-debugging-pipe Chrome switch instead of the default --remote-debugging-port to enable this communication mode.
    [1741451641.987][INFO]: Launching chrome: /var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/44886e0696fee5410020d9bd8d8f80cb/sandbox/linux-sandbox/318/execroot/_main/bazel-out/k8-fastbuild-ST-5ff9f0c5ea46/bin/test/hello_world_bundler_wasm_bindgen_test.runfiles/_main~rust_ext~chrome_linux64/chrome --allow-pre-commit-input --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-dev-shm-usage --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-automation --enable-logging --headless --log-level=0 --no-first-run --no-sandbox --no-service-autorun --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir=/var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/44886e0696fee5410020d9bd8d8f80cb/sandbox/linux-sandbox/318/execroot/_main/bazel-out/k8-fastbuild-ST-5ff9f0c5ea46/testlogs/test/hello_world_bundler_wasm_bindgen_test/test.outputs/user_data_dir
    [0308/163402.035000:ERROR:third_party/crashpad/crashpad/util/file/file_io_posix.cc:145] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq: No such file or directory (2)
    [0308/163402.035048:ERROR:third_party/crashpad/crashpad/util/file/file_io_posix.cc:145] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq: No such file or directory (2)
    [1741451642.254][INFO]: [e873c799d7d436738e4d96b0edc0bdce] RESPONSE InitSession ERROR session not created: probably user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir
    [1741451642.254][DEBUG]: Log type 'driver' lost 0 entries on destruction
    [1741451642.254][DEBUG]: Log type 'browser' lost 0 entries on destruction

                                                  
Error: http://127.0.0.1:45965/session/e873c799d7d436738e4d96b0edc0bdce/url: status code 404

# test_targets:
# - "//..."
extensions_wasm_bindgen_linux_rbe:
platform: rbe_ubuntu2004
name: Extensions wasm-bindgen
Expand All @@ -1083,12 +1086,13 @@ tasks:
test_flags: *aspects_flags
build_targets:
- "//..."
test_targets:
- "--"
- "//..."
# TODO: https://github.com/bazelbuild/rules_rust/issues/3039
- "-//rules_js/test:hello_world_wasm_lib_test"
- "-//rules_js/test:hello_world_wasm_direct_test"
# TODO: Chromedriver cannot launch chrome on linux
# test_targets:
# - "--"
# - "//..."
# # TODO: https://github.com/bazelbuild/rules_rust/issues/3039
# - "-//rules_js/test:hello_world_wasm_lib_test"
# - "-//rules_js/test:hello_world_wasm_direct_test"
extensions_wasm_bindgen_macos:
platform: macos_arm64
name: Extensions wasm-bindgen
Expand Down
3 changes: 3 additions & 0 deletions extensions/wasm_bindgen/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
/bazel-*
user.bazelrc

# Test Browsers
browsers/

# rust-analyzer
rust-project.json

Expand Down
16 changes: 16 additions & 0 deletions extensions/wasm_bindgen/3rdparty/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ crates_vendor(
"wasm-bindgen": crate.spec(
version = WASM_BINDGEN_VERSION,
),
"wasm-bindgen-test": crate.spec(
version = "0.3.37",
),
},
# Shorten the repository name to avoid MAX_PATH issues on Windows
# `rules_rust_wasm_bindgen_deps` == `rrwbd`
Expand All @@ -47,12 +50,25 @@ alias(
visibility = ["//visibility:public"],
)

alias(
name = "wasm_bindgen_test_runner",
actual = "@rules_rust_wasm_bindgen_cli//:test_runner",
tags = ["manual"],
visibility = ["//visibility:public"],
)

alias(
name = "wasm_bindgen",
actual = "//3rdparty/crates:wasm-bindgen",
visibility = ["//visibility:public"],
)

alias(
name = "wasm_bindgen_test",
actual = "//3rdparty/crates:wasm-bindgen-test",
visibility = ["//visibility:public"],
)

bzl_library(
name = "bzl_lib",
srcs = [
Expand Down
35 changes: 34 additions & 1 deletion extensions/wasm_bindgen/3rdparty/BUILD.wasm-bindgen-cli.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ exports_files([
# TODO: Comment on bootstrapping
rust_binary(
name = "wasm-bindgen-cli",
srcs = glob(["**/*.rs"]),
srcs = glob(
include = ["**/*.rs"],
exclude = ["src/bin/wasm-bindgen-test-runner/**"],
),
aliases = aliases(),
crate_features = [
],
Expand All @@ -33,3 +36,33 @@ alias(
actual = ":wasm-bindgen-cli",
tags = ["manual"],
)

rust_binary(
name = "wasm-bindgen-test-runner",
srcs = glob(
include = ["**/*.rs"],
exclude = ["src/bin/wasm-bindgen.rs"],
),
aliases = aliases(),
compile_data = glob([
"**/*.html",
]),
crate_features = [
],
crate_root = "src/bin/wasm-bindgen-test-runner/main.rs",
data = [],
edition = "2018",
proc_macro_deps = all_crate_deps(proc_macro = True),
rustc_flags = [
# Don't produce warnings for this crate
"--cap-lints=allow",
],
version = WASM_BINDGEN_VERSION,
deps = all_crate_deps(),
)

alias(
name = "test_runner",
actual = ":wasm-bindgen-test-runner",
tags = ["manual"],
)
78 changes: 78 additions & 0 deletions extensions/wasm_bindgen/3rdparty/Cargo.Bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions extensions/wasm_bindgen/3rdparty/crates/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading