mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
Disable all source-gen tests at compile time
This commit is contained in:
parent
5f3f4284dd
commit
0bffdf2627
@ -26,3 +26,6 @@ hir = { path = "../hir", version = "0.0.0" }
|
|||||||
test-utils = { path = "../test-utils" }
|
test-utils = { path = "../test-utils" }
|
||||||
sourcegen = { path = "../sourcegen" }
|
sourcegen = { path = "../sourcegen" }
|
||||||
expect-test = "1.4.0"
|
expect-test = "1.4.0"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
in-rust-tree = []
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
//! Generates `assists.md` documentation.
|
//! Generates `assists.md` documentation.
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
use std::{fmt, fs, path::Path};
|
use std::{fmt, fs, path::Path};
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
use test_utils::project_root;
|
use test_utils::project_root;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
#[test]
|
#[test]
|
||||||
fn sourcegen_assists_docs() {
|
fn sourcegen_assists_docs() {
|
||||||
let assists = Assist::collect();
|
let assists = Assist::collect();
|
||||||
@ -59,6 +62,8 @@ r#####"
|
|||||||
fs::write(dst, contents).unwrap();
|
fs::write(dst, contents).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct Section {
|
struct Section {
|
||||||
doc: String,
|
doc: String,
|
||||||
@ -66,6 +71,7 @@ struct Section {
|
|||||||
after: String,
|
after: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct Assist {
|
struct Assist {
|
||||||
id: String,
|
id: String,
|
||||||
@ -73,6 +79,7 @@ struct Assist {
|
|||||||
sections: Vec<Section>,
|
sections: Vec<Section>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
impl Assist {
|
impl Assist {
|
||||||
fn collect() -> Vec<Assist> {
|
fn collect() -> Vec<Assist> {
|
||||||
let handlers_dir = project_root().join("crates/ide-assists/src/handlers");
|
let handlers_dir = project_root().join("crates/ide-assists/src/handlers");
|
||||||
@ -104,9 +111,11 @@ impl Assist {
|
|||||||
while lines.peek().is_some() {
|
while lines.peek().is_some() {
|
||||||
let doc = take_until(lines.by_ref(), "```").trim().to_string();
|
let doc = take_until(lines.by_ref(), "```").trim().to_string();
|
||||||
assert!(
|
assert!(
|
||||||
(doc.chars().next().unwrap().is_ascii_uppercase() && doc.ends_with('.')) || assist.sections.len() > 0,
|
(doc.chars().next().unwrap().is_ascii_uppercase() && doc.ends_with('.'))
|
||||||
|
|| assist.sections.len() > 0,
|
||||||
"\n\n{}: assist docs should be proper sentences, with capitalization and a full stop at the end.\n\n{}\n\n",
|
"\n\n{}: assist docs should be proper sentences, with capitalization and a full stop at the end.\n\n{}\n\n",
|
||||||
&assist.id, doc,
|
&assist.id,
|
||||||
|
doc,
|
||||||
);
|
);
|
||||||
|
|
||||||
let before = take_until(lines.by_ref(), "```");
|
let before = take_until(lines.by_ref(), "```");
|
||||||
@ -135,6 +144,7 @@ impl Assist {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
impl fmt::Display for Assist {
|
impl fmt::Display for Assist {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let _ = writeln!(
|
let _ = writeln!(
|
||||||
@ -169,6 +179,7 @@ impl fmt::Display for Assist {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
fn hide_hash_comments(text: &str) -> String {
|
fn hide_hash_comments(text: &str) -> String {
|
||||||
text.split('\n') // want final newline
|
text.split('\n') // want final newline
|
||||||
.filter(|&it| !(it.starts_with("# ") || it == "#"))
|
.filter(|&it| !(it.starts_with("# ") || it == "#"))
|
||||||
@ -176,6 +187,7 @@ fn hide_hash_comments(text: &str) -> String {
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
fn reveal_hash_comments(text: &str) -> String {
|
fn reveal_hash_comments(text: &str) -> String {
|
||||||
text.split('\n') // want final newline
|
text.split('\n') // want final newline
|
||||||
.map(|it| {
|
.map(|it| {
|
||||||
|
@ -29,3 +29,6 @@ expect-test = "1.4.0"
|
|||||||
|
|
||||||
test-utils = { path = "../test-utils" }
|
test-utils = { path = "../test-utils" }
|
||||||
sourcegen = { path = "../sourcegen" }
|
sourcegen = { path = "../sourcegen" }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
in-rust-tree = []
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
//! Generates `assists.md` documentation.
|
//! Generates `assists.md` documentation.
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
use std::{fmt, fs, io, path::PathBuf};
|
use std::{fmt, fs, io, path::PathBuf};
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
use sourcegen::project_root;
|
use sourcegen::project_root;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
#[test]
|
#[test]
|
||||||
fn sourcegen_diagnostic_docs() {
|
fn sourcegen_diagnostic_docs() {
|
||||||
let diagnostics = Diagnostic::collect().unwrap();
|
let diagnostics = Diagnostic::collect().unwrap();
|
||||||
@ -14,6 +17,7 @@ fn sourcegen_diagnostic_docs() {
|
|||||||
fs::write(&dst, &contents).unwrap();
|
fs::write(&dst, &contents).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct Diagnostic {
|
struct Diagnostic {
|
||||||
id: String,
|
id: String,
|
||||||
@ -21,6 +25,7 @@ struct Diagnostic {
|
|||||||
doc: String,
|
doc: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
impl Diagnostic {
|
impl Diagnostic {
|
||||||
fn collect() -> io::Result<Vec<Diagnostic>> {
|
fn collect() -> io::Result<Vec<Diagnostic>> {
|
||||||
let handlers_dir = project_root().join("crates/ide-diagnostics/src/handlers");
|
let handlers_dir = project_root().join("crates/ide-diagnostics/src/handlers");
|
||||||
@ -51,6 +56,7 @@ impl Diagnostic {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
fn is_valid_diagnostic_name(diagnostic: &str) -> Result<(), String> {
|
fn is_valid_diagnostic_name(diagnostic: &str) -> Result<(), String> {
|
||||||
let diagnostic = diagnostic.trim();
|
let diagnostic = diagnostic.trim();
|
||||||
if diagnostic.find(char::is_whitespace).is_some() {
|
if diagnostic.find(char::is_whitespace).is_some() {
|
||||||
@ -66,6 +72,7 @@ fn is_valid_diagnostic_name(diagnostic: &str) -> Result<(), String> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
impl fmt::Display for Diagnostic {
|
impl fmt::Display for Diagnostic {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
writeln!(f, "=== {}\n**Source:** {}\n{}", self.id, self.location, self.doc)
|
writeln!(f, "=== {}\n**Source:** {}\n{}", self.id, self.location, self.doc)
|
||||||
|
@ -42,3 +42,6 @@ toolchain = { path = "../toolchain", version = "0.0.0" }
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
test-utils = { path = "../test-utils" }
|
test-utils = { path = "../test-utils" }
|
||||||
expect-test = "1.4.0"
|
expect-test = "1.4.0"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
in-rust-tree = ["ide-assists/in-rust-tree", "ide-diagnostics/in-rust-tree"]
|
||||||
|
@ -84,4 +84,9 @@ mbe = { path = "../mbe" }
|
|||||||
[features]
|
[features]
|
||||||
jemalloc = ["jemallocator", "profile/jemalloc"]
|
jemalloc = ["jemallocator", "profile/jemalloc"]
|
||||||
force-always-assert = ["always-assert/force"]
|
force-always-assert = ["always-assert/force"]
|
||||||
in-rust-tree = ["proc-macro-srv/sysroot-abi"]
|
in-rust-tree = [
|
||||||
|
"proc-macro-srv/sysroot-abi",
|
||||||
|
"sourcegen/in-rust-tree",
|
||||||
|
"ide/in-rust-tree",
|
||||||
|
"syntax/in-rust-tree"
|
||||||
|
]
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
//! Generates `assists.md` documentation.
|
//! Generates `assists.md` documentation.
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
use std::{fmt, fs, io, path::PathBuf};
|
use std::{fmt, fs, io, path::PathBuf};
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
#[test]
|
#[test]
|
||||||
fn sourcegen_feature_docs() {
|
fn sourcegen_feature_docs() {
|
||||||
let features = Feature::collect().unwrap();
|
let features = Feature::collect().unwrap();
|
||||||
@ -17,6 +19,7 @@ fn sourcegen_feature_docs() {
|
|||||||
fs::write(&dst, &contents).unwrap();
|
fs::write(&dst, &contents).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct Feature {
|
struct Feature {
|
||||||
id: String,
|
id: String,
|
||||||
@ -24,6 +27,7 @@ struct Feature {
|
|||||||
doc: String,
|
doc: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
impl Feature {
|
impl Feature {
|
||||||
fn collect() -> io::Result<Vec<Feature>> {
|
fn collect() -> io::Result<Vec<Feature>> {
|
||||||
let crates_dir = sourcegen::project_root().join("crates");
|
let crates_dir = sourcegen::project_root().join("crates");
|
||||||
@ -54,6 +58,7 @@ impl Feature {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
fn is_valid_feature_name(feature: &str) -> Result<(), String> {
|
fn is_valid_feature_name(feature: &str) -> Result<(), String> {
|
||||||
'word: for word in feature.split_whitespace() {
|
'word: for word in feature.split_whitespace() {
|
||||||
for short in ["to", "and"] {
|
for short in ["to", "and"] {
|
||||||
@ -73,6 +78,7 @@ fn is_valid_feature_name(feature: &str) -> Result<(), String> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
impl fmt::Display for Feature {
|
impl fmt::Display for Feature {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
writeln!(f, "=== {}\n**Source:** {}\n{}", self.id, self.location, self.doc)
|
writeln!(f, "=== {}\n**Source:** {}\n{}", self.id, self.location, self.doc)
|
||||||
|
@ -3,8 +3,12 @@ use std::{
|
|||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
use xshell::{cmd, Shell};
|
use xshell::Shell;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
|
use xshell::cmd;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
#[test]
|
#[test]
|
||||||
fn check_code_formatting() {
|
fn check_code_formatting() {
|
||||||
let sh = &Shell::new().unwrap();
|
let sh = &Shell::new().unwrap();
|
||||||
@ -168,6 +172,7 @@ See https://github.com/rust-lang/rust-clippy/issues/5537 for discussion.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
#[test]
|
#[test]
|
||||||
fn check_licenses() {
|
fn check_licenses() {
|
||||||
let sh = &Shell::new().unwrap();
|
let sh = &Shell::new().unwrap();
|
||||||
|
@ -11,3 +11,6 @@ doctest = false
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
xshell = "0.2.2"
|
xshell = "0.2.2"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
in-rust-tree = []
|
||||||
|
@ -34,3 +34,6 @@ ungrammar = "1.16.1"
|
|||||||
|
|
||||||
test-utils = { path = "../test-utils" }
|
test-utils = { path = "../test-utils" }
|
||||||
sourcegen = { path = "../sourcegen" }
|
sourcegen = { path = "../sourcegen" }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
in-rust-tree = []
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
mod sourcegen_ast;
|
|
||||||
mod ast_src;
|
mod ast_src;
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
|
mod sourcegen_ast;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
fs,
|
fs,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
//! Defines input for code generation process.
|
//! Defines input for code generation process.
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
pub(crate) struct KindsSrc<'a> {
|
pub(crate) struct KindsSrc<'a> {
|
||||||
pub(crate) punct: &'a [(&'a str, &'a str)],
|
pub(crate) punct: &'a [(&'a str, &'a str)],
|
||||||
pub(crate) keywords: &'a [&'a str],
|
pub(crate) keywords: &'a [&'a str],
|
||||||
@ -9,6 +10,7 @@ pub(crate) struct KindsSrc<'a> {
|
|||||||
pub(crate) nodes: &'a [&'a str],
|
pub(crate) nodes: &'a [&'a str],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
pub(crate) const KINDS_SRC: KindsSrc<'_> = KindsSrc {
|
pub(crate) const KINDS_SRC: KindsSrc<'_> = KindsSrc {
|
||||||
punct: &[
|
punct: &[
|
||||||
(";", "SEMICOLON"),
|
(";", "SEMICOLON"),
|
||||||
@ -216,6 +218,7 @@ pub(crate) const KINDS_SRC: KindsSrc<'_> = KindsSrc {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
pub(crate) struct AstSrc {
|
pub(crate) struct AstSrc {
|
||||||
pub(crate) tokens: Vec<String>,
|
pub(crate) tokens: Vec<String>,
|
||||||
@ -223,6 +226,7 @@ pub(crate) struct AstSrc {
|
|||||||
pub(crate) enums: Vec<AstEnumSrc>,
|
pub(crate) enums: Vec<AstEnumSrc>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) struct AstNodeSrc {
|
pub(crate) struct AstNodeSrc {
|
||||||
pub(crate) doc: Vec<String>,
|
pub(crate) doc: Vec<String>,
|
||||||
@ -231,18 +235,21 @@ pub(crate) struct AstNodeSrc {
|
|||||||
pub(crate) fields: Vec<Field>,
|
pub(crate) fields: Vec<Field>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub(crate) enum Field {
|
pub(crate) enum Field {
|
||||||
Token(String),
|
Token(String),
|
||||||
Node { name: String, ty: String, cardinality: Cardinality },
|
Node { name: String, ty: String, cardinality: Cardinality },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub(crate) enum Cardinality {
|
pub(crate) enum Cardinality {
|
||||||
Optional,
|
Optional,
|
||||||
Many,
|
Many,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "in-rust-tree"))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) struct AstEnumSrc {
|
pub(crate) struct AstEnumSrc {
|
||||||
pub(crate) doc: Vec<String>,
|
pub(crate) doc: Vec<String>,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user