Skip to content

Commit f213016

Browse files
authored
Move //cargo specific tests to //cargo/tests (#3874)
This also includes minor updates to account for the new placement of data files.
1 parent f1c294d commit f213016

82 files changed

Lines changed: 53 additions & 38 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cargo/tests/build_env/BUILD.bazel

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
load("//cargo:defs.bzl", "cargo_build_script")
2+
load("//rust:rust_test.bzl", "rust_test")
3+
4+
rust_test(
5+
# Intentionally uses a mix of -s and _s because those normalisations are part of what is being tested.
6+
name = "cargo_env-vars_test",
7+
srcs = ["tests/cargo.rs"],
8+
edition = "2018",
9+
deps = [":cargo_build_script_env-vars_bs"],
10+
)
11+
12+
rust_test(
13+
name = "cargo-env-vars-custom-crate-name-test",
14+
srcs = ["tests/custom_crate_name.rs"],
15+
crate_name = "custom_crate_name",
16+
edition = "2018",
17+
deps = [":cargo_build_script_env-vars_bs"],
18+
)
19+
20+
cargo_build_script(
21+
name = "cargo_build_script_env-vars_bs",
22+
srcs = ["src/build.rs"],
23+
edition = "2018",
24+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This file tests that CARGO_MANIFEST_DIR is set for the build environment
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#[test]
2+
fn cargo_env_vars() {
3+
assert_eq!(
4+
env!("CARGO_PKG_NAME"),
5+
"cargo-env-vars-custom-crate-name-test"
6+
);
7+
assert_eq!(env!("CARGO_CRATE_NAME"), "custom_crate_name");
8+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#[test]
2+
pub fn test_manifest_dir() {
3+
let actual = include_str!(concat!(
4+
env!("CARGO_MANIFEST_DIR"),
5+
"/src/manifest_dir_file.txt"
6+
))
7+
.trim_end();
8+
let expected = "This file tests that CARGO_MANIFEST_DIR is set for the build environment";
9+
assert_eq!(actual, expected);
10+
}
File renamed without changes.

test/cargo_build_script/build_script_env_files/BUILD.bazel renamed to cargo/tests/cargo_build_script/build_script_env_files/BUILD.bazel

File renamed without changes.

test/cargo_build_script/build_script_env_files/build.rs renamed to cargo/tests/cargo_build_script/build_script_env_files/build.rs

File renamed without changes.

0 commit comments

Comments
 (0)