diff options
author | Aleksey Kladov <[email protected]> | 2021-06-15 20:38:21 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-06-15 20:38:21 +0100 |
commit | 2eef66a2ed9b02962511e38c620efb23e2d65b00 (patch) | |
tree | 40f9d94f858e7467811e0da873bfbf9a3b53c35a /crates/test_utils | |
parent | 09c4013ec01b5eafc436cb9369a81036297379c1 (diff) |
internal: sanity-check minicore flags
Diffstat (limited to 'crates/test_utils')
-rw-r--r-- | crates/test_utils/src/fixture.rs | 9 | ||||
-rw-r--r-- | crates/test_utils/src/minicore.rs | 4 |
2 files changed, 11 insertions, 2 deletions
diff --git a/crates/test_utils/src/fixture.rs b/crates/test_utils/src/fixture.rs index 535892f3f..779146084 100644 --- a/crates/test_utils/src/fixture.rs +++ b/crates/test_utils/src/fixture.rs | |||
@@ -276,6 +276,7 @@ impl MiniCore { | |||
276 | } | 276 | } |
277 | 277 | ||
278 | let mut curr_region = ""; | 278 | let mut curr_region = ""; |
279 | let mut seen_regions = Vec::new(); | ||
279 | for line in lines { | 280 | for line in lines { |
280 | let trimmed = line.trim(); | 281 | let trimmed = line.trim(); |
281 | if let Some(region) = trimmed.strip_prefix("// region:") { | 282 | if let Some(region) = trimmed.strip_prefix("// region:") { |
@@ -288,6 +289,7 @@ impl MiniCore { | |||
288 | curr_region = ""; | 289 | curr_region = ""; |
289 | continue; | 290 | continue; |
290 | } | 291 | } |
292 | seen_regions.push(curr_region); | ||
291 | 293 | ||
292 | let mut flag = curr_region; | 294 | let mut flag = curr_region; |
293 | if let Some(idx) = trimmed.find("// :") { | 295 | if let Some(idx) = trimmed.find("// :") { |
@@ -305,6 +307,13 @@ impl MiniCore { | |||
305 | buf.push_str(line) | 307 | buf.push_str(line) |
306 | } | 308 | } |
307 | } | 309 | } |
310 | |||
311 | for flag in &self.valid_flags { | ||
312 | if !seen_regions.iter().any(|it| it == flag) { | ||
313 | panic!("unused minicore flag: {:?}", flag); | ||
314 | } | ||
315 | } | ||
316 | |||
308 | buf | 317 | buf |
309 | } | 318 | } |
310 | } | 319 | } |
diff --git a/crates/test_utils/src/minicore.rs b/crates/test_utils/src/minicore.rs index f9f14b7df..8c0d122dc 100644 --- a/crates/test_utils/src/minicore.rs +++ b/crates/test_utils/src/minicore.rs | |||
@@ -64,7 +64,7 @@ pub mod ops { | |||
64 | pub use self::deref::Deref; | 64 | pub use self::deref::Deref; |
65 | // endregion:deref | 65 | // endregion:deref |
66 | 66 | ||
67 | //region:range | 67 | // region:range |
68 | mod range { | 68 | mod range { |
69 | #[lang = "RangeFull"] | 69 | #[lang = "RangeFull"] |
70 | pub struct RangeFull; | 70 | pub struct RangeFull; |
@@ -99,7 +99,7 @@ pub mod ops { | |||
99 | } | 99 | } |
100 | pub use self::range::{Range, RangeFrom, RangeFull, RangeTo}; | 100 | pub use self::range::{Range, RangeFrom, RangeFull, RangeTo}; |
101 | pub use self::range::{RangeInclusive, RangeToInclusive}; | 101 | pub use self::range::{RangeInclusive, RangeToInclusive}; |
102 | //endregion:range | 102 | // endregion:range |
103 | } | 103 | } |
104 | 104 | ||
105 | // region:slice | 105 | // region:slice |