Skip to content

Commit abb6b8f

Browse files
committed
Use the same name in xtask and test utils
1 parent b6ba0de commit abb6b8f

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

crates/rust-analyzer/src/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ fn manual(fields: &[(&'static str, &'static str, &[&str], &str)]) -> String {
859859
mod tests {
860860
use std::fs;
861861

862-
use test_utils::{ensure_file_contents, project_dir};
862+
use test_utils::{ensure_file_contents, project_root};
863863

864864
use super::*;
865865

@@ -877,7 +877,7 @@ mod tests {
877877
.to_string();
878878
schema.push_str(",\n");
879879

880-
let package_json_path = project_dir().join("editors/code/package.json");
880+
let package_json_path = project_root().join("editors/code/package.json");
881881
let mut package_json = fs::read_to_string(&package_json_path).unwrap();
882882

883883
let start_marker = " \"$generated-start\": false,\n";
@@ -896,7 +896,7 @@ mod tests {
896896

897897
#[test]
898898
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");
900900
let current = fs::read_to_string(&docs_path).unwrap();
901901
let expected = ConfigData::manual();
902902

crates/syntax/src/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{
77
use ast::NameOwner;
88
use expect_test::expect_file;
99
use rayon::prelude::*;
10-
use test_utils::{bench, bench_fixture, project_dir, skip_slow_tests};
10+
use test_utils::{bench, bench_fixture, project_root, skip_slow_tests};
1111

1212
use crate::{ast, fuzz, tokenize, AstNode, SourceFile, SyntaxError, TextRange, TextSize, Token};
1313

@@ -153,7 +153,7 @@ fn reparse_fuzz_tests() {
153153
/// Test that Rust-analyzer can parse and validate the rust-analyzer
154154
#[test]
155155
fn self_hosting_parsing() {
156-
let dir = project_dir().join("crates");
156+
let dir = project_root().join("crates");
157157
let files = walkdir::WalkDir::new(dir)
158158
.into_iter()
159159
.filter_entry(|entry| {
@@ -193,7 +193,7 @@ fn self_hosting_parsing() {
193193
}
194194

195195
fn test_data_dir() -> PathBuf {
196-
project_dir().join("crates/syntax/test_data")
196+
project_root().join("crates/syntax/test_data")
197197
}
198198

199199
fn assert_errors_are_present(errors: &[SyntaxError], path: &Path) {

crates/test_utils/src/bench_fixture.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::fs;
44

55
use stdx::format_to;
66

7-
use crate::project_dir;
7+
use crate::project_root;
88

99
pub fn big_struct() -> String {
1010
let n = 1_000;
@@ -32,11 +32,11 @@ struct S{} {{
3232
}
3333

3434
pub 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");
3636
fs::read_to_string(&path).unwrap()
3737
}
3838

3939
pub 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");
4141
fs::read_to_string(&path).unwrap()
4242
}

crates/test_utils/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,14 +288,14 @@ pub fn skip_slow_tests() -> bool {
288288
if should_skip {
289289
eprintln!("ignoring slow test")
290290
} else {
291-
let path = project_dir().join("./target/.slow_tests_cookie");
291+
let path = project_root().join("./target/.slow_tests_cookie");
292292
fs::write(&path, ".").unwrap();
293293
}
294294
should_skip
295295
}
296296

297297
/// Returns the path to the root directory of `rust-analyzer` project.
298-
pub fn project_dir() -> PathBuf {
298+
pub fn project_root() -> PathBuf {
299299
let dir = env!("CARGO_MANIFEST_DIR");
300300
PathBuf::from(dir).parent().unwrap().parent().unwrap().to_owned()
301301
}
@@ -371,7 +371,7 @@ pub fn try_ensure_file_contents(file: &Path, contents: &str) -> Result<(), ()> {
371371
}
372372
_ => (),
373373
}
374-
let display_path = file.strip_prefix(&project_dir()).unwrap_or(file);
374+
let display_path = file.strip_prefix(&project_root()).unwrap_or(file);
375375
eprintln!(
376376
"\n\x1b[31;1merror\x1b[0m: {} was not up-to-date, updating\n",
377377
display_path.display()

0 commit comments

Comments
 (0)