Skip to content

Commit 1b3c957

Browse files
committed
Add a test for remap-path-prefix
1 parent 25bd121 commit 1b3c957

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
load("//rust:defs.bzl", "rust_test", "rust_library")
2+
3+
rust_library(
4+
name = "dep",
5+
srcs = ["dep.rs"],
6+
edition = "2018",
7+
)
8+
9+
rust_test(
10+
name = "remap_path_prefix",
11+
srcs = ["test.rs"],
12+
edition = "2018",
13+
deps = [":dep"],
14+
)

test/unit/remap_path_prefix/dep.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Without --remap-path-prefix, Location::caller() in this generic function will return an absolute path
2+
pub fn get_file_name<T>() -> &'static str {
3+
std::panic::Location::caller().file()
4+
}

test/unit/remap_path_prefix/test.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#[test]
2+
fn test_dep_file_name() {
3+
assert_eq!(dep::get_file_name::<()>(), "test/unit/remap_path_prefix/dep.rs");
4+
}

0 commit comments

Comments
 (0)