Skip to content

Commit

Permalink
Add a test for remap-path-prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
goffrie committed Sep 26, 2022
1 parent 25bd121 commit 3b735aa
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/unit/remap_path_prefix/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
load("//rust:defs.bzl", "rust_test", "rust_library")

rust_library(
name = "dep",
srcs = ["dep.rs"],
edition = "2018",
)

rust_test(
name = "remap_path_prefix",
srcs = ["test.rs"],
edition = "2018",
deps = [":dep"],
)
4 changes: 4 additions & 0 deletions test/unit/remap_path_prefix/dep.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Without --remap-path-prefix, Location::caller() in this generic function will return an absolute path
pub fn get_file_name<T>() -> &'static str {
std::panic::Location::caller().file()
}
7 changes: 7 additions & 0 deletions test/unit/remap_path_prefix/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#[test]
fn test_dep_file_name() {
assert_eq!(
dep::get_file_name::<()>(),
"test/unit/remap_path_prefix/dep.rs"
);
}

0 comments on commit 3b735aa

Please sign in to comment.