move syntax tests to unit tests
This commit is contained in:
parent
4d544fbf9b
commit
459241f272
512 changed files with 12 additions and 13 deletions
|
@ -1,7 +1,7 @@
|
||||||
cache: cargo
|
cache: cargo
|
||||||
before_cache:
|
before_cache:
|
||||||
- find ./target/debug -maxdepth 1 -type f -delete
|
- find ./target/debug -maxdepth 1 -type f -delete
|
||||||
- rm -fr ./target/debug/{deps,.fingerprint}/{*ra_*,*test*,*gen_lsp*,*thread_worker*}
|
- rm -fr ./target/debug/{deps,.fingerprint}/{*ra_*,*heavy_test*,*gen_lsp*,*thread_worker*}
|
||||||
- rm -f ./target/.rustc_info.json
|
- rm -f ./target/.rustc_info.json
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
|
|
|
@ -24,6 +24,8 @@ mod syntax_error;
|
||||||
mod parsing;
|
mod parsing;
|
||||||
mod validation;
|
mod validation;
|
||||||
mod ptr;
|
mod ptr;
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests;
|
||||||
|
|
||||||
pub mod algo;
|
pub mod algo;
|
||||||
pub mod ast;
|
pub mod ast;
|
||||||
|
|
|
@ -1,19 +1,16 @@
|
||||||
extern crate ra_syntax;
|
|
||||||
extern crate test_utils;
|
|
||||||
extern crate walkdir;
|
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
fmt::Write,
|
fmt::Write,
|
||||||
path::{Component, PathBuf},
|
path::{Component, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
use ra_syntax::{fuzz, SourceFile};
|
|
||||||
use test_utils::{collect_tests, dir_tests, project_dir, read_text};
|
use test_utils::{collect_tests, dir_tests, project_dir, read_text};
|
||||||
|
|
||||||
|
use crate::{fuzz, SourceFile};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lexer_tests() {
|
fn lexer_tests() {
|
||||||
dir_tests(&test_data_dir(), &["lexer"], |text, _| {
|
dir_tests(&test_data_dir(), &["lexer"], |text, _| {
|
||||||
let tokens = ra_syntax::tokenize(text);
|
let tokens = crate::tokenize(text);
|
||||||
dump_tokens(&tokens, text)
|
dump_tokens(&tokens, text)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -25,7 +22,7 @@ fn parser_tests() {
|
||||||
let errors = parse.errors();
|
let errors = parse.errors();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
errors,
|
errors,
|
||||||
&[] as &[ra_syntax::SyntaxError],
|
&[] as &[crate::SyntaxError],
|
||||||
"There should be no errors in the file {:?}",
|
"There should be no errors in the file {:?}",
|
||||||
path.display(),
|
path.display(),
|
||||||
);
|
);
|
||||||
|
@ -67,7 +64,7 @@ fn self_hosting_parsing() {
|
||||||
.filter_entry(|entry| {
|
.filter_entry(|entry| {
|
||||||
!entry.path().components().any(|component| {
|
!entry.path().components().any(|component| {
|
||||||
// Get all files which are not in the crates/ra_syntax/tests/data folder
|
// Get all files which are not in the crates/ra_syntax/tests/data folder
|
||||||
component == Component::Normal(OsStr::new("data"))
|
component == Component::Normal(OsStr::new("test_data"))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.map(|e| e.unwrap())
|
.map(|e| e.unwrap())
|
||||||
|
@ -87,10 +84,10 @@ fn self_hosting_parsing() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_data_dir() -> PathBuf {
|
fn test_data_dir() -> PathBuf {
|
||||||
project_dir().join("crates/ra_syntax/tests/data")
|
project_dir().join("crates/ra_syntax/test_data")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dump_tokens(tokens: &[ra_syntax::Token], text: &str) -> String {
|
fn dump_tokens(tokens: &[crate::Token], text: &str) -> String {
|
||||||
let mut acc = String::new();
|
let mut acc = String::new();
|
||||||
let mut offset = 0;
|
let mut offset = 0;
|
||||||
for token in tokens {
|
for token in tokens {
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue