Skip to content

Commit b7c1b0f

Browse files
authored
Use test harness tests in rust_analyzer now that runfiles work on windows (#785)
Use test harness tests in rust_analyzer now that runfiles work on windows
1 parent 4c31047 commit b7c1b0f

File tree

4 files changed

+23
-22
lines changed

4 files changed

+23
-22
lines changed

test/rust_analyzer/aspect_traversal_test/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,5 @@ rust_test(
4545
srcs = ["rust_project_json_test.rs"],
4646
data = [":rust-project.json"],
4747
edition = "2018",
48-
use_libtest_harness = False,
4948
deps = ["//tools/runfiles"],
5049
)
Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
1-
use runfiles::Runfiles;
1+
#[cfg(test)]
2+
mod tests {
3+
use runfiles::Runfiles;
24

3-
fn main() {
4-
let r = Runfiles::create().unwrap();
5-
let rust_project_path =
6-
r.rlocation("rules_rust/test/rust_analyzer/aspect_traversal_test/rust-project.json");
5+
#[test]
6+
fn test_aspect_traverses_all_the_right_corners_of_target_graph() {
7+
let r = Runfiles::create().unwrap();
8+
let rust_project_path =
9+
r.rlocation("rules_rust/test/rust_analyzer/aspect_traversal_test/rust-project.json");
710

8-
let content = std::fs::read_to_string(&rust_project_path)
9-
.expect(&format!("couldn't open {:?}", &rust_project_path));
11+
let content = std::fs::read_to_string(&rust_project_path)
12+
.expect(&format!("couldn't open {:?}", &rust_project_path));
1013

11-
for dep in &[
12-
"lib_dep",
13-
"extra_test_dep",
14-
"proc_macro_dep",
15-
"extra_proc_macro_dep",
16-
] {
17-
if !content.contains(dep) {
18-
panic!("expected rust-project.json to contain {}.", dep);
14+
for dep in &[
15+
"lib_dep",
16+
"extra_test_dep",
17+
"proc_macro_dep",
18+
"extra_proc_macro_dep",
19+
] {
20+
assert!(
21+
content.contains(dep),
22+
"expected rust-project.json to contain {}.",
23+
dep
24+
);
1925
}
2026
}
2127
}

test/rust_analyzer/merging_crates_test/rust_project_json_test.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
use runfiles::Runfiles;
2-
31
#[cfg(test)]
42
mod tests {
5-
use super::*;
3+
use runfiles::Runfiles;
64

75
#[test]
86
fn test_deps_of_crate_and_its_test_are_merged() {

test/rust_analyzer/merging_crates_test_reversed/rust_project_json_test.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
use runfiles::Runfiles;
2-
31
#[cfg(test)]
42
mod tests {
5-
use super::*;
3+
use runfiles::Runfiles;
64

75
#[test]
86
fn test_deps_of_crate_and_its_test_are_merged() {

0 commit comments

Comments
 (0)