Skip to content

tests: Add lsif_contains_generated_constant test #18309

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

Closed
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
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/target/
target/
/dist/
crates/*/target
**/*.rs.bk
**/*.rs.pending-snap
.idea/*
Expand Down
7 changes: 7 additions & 0 deletions crates/rust-analyzer/tests/lsif-test-crate/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions crates/rust-analyzer/tests/lsif-test-crate/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "lsif-test-crate"
version = "0.0.0"
edition = "2021"
publish = false

[dependencies]

[workspace]
13 changes: 13 additions & 0 deletions crates/rust-analyzer/tests/lsif-test-crate/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#![allow(unused)]

macro_rules! generate_const_from_identifier(
($id:ident) => (
const _: () = { const $id: &str = "encoded_data"; };
)
);

generate_const_from_identifier!(REQ_001);
mod tests {
use super::*;
generate_const_from_identifier!(REQ_002);
}
32 changes: 32 additions & 0 deletions crates/rust-analyzer/tests/slow-tests/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use std::process::Command;

use test_utils::skip_slow_tests;

const RA_BIN: &str = "../../target/debug/rust-analyzer";

// If you choose to change the behavior of the lsif command and therefore
// modify or remove this test, please inform the ferrocene/needy maintainers by
// opening an issue at https://github.com/ferrocene/needy.
#[test]
fn lsif_contains_generated_constant() {
if skip_slow_tests() {
return;
}

// Arrange
let mut cmd = Command::new(RA_BIN);
cmd.args(["lsif", "tests/lsif-test-crate"]);

// Act
let output = cmd.output().unwrap();
let stdout = String::from_utf8(output.stdout).unwrap();

// Assert
assert!(stdout.contains("REQ_001"));
assert!(stdout.contains("lsif_test_crate"));

assert!(stdout.contains("REQ_002"));
assert!(stdout.contains("lsif_test_crate::tests"));

assert!(stdout.contains("encoded_data"));
}
1 change: 1 addition & 0 deletions crates/rust-analyzer/tests/slow-tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#![allow(clippy::disallowed_types)]

mod cli;
mod ratoml;
mod support;
mod testdir;
Expand Down