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

Split RLS into bin/lib and move some tests to Cargo integration test format #1210

Merged
merged 14 commits into from
Jan 8, 2019
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
.idea

target
test_data/Cargo.lock
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ categories = ["development-tools"]

build = "build.rs"

[lib]
name = "rls"
doctest = false

[[bin]]
name = "rls"
test = false

[dependencies]
cargo = { git = "https://github.com/rust-lang/cargo", rev = "2a9f16da7ffc4877aacf7547bac705f0d82de2d6" }
cargo_metadata = "0.6"
Expand Down
7 changes: 7 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::path::Path;
use std::env;

fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-env-changed=CFG_RELEASE_CHANNEL");
Expand All @@ -20,4 +23,8 @@ fn main() {
"cargo:rustc-env=COMMIT_DATE={}",
rustc_tools_util::get_commit_date().unwrap_or_default()
);
println!(
"cargo:rustc-env=FIXTURES_DIR={}",
Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap()).join("tests/fixtures").display()
);
}
9 changes: 6 additions & 3 deletions src/actions/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,18 @@ impl IsWithin for Range {

/// Tests for formatted messages from the compilers json output
/// run cargo with `--message-format=json` to generate the json for new tests and add .json
/// message files to '$(crate::test::FIXTURES_DIR)/compiler_message/'
/// message files to '$FIXTURES_DIR/compiler_message/'
#[cfg(test)]
mod diagnostic_message_test {
use super::*;
use languageserver_types::Position;
pub(super) use crate::test::FIXTURES_DIR;

pub(super) fn fixtures_dir() -> &'static Path {
Path::new(env!("FIXTURES_DIR"))
}

pub(super) fn read_fixture(path: impl AsRef<Path>) -> String {
std::fs::read_to_string(FIXTURES_DIR.join(path.as_ref())).unwrap()
std::fs::read_to_string(fixtures_dir().join(path.as_ref())).unwrap()
}

pub(super) fn parse_compiler_message(
Expand Down
Loading