Skip to content

feat: add Cargo-style rust_crate and reusable test suites - #217

Draft
dzbarsky wants to merge 2 commits into
mainfrom
codex/cargo-style-rust-crate
Draft

feat: add Cargo-style rust_crate and reusable test suites#217
dzbarsky wants to merge 2 commits into
mainfrom
codex/cargo-style-rust-crate

Conversation

@dzbarsky

@dzbarsky dzbarsky commented Aug 13, 2026

Copy link
Copy Markdown
Member

Summary

Add a public @rules_rs//rs:rust_crate.bzl macro that infers Cargo libraries, binaries, build scripts, library and binary unit tests, and integration tests. Expose independently reusable rust_unit_test_suite and rust_integration_test_suite helpers, and re-export the upstream-compatible rust_test_suite requested in #193.

The existing generated-dependency rust_crate implementation was moved to rs/private/rust_crate.bzl in #218.

The new Cargo workspace fixture covers binary-only packages, default and hyphenated binaries, nested binary and integration-test roots, shared test modules, normal/development/build dependency separation and overlap, build-script helper modules, CARGO_PKG_NAME, CARGO_PKG_VERSION, and compile-time/runtime CARGO_BIN_EXE_*.

Validation

  • bazel test --config=remote //rust_crate/... in test/: 15 tests passed.
  • Root-module public/private targets and //rs/private:all: 42 tests passed.
  • buildifier -mode=check, rustfmt --check, and git diff --check passed.

Full-suite validation on this macOS checkout encounters pre-existing local conditions: an ignored test/target directory is interpreted as a missing @target repository, and an unrestricted root remote run selects a macOS executable on Linux workers. Focused and existing private regression suites pass.

@dzbarsky
dzbarsky force-pushed the codex/cargo-style-rust-crate branch from ad04258 to c0db9dc Compare August 13, 2026 23:30
@dzbarsky
dzbarsky changed the base branch from main to codex/move-generated-rust-crate-private August 13, 2026 23:31
@dzbarsky
dzbarsky force-pushed the codex/cargo-style-rust-crate branch from c0db9dc to 0343b28 Compare August 13, 2026 23:55
@dzbarsky
dzbarsky changed the base branch from codex/move-generated-rust-crate-private to main August 13, 2026 23:55
Comment thread rs/rust_test.bzl Outdated
caller_rustc_env = kwargs.pop("rustc_env", {})
caller_env = kwargs.pop("env", {})

rustc_env = dict(cargo_binary_env)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

just do rustc_env = cargo_binary_env | rustc_env and add it to kwargs with default of {}? Same with the other ones

Comment thread README.md Outdated
rust_crate(
name = "my_crate",
aliases = aliases(),
deps = all_crate_deps(normal = True),

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

drop normal = True, we don't need that! actually can this just take a dep_data struct like DEP_DATA creates?

@dzbarsky dzbarsky left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

comments

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.

1 participant