Skip to content

Use Bazel for running Rust tests#11852

Merged
diemol merged 5 commits intotrunkfrom
bazel-rust-test
Apr 17, 2023
Merged

Use Bazel for running Rust tests#11852
diemol merged 5 commits intotrunkfrom
bazel-rust-test

Conversation

@p0deje
Copy link
Copy Markdown
Member

@p0deje p0deje commented Mar 31, 2023

Brings Rust bits on par with the rest, allowing to run tests using Bazel:

$ bazel test -t- //rust/...
INFO: Analyzed 9 targets (0 packages loaded, 1640 targets configured).
INFO: Found 2 targets and 7 test targets...
INFO: Elapsed time: 22.218s, Critical Path: 20.78s
INFO: 8 processes: 2 darwin-sandbox, 12 local.
INFO: Build completed successfully, 8 total actions
//rust:tests/cli_tests                                                   PASSED in 20.7s
//rust:tests/iexplorer_tests                                             PASSED in 0.5s
//rust:tests/output_tests                                                PASSED in 0.1s
//rust:tests/proxy_tests                                                 PASSED in 0.1s
//rust:tests/safari_tests                                                PASSED in 0.0s
//rust:tests/timeout_tests                                               PASSED in 0.1s
//rust:unit                                                              PASSED in 0.1s

It seems like proxy tests cannot be easily run in parallel to others so I ended up just using the exclusive tag to force all the tests sequentially.

@p0deje p0deje added the rust label Mar 31, 2023
@p0deje p0deje requested a review from bonigarcia March 31, 2023 23:40
@p0deje p0deje force-pushed the bazel-rust-test branch 2 times, most recently from da2f740 to 515f1c2 Compare April 1, 2023 23:23
Copy link
Copy Markdown
Member

@bonigarcia bonigarcia left a comment

Choose a reason for hiding this comment

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

I am not sure about this PR. What is the benefit of running the Rust test with Bazel instead of cargo?

In any case, the current PR is not exactly the same as cargo test. If I am not wrong, the tests executed are those included in the tests folders:

for file in glob(["tests/*.rs"])

Nevertheless, those are only the integration tests. There are also unit tests within the src folder (which is the typical way to do it with Rust). See, for example, firefox.rs.

@p0deje
Copy link
Copy Markdown
Member Author

p0deje commented Apr 2, 2023

I am not sure about this PR. What is the benefit of running the Rust test with Bazel instead of cargo?

The main benefits are the same as for any other code in the repository - use a single tool that automatically installs the Rust toolchain, compiles the binary, and hermetically runs the tests without requiring a developer to do all of that manually. Furthermore, once we start using remote cache and remote build, it will be possible to build Linux versions from macOS machines for example.

Nevertheless, those are only the integration tests. There are also unit tests within the src folder (which is the typical way to do it with Rust). See, for example, firefox.rs.

Thanks for pointing that out, I was not aware - will add this too.

@p0deje p0deje force-pushed the bazel-rust-test branch from 515f1c2 to 3a7a7bb Compare April 2, 2023 13:33
@diemol
Copy link
Copy Markdown
Member

diemol commented Apr 5, 2023

I wonder why tests are failing if they are passing on trunk, the only difference is how they are executed. Any ideas @p0deje @bonigarcia ?

@p0deje
Copy link
Copy Markdown
Member Author

p0deje commented Apr 5, 2023

@diemol I think the unit tests are failing because of the sandbox and can be fixed by adding a no-sandbox tag to the target. I am not sure what is wrong with proxy tests on Windows though.

@diemol
Copy link
Copy Markdown
Member

diemol commented Apr 16, 2023

Strange... Why is the proxy test failing on Windows on this PR but passing on trunk?

@p0deje
Copy link
Copy Markdown
Member Author

p0deje commented Apr 16, 2023

@diemol It's actually failing on trunk too if you run it separately cargo test --test proxy_tests. I'm trying to figure out what's going on with @bonigarcia.

@bonigarcia
Copy link
Copy Markdown
Member

@p0deje It seems this issue has been fixed after merging #11865 by @dev-ardi (thanks about that!). Now the output in Windows is as follows:

C:\Users\boni\Documents\dev\selenium\rust>cargo test --test proxy_tests
   Compiling selenium-manager v1.0.0-M3 (C:\Users\boni\Documents\dev\selenium\rust)
    Finished test [unoptimized + debuginfo] target(s) in 2.43s
     Running tests\proxy_tests.rs (target\debug\deps\proxy_tests-56cacd1d69678e3c.exe)

running 3 tests
test wrong_port_proxy_test ... ok
test wrong_protocol_proxy_test ... ok
test ok_proxy_test ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.29s

@diemol diemol merged commit 2b3ad21 into trunk Apr 17, 2023
@diemol diemol deleted the bazel-rust-test branch April 17, 2023 09:51
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.

3 participants