mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 12:33:33 +00:00
Use the same name in xtask and test utils
This commit is contained in:
parent
b6ba0dec0c
commit
abb6b8f14c
4 changed files with 12 additions and 12 deletions
|
@ -859,7 +859,7 @@ fn manual(fields: &[(&'static str, &'static str, &[&str], &str)]) -> String {
|
|||
mod tests {
|
||||
use std::fs;
|
||||
|
||||
use test_utils::{ensure_file_contents, project_dir};
|
||||
use test_utils::{ensure_file_contents, project_root};
|
||||
|
||||
use super::*;
|
||||
|
||||
|
@ -877,7 +877,7 @@ mod tests {
|
|||
.to_string();
|
||||
schema.push_str(",\n");
|
||||
|
||||
let package_json_path = project_dir().join("editors/code/package.json");
|
||||
let package_json_path = project_root().join("editors/code/package.json");
|
||||
let mut package_json = fs::read_to_string(&package_json_path).unwrap();
|
||||
|
||||
let start_marker = " \"$generated-start\": false,\n";
|
||||
|
@ -896,7 +896,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn schema_in_sync_with_docs() {
|
||||
let docs_path = project_dir().join("docs/user/generated_config.adoc");
|
||||
let docs_path = project_root().join("docs/user/generated_config.adoc");
|
||||
let current = fs::read_to_string(&docs_path).unwrap();
|
||||
let expected = ConfigData::manual();
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ use std::{
|
|||
use ast::NameOwner;
|
||||
use expect_test::expect_file;
|
||||
use rayon::prelude::*;
|
||||
use test_utils::{bench, bench_fixture, project_dir, skip_slow_tests};
|
||||
use test_utils::{bench, bench_fixture, project_root, skip_slow_tests};
|
||||
|
||||
use crate::{ast, fuzz, tokenize, AstNode, SourceFile, SyntaxError, TextRange, TextSize, Token};
|
||||
|
||||
|
@ -153,7 +153,7 @@ fn reparse_fuzz_tests() {
|
|||
/// Test that Rust-analyzer can parse and validate the rust-analyzer
|
||||
#[test]
|
||||
fn self_hosting_parsing() {
|
||||
let dir = project_dir().join("crates");
|
||||
let dir = project_root().join("crates");
|
||||
let files = walkdir::WalkDir::new(dir)
|
||||
.into_iter()
|
||||
.filter_entry(|entry| {
|
||||
|
@ -193,7 +193,7 @@ fn self_hosting_parsing() {
|
|||
}
|
||||
|
||||
fn test_data_dir() -> PathBuf {
|
||||
project_dir().join("crates/syntax/test_data")
|
||||
project_root().join("crates/syntax/test_data")
|
||||
}
|
||||
|
||||
fn assert_errors_are_present(errors: &[SyntaxError], path: &Path) {
|
||||
|
|
|
@ -4,7 +4,7 @@ use std::fs;
|
|||
|
||||
use stdx::format_to;
|
||||
|
||||
use crate::project_dir;
|
||||
use crate::project_root;
|
||||
|
||||
pub fn big_struct() -> String {
|
||||
let n = 1_000;
|
||||
|
@ -32,11 +32,11 @@ struct S{} {{
|
|||
}
|
||||
|
||||
pub fn glorious_old_parser() -> String {
|
||||
let path = project_dir().join("bench_data/glorious_old_parser");
|
||||
let path = project_root().join("bench_data/glorious_old_parser");
|
||||
fs::read_to_string(&path).unwrap()
|
||||
}
|
||||
|
||||
pub fn numerous_macro_rules() -> String {
|
||||
let path = project_dir().join("bench_data/numerous_macro_rules");
|
||||
let path = project_root().join("bench_data/numerous_macro_rules");
|
||||
fs::read_to_string(&path).unwrap()
|
||||
}
|
||||
|
|
|
@ -288,14 +288,14 @@ pub fn skip_slow_tests() -> bool {
|
|||
if should_skip {
|
||||
eprintln!("ignoring slow test")
|
||||
} else {
|
||||
let path = project_dir().join("./target/.slow_tests_cookie");
|
||||
let path = project_root().join("./target/.slow_tests_cookie");
|
||||
fs::write(&path, ".").unwrap();
|
||||
}
|
||||
should_skip
|
||||
}
|
||||
|
||||
/// Returns the path to the root directory of `rust-analyzer` project.
|
||||
pub fn project_dir() -> PathBuf {
|
||||
pub fn project_root() -> PathBuf {
|
||||
let dir = env!("CARGO_MANIFEST_DIR");
|
||||
PathBuf::from(dir).parent().unwrap().parent().unwrap().to_owned()
|
||||
}
|
||||
|
@ -371,7 +371,7 @@ pub fn try_ensure_file_contents(file: &Path, contents: &str) -> Result<(), ()> {
|
|||
}
|
||||
_ => (),
|
||||
}
|
||||
let display_path = file.strip_prefix(&project_dir()).unwrap_or(file);
|
||||
let display_path = file.strip_prefix(&project_root()).unwrap_or(file);
|
||||
eprintln!(
|
||||
"\n\x1b[31;1merror\x1b[0m: {} was not up-to-date, updating\n",
|
||||
display_path.display()
|
||||
|
|
Loading…
Reference in a new issue