Skip to content

Don't run proc-macro-srv tests on the rust-analyzer repo #13286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 23, 2022
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
2 changes: 2 additions & 0 deletions crates/proc-macro-srv/src/abis/abi_sysroot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use proc_macro_api::ProcMacroKind;

use super::PanicMessage;

pub use ra_server::TokenStream;

pub(crate) struct Abi {
exported_macros: Vec<proc_macro::bridge::client::ProcMacro>,
}
Expand Down
11 changes: 9 additions & 2 deletions crates/proc-macro-srv/src/abis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ mod abi_sysroot;
include!(concat!(env!("OUT_DIR"), "/rustc_version.rs"));

// Used by `test/utils.rs`
#[cfg(test)]
pub(crate) use abi_1_63::TokenStream as TestTokenStream;
#[cfg(all(test, feature = "sysroot-abi"))]
pub(crate) use abi_sysroot::TokenStream as TestTokenStream;

use super::dylib::LoadProcMacroDylibError;
pub(crate) use abi_1_58::Abi as Abi_1_58;
Expand Down Expand Up @@ -144,3 +144,10 @@ impl Abi {
}
}
}

#[test]
fn test_version_check() {
let path = paths::AbsPathBuf::assert(crate::proc_macro_test_dylib_path());
let info = proc_macro_api::read_dylib_info(&path).unwrap();
assert!(info.version.1 >= 50);
}
9 changes: 7 additions & 2 deletions crates/proc-macro-srv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
mod dylib;
mod abis;

pub mod cli;

use std::{
collections::{hash_map::Entry, HashMap},
env,
Expand Down Expand Up @@ -149,7 +151,10 @@ impl EnvSnapshot {
}
}

pub mod cli;
#[cfg(all(feature = "sysroot-abi", test))]
mod tests;

#[cfg(test)]
mod tests;
pub fn proc_macro_test_dylib_path() -> std::path::PathBuf {
proc_macro_test::PROC_MACRO_TEST_LOCATION.into()
}
11 changes: 2 additions & 9 deletions crates/proc-macro-srv/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

#[macro_use]
mod utils;
use expect_test::expect;
use paths::AbsPathBuf;
use utils::*;

use expect_test::expect;

#[test]
fn test_derive_empty() {
assert_expand("DeriveEmpty", r#"struct S;"#, expect![[r#"SUBTREE $"#]]);
Expand Down Expand Up @@ -157,10 +157,3 @@ fn list_test_macros() {
DeriveError [CustomDerive]"#]]
.assert_eq(&res);
}

#[test]
fn test_version_check() {
let path = AbsPathBuf::assert(fixtures::proc_macro_test_dylib_path());
let info = proc_macro_api::read_dylib_info(&path).unwrap();
assert!(info.version.1 >= 50);
}
12 changes: 3 additions & 9 deletions crates/proc-macro-srv/src/tests/utils.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
//! utils used in proc-macro tests

use crate::dylib;
use crate::ProcMacroSrv;
use expect_test::Expect;
use std::str::FromStr;

pub mod fixtures {
pub fn proc_macro_test_dylib_path() -> std::path::PathBuf {
proc_macro_test::PROC_MACRO_TEST_LOCATION.into()
}
}
use crate::{dylib, proc_macro_test_dylib_path, ProcMacroSrv};

fn parse_string(code: &str) -> Option<crate::abis::TestTokenStream> {
// This is a bit strange. We need to parse a string into a token stream into
Expand All @@ -30,7 +24,7 @@ pub fn assert_expand_attr(macro_name: &str, ra_fixture: &str, attr_args: &str, e
}

fn assert_expand_impl(macro_name: &str, input: &str, attr: Option<&str>, expect: Expect) {
let path = fixtures::proc_macro_test_dylib_path();
let path = proc_macro_test_dylib_path();
let expander = dylib::Expander::new(&path).unwrap();
let fixture = parse_string(input).unwrap();
let attr = attr.map(|attr| parse_string(attr).unwrap().into_subtree());
Expand All @@ -40,7 +34,7 @@ fn assert_expand_impl(macro_name: &str, input: &str, attr: Option<&str>, expect:
}

pub(crate) fn list() -> Vec<String> {
let dylib_path = fixtures::proc_macro_test_dylib_path();
let dylib_path = proc_macro_test_dylib_path();
let mut srv = ProcMacroSrv::default();
let res = srv.list_macros(&dylib_path).unwrap();
res.into_iter().map(|(name, kind)| format!("{} [{:?}]", name, kind)).collect()
Expand Down
4 changes: 3 additions & 1 deletion crates/rust-analyzer/tests/slow-tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ mod tidy;

use std::{collections::HashMap, path::PathBuf, time::Instant};

use expect_test::expect;
use lsp_types::{
notification::DidOpenTextDocument,
request::{
Expand Down Expand Up @@ -821,7 +820,10 @@ fn main() {
}

#[test]
// FIXME: Re-enable once we can run proc-macro tests on rust-lang/rust-analyzer again
#[cfg(FALSE)]
fn resolve_proc_macro() {
use expect_test::expect;
if skip_slow_tests() {
return;
}
Expand Down