aya: Add cargo-public-api

Adds cargo-public-api. This allows for public API changes to get caught
by cargo test, requiring new changes to be "blessed" by using:

   UPDATE_EXPECT=1 cargo test

When this file is changed, Alessandro will need to review the PR.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
reviewable/pr682/r1
Dave Tucker 2 years ago
parent ff11c65734
commit ca2c360e69

@ -9,3 +9,6 @@ linker = "arm-linux-gnueabihf-gcc"
[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-musl-gcc"
[env]
CARGO_WORKSPACE_DIR = { value = "", relative = true }

@ -29,7 +29,11 @@ tokio = { workspace = true, features = ["rt"], optional = true }
[dev-dependencies]
assert_matches = { workspace = true }
expect-test = "1.4.1"
futures = { workspace = true }
public-api = "0.31.2"
rustdoc-json = "0.8.6"
rustup-toolchain = "0.1.5"
tempfile = { workspace = true }
[features]

@ -58,3 +58,27 @@ pub mod util;
pub use bpf::*;
pub use obj::btf::{Btf, BtfError};
pub use object::Endianness;
#[cfg(test)]
mod tests {
#[test]
#[cfg_attr(miri, ignore)]
fn public_api() {
// Install a compatible nightly toolchain if it is missing
rustup_toolchain::install(public_api::MINIMUM_NIGHTLY_RUST_VERSION).unwrap();
// Build rustdoc JSON
let rustdoc_json = rustdoc_json::Builder::default()
.toolchain(public_api::MINIMUM_NIGHTLY_RUST_VERSION)
.build()
.unwrap();
// Derive the public API from the rustdoc JSON
let public_api = public_api::Builder::from_rustdoc_json(rustdoc_json)
.build()
.unwrap();
// Assert that the public API looks correct
expect_test::expect_file!["./public-api.txt"].assert_eq(&public_api.to_string());
}
}

@ -224,7 +224,7 @@ fn maybe_warn_rlimit() {
let limit = unsafe { limit.assume_init() };
let limit: RlimitSize = RlimitSize(limit.rlim_cur.try_into().unwrap());
if limit.0 == RLIM_INFINITY.try_into().unwrap() {
if limit.0 == TryInto::<usize>::try_into(RLIM_INFINITY).unwrap() {
return;
}
warn!(

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save