Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

tests: Don't generate tooltip results in tests/fixtures #1199

Merged
merged 1 commit into from
Dec 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 9 additions & 22 deletions src/actions/hover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1191,14 +1191,9 @@ pub mod test {
related_information_support: true,
};
let mut config = config::Config::default();
let cur_dir = env::current_dir().unwrap();
let target_dir = env::var("CARGO_TARGET_DIR")
.map(|s| Path::new(&s).to_owned())
.unwrap_or_else(|_| cur_dir.join("target"));

let working_dir = target_dir.join("tests").join("hover").join("working_dir");

config.target_dir = config::Inferrable::Specified(Some(working_dir.clone()));
let temp_dir = tempfile::tempdir().unwrap().into_path();
config.target_dir = config::Inferrable::Specified(Some(temp_dir.clone()));

let config = Arc::new(Mutex::new(config));
let analysis = Arc::new(analysis::AnalysisHost::new(analysis::Target::Debug));
Expand All @@ -1220,7 +1215,7 @@ pub mod test {
TooltipTestHarness {
ctx,
project_dir,
working_dir,
working_dir: temp_dir
}
}

Expand Down Expand Up @@ -2056,7 +2051,6 @@ pub mod test {
fn test_tooltip() -> Result<(), Box<dyn std::error::Error>> {
let _ = env_logger::try_init();
use self::test::{LineOutput, Test, TooltipTestHarness};
use std::env;

let tests = vec![
Test::new("test_tooltip_01.rs", 13, 11),
Expand Down Expand Up @@ -2112,14 +2106,11 @@ pub mod test {
Test::new("test_tooltip_mod_use_external.rs", 12, 12),
];

let cwd = env::current_dir()?;
let out = LineOutput::default();
let proj_dir = FIXTURES_DIR.join("hover");
let save_dir = cwd
.join("target")
.join("tests")
.join("hover")
.join("save_data");

let save_dir_guard = tempfile::tempdir().unwrap();
let save_dir = save_dir_guard.path().to_owned();
let load_dir = proj_dir.join("save_data");

let harness = TooltipTestHarness::new(proj_dir, &out);
Expand All @@ -2145,7 +2136,6 @@ pub mod test {
fn test_tooltip_std() -> Result<(), Box<dyn std::error::Error>> {
let _ = env_logger::try_init();
use self::test::{LineOutput, Test, TooltipTestHarness};
use std::env;

let tests = vec![
// these test std stuff
Expand All @@ -2167,14 +2157,11 @@ pub mod test {
Test::new("test_tooltip_std.rs", 25, 25),
];

let cwd = env::current_dir()?;
let out = LineOutput::default();
let proj_dir = FIXTURES_DIR.join("hover");
let save_dir = cwd
.join("target")
.join("tests")
.join("hover")
.join("save_data");

let save_dir_guard = tempfile::tempdir().unwrap();
let save_dir = save_dir_guard.path().to_owned();
let load_dir = proj_dir.join("save_data");

let harness = TooltipTestHarness::new(proj_dir, &out);
Expand Down
13 changes: 3 additions & 10 deletions src/test/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use serde_json;
use walkdir::WalkDir;

lazy_static! {
static ref COUNTER: AtomicUsize = AtomicUsize::new(0);
static ref MANIFEST_DIR: &'static Path = Path::new(env!("CARGO_MANIFEST_DIR"));
pub static ref FIXTURES_DIR: PathBuf = MANIFEST_DIR.join("tests").join("fixtures");
}
Expand All @@ -51,24 +50,18 @@ impl Environment {
let scratchpad_dir = build_scratchpad_from_fixture(fixture_dir)
.expect("Can't copy fixture files to scratchpad");

let target_dir = env::var("CARGO_TARGET_DIR")
.map(|s| Path::new(&s).to_owned())
.unwrap_or_else(|_| MANIFEST_DIR.join("target"));

let working_dir = target_dir
.join("tests")
.join(format!("{}", COUNTER.fetch_add(1, Ordering::Relaxed)));
let target_dir = scratchpad_dir.join("target");

let mut config = Config::default();
config.target_dir = Inferrable::Specified(Some(working_dir.clone()));
config.target_dir = Inferrable::Specified(Some(target_dir.clone()));
config.unstable_features = true;

let cache = Cache::new(scratchpad_dir);

Self {
config: Some(config),
cache,
target_path: working_dir,
target_path: target_dir,
}
}
}
Expand Down