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

Conversation

UebelAndre
Copy link
Collaborator

@UebelAndre UebelAndre commented Feb 13, 2025

This change adds a new rule rust_wasm_bindgen_test for running tests in a headless browser.

Currently only chrome and firefox are supported browsers. The browser can be selected using the following flag.

--@rules_rust_wasm_bindgen//:test_browser={BROWSER}

@UebelAndre UebelAndre force-pushed the wasm-bindgen branch 4 times, most recently from 64d385c to 1ec5801 Compare February 20, 2025 05:00
@UebelAndre UebelAndre force-pushed the wasm-bindgen branch 4 times, most recently from 5313a77 to ecd6ef3 Compare March 8, 2025 17:31
@UebelAndre UebelAndre marked this pull request as ready for review March 8, 2025 17:33
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

Copy link
Collaborator

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

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

Exciting! I will try to poke at the chromedriver stuff at some point... Definitely seems weird - the directories should be per-action unique because of the sandbox...

@UebelAndre UebelAndre requested a review from illicitonion March 8, 2025 23:25
@UebelAndre UebelAndre enabled auto-merge March 10, 2025 15:37
@UebelAndre UebelAndre disabled auto-merge March 10, 2025 15:37
@UebelAndre UebelAndre enabled auto-merge March 10, 2025 15:37
@UebelAndre UebelAndre added this pull request to the merge queue Mar 10, 2025
Merged via the queue into bazelbuild:main with commit 14b2965 Mar 10, 2025
3 checks passed
@UebelAndre UebelAndre deleted the wasm-bindgen branch March 10, 2025 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants