aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/rust-analyzer/src/config.rs6
-rw-r--r--crates/syntax/src/tests.rs6
-rw-r--r--crates/test_utils/src/bench_fixture.rs6
-rw-r--r--crates/test_utils/src/lib.rs6
4 files changed, 12 insertions, 12 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index 02468631b..bceca2b0f 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -859,7 +859,7 @@ fn manual(fields: &[(&'static str, &'static str, &[&str], &str)]) -> String {
859mod tests { 859mod tests {
860 use std::fs; 860 use std::fs;
861 861
862 use test_utils::{ensure_file_contents, project_dir}; 862 use test_utils::{ensure_file_contents, project_root};
863 863
864 use super::*; 864 use super::*;
865 865
@@ -877,7 +877,7 @@ mod tests {
877 .to_string(); 877 .to_string();
878 schema.push_str(",\n"); 878 schema.push_str(",\n");
879 879
880 let package_json_path = project_dir().join("editors/code/package.json"); 880 let package_json_path = project_root().join("editors/code/package.json");
881 let mut package_json = fs::read_to_string(&package_json_path).unwrap(); 881 let mut package_json = fs::read_to_string(&package_json_path).unwrap();
882 882
883 let start_marker = " \"$generated-start\": false,\n"; 883 let start_marker = " \"$generated-start\": false,\n";
@@ -896,7 +896,7 @@ mod tests {
896 896
897 #[test] 897 #[test]
898 fn schema_in_sync_with_docs() { 898 fn schema_in_sync_with_docs() {
899 let docs_path = project_dir().join("docs/user/generated_config.adoc"); 899 let docs_path = project_root().join("docs/user/generated_config.adoc");
900 let current = fs::read_to_string(&docs_path).unwrap(); 900 let current = fs::read_to_string(&docs_path).unwrap();
901 let expected = ConfigData::manual(); 901 let expected = ConfigData::manual();
902 902
diff --git a/crates/syntax/src/tests.rs b/crates/syntax/src/tests.rs
index b2c06e24f..ba0ccfaed 100644
--- a/crates/syntax/src/tests.rs
+++ b/crates/syntax/src/tests.rs
@@ -7,7 +7,7 @@ use std::{
7use ast::NameOwner; 7use ast::NameOwner;
8use expect_test::expect_file; 8use expect_test::expect_file;
9use rayon::prelude::*; 9use rayon::prelude::*;
10use test_utils::{bench, bench_fixture, project_dir, skip_slow_tests}; 10use test_utils::{bench, bench_fixture, project_root, skip_slow_tests};
11 11
12use crate::{ast, fuzz, tokenize, AstNode, SourceFile, SyntaxError, TextRange, TextSize, Token}; 12use crate::{ast, fuzz, tokenize, AstNode, SourceFile, SyntaxError, TextRange, TextSize, Token};
13 13
@@ -153,7 +153,7 @@ fn reparse_fuzz_tests() {
153/// Test that Rust-analyzer can parse and validate the rust-analyzer 153/// Test that Rust-analyzer can parse and validate the rust-analyzer
154#[test] 154#[test]
155fn self_hosting_parsing() { 155fn self_hosting_parsing() {
156 let dir = project_dir().join("crates"); 156 let dir = project_root().join("crates");
157 let files = walkdir::WalkDir::new(dir) 157 let files = walkdir::WalkDir::new(dir)
158 .into_iter() 158 .into_iter()
159 .filter_entry(|entry| { 159 .filter_entry(|entry| {
@@ -193,7 +193,7 @@ fn self_hosting_parsing() {
193} 193}
194 194
195fn test_data_dir() -> PathBuf { 195fn test_data_dir() -> PathBuf {
196 project_dir().join("crates/syntax/test_data") 196 project_root().join("crates/syntax/test_data")
197} 197}
198 198
199fn assert_errors_are_present(errors: &[SyntaxError], path: &Path) { 199fn assert_errors_are_present(errors: &[SyntaxError], path: &Path) {
diff --git a/crates/test_utils/src/bench_fixture.rs b/crates/test_utils/src/bench_fixture.rs
index d775e2cc9..3a37c4473 100644
--- a/crates/test_utils/src/bench_fixture.rs
+++ b/crates/test_utils/src/bench_fixture.rs
@@ -4,7 +4,7 @@ use std::fs;
4 4
5use stdx::format_to; 5use stdx::format_to;
6 6
7use crate::project_dir; 7use crate::project_root;
8 8
9pub fn big_struct() -> String { 9pub fn big_struct() -> String {
10 let n = 1_000; 10 let n = 1_000;
@@ -32,11 +32,11 @@ struct S{} {{
32} 32}
33 33
34pub fn glorious_old_parser() -> String { 34pub fn glorious_old_parser() -> String {
35 let path = project_dir().join("bench_data/glorious_old_parser"); 35 let path = project_root().join("bench_data/glorious_old_parser");
36 fs::read_to_string(&path).unwrap() 36 fs::read_to_string(&path).unwrap()
37} 37}
38 38
39pub fn numerous_macro_rules() -> String { 39pub fn numerous_macro_rules() -> String {
40 let path = project_dir().join("bench_data/numerous_macro_rules"); 40 let path = project_root().join("bench_data/numerous_macro_rules");
41 fs::read_to_string(&path).unwrap() 41 fs::read_to_string(&path).unwrap()
42} 42}
diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs
index 7f122b13e..097a54139 100644
--- a/crates/test_utils/src/lib.rs
+++ b/crates/test_utils/src/lib.rs
@@ -288,14 +288,14 @@ pub fn skip_slow_tests() -> bool {
288 if should_skip { 288 if should_skip {
289 eprintln!("ignoring slow test") 289 eprintln!("ignoring slow test")
290 } else { 290 } else {
291 let path = project_dir().join("./target/.slow_tests_cookie"); 291 let path = project_root().join("./target/.slow_tests_cookie");
292 fs::write(&path, ".").unwrap(); 292 fs::write(&path, ".").unwrap();
293 } 293 }
294 should_skip 294 should_skip
295} 295}
296 296
297/// Returns the path to the root directory of `rust-analyzer` project. 297/// Returns the path to the root directory of `rust-analyzer` project.
298pub fn project_dir() -> PathBuf { 298pub fn project_root() -> PathBuf {
299 let dir = env!("CARGO_MANIFEST_DIR"); 299 let dir = env!("CARGO_MANIFEST_DIR");
300 PathBuf::from(dir).parent().unwrap().parent().unwrap().to_owned() 300 PathBuf::from(dir).parent().unwrap().parent().unwrap().to_owned()
301} 301}
@@ -371,7 +371,7 @@ pub fn try_ensure_file_contents(file: &Path, contents: &str) -> Result<(), ()> {
371 } 371 }
372 _ => (), 372 _ => (),
373 } 373 }
374 let display_path = file.strip_prefix(&project_dir()).unwrap_or(file); 374 let display_path = file.strip_prefix(&project_root()).unwrap_or(file);
375 eprintln!( 375 eprintln!(
376 "\n\x1b[31;1merror\x1b[0m: {} was not up-to-date, updating\n", 376 "\n\x1b[31;1merror\x1b[0m: {} was not up-to-date, updating\n",
377 display_path.display() 377 display_path.display()