Skip to content

Commit

Permalink
Add crate for testing build configs (#2326)
Browse files Browse the repository at this point in the history
I intend to publish this to crates.io after review.

This will be used to test
#2312.
  • Loading branch information
illicitonion authored Dec 13, 2023
1 parent 4cdada1 commit 233bb35
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
7 changes: 7 additions & 0 deletions crate_universe/test_data/test_data_passing_crate/Cargo.lock

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

6 changes: 6 additions & 0 deletions crate_universe/test_data/test_data_passing_crate/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "test_data_passing_crate"
description = "Used by https://github.com/bazelbuild/rules_rust to test cargo emulation"
version = "0.1.0"
edition = "2021"
repository = "https://github.com/bazelbuild/rules_rust"
3 changes: 3 additions & 0 deletions crate_universe/test_data/test_data_passing_crate/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# test_data_passing_crate

This crate exists, and is published to crates.io, so that we can write tests for crate_universe which assert over what opt level and OUT_DIR were used when third-party crates from crates.io were being built.
10 changes: 10 additions & 0 deletions crate_universe/test_data/test_data_passing_crate/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fn main() {
println!(
"cargo:rustc-env=BUILD_SCRIPT_OPT_LEVEL={}",
std::env::var("OPT_LEVEL").unwrap()
);
println!(
"cargo:rustc-env=BUILD_SCRIPT_OUT_DIR={}",
std::env::var("OUT_DIR").unwrap()
);
}
7 changes: 7 additions & 0 deletions crate_universe/test_data/test_data_passing_crate/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pub const fn get_opt_level() -> &'static str {
env!("BUILD_SCRIPT_OPT_LEVEL")
}

pub const fn get_out_dir() -> &'static str {
env!("BUILD_SCRIPT_OUT_DIR")
}

0 comments on commit 233bb35

Please sign in to comment.