Skip to content

Commit 0194adb

Browse files
bors[bot]matklad
andcommitted
Merge #1585
1585: move syntax tests to unit tests r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
2 parents bf30304 + 459241f commit 0194adb

File tree

512 files changed

+13
-16
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

512 files changed

+13
-16
lines changed

.travis.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
cache: cargo
22
before_cache:
3-
# ask Cargo to clean up artifacts for workspace crates
4-
- cargo clean $(printf -- '--package %s ' $(cd crates; ls))
5-
# Cargo doesn't clean up depinfo itself, do it manually
6-
- find ./target/debug -maxdepth 2 -iname '*.d' -delete
3+
- find ./target/debug -maxdepth 1 -type f -delete
4+
- rm -fr ./target/debug/{deps,.fingerprint}/{*ra_*,*heavy_test*,*gen_lsp*,*thread_worker*}
75
- rm -f ./target/.rustc_info.json
86

97
matrix:

crates/ra_syntax/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ mod syntax_error;
2424
mod parsing;
2525
mod validation;
2626
mod ptr;
27+
#[cfg(test)]
28+
mod tests;
2729

2830
pub mod algo;
2931
pub mod ast;

crates/ra_syntax/tests/test.rs renamed to crates/ra_syntax/src/tests.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
extern crate ra_syntax;
2-
extern crate test_utils;
3-
extern crate walkdir;
4-
51
use std::{
62
fmt::Write,
73
path::{Component, PathBuf},
84
};
95

10-
use ra_syntax::{fuzz, SourceFile};
116
use test_utils::{collect_tests, dir_tests, project_dir, read_text};
127

8+
use crate::{fuzz, SourceFile};
9+
1310
#[test]
1411
fn lexer_tests() {
1512
dir_tests(&test_data_dir(), &["lexer"], |text, _| {
16-
let tokens = ra_syntax::tokenize(text);
13+
let tokens = crate::tokenize(text);
1714
dump_tokens(&tokens, text)
1815
})
1916
}
@@ -25,7 +22,7 @@ fn parser_tests() {
2522
let errors = parse.errors();
2623
assert_eq!(
2724
errors,
28-
&[] as &[ra_syntax::SyntaxError],
25+
&[] as &[crate::SyntaxError],
2926
"There should be no errors in the file {:?}",
3027
path.display(),
3128
);
@@ -67,7 +64,7 @@ fn self_hosting_parsing() {
6764
.filter_entry(|entry| {
6865
!entry.path().components().any(|component| {
6966
// Get all files which are not in the crates/ra_syntax/tests/data folder
70-
component == Component::Normal(OsStr::new("data"))
67+
component == Component::Normal(OsStr::new("test_data"))
7168
})
7269
})
7370
.map(|e| e.unwrap())
@@ -87,10 +84,10 @@ fn self_hosting_parsing() {
8784
}
8885

8986
fn test_data_dir() -> PathBuf {
90-
project_dir().join("crates/ra_syntax/tests/data")
87+
project_dir().join("crates/ra_syntax/test_data")
9188
}
9289

93-
fn dump_tokens(tokens: &[ra_syntax::Token], text: &str) -> String {
90+
fn dump_tokens(tokens: &[crate::Token], text: &str) -> String {
9491
let mut acc = String::new();
9592
let mut offset = 0;
9693
for token in tokens {

0 commit comments

Comments
 (0)