From 773f3afd3628ed646fee561cb2a09a28454e72c8 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Tue, 10 Mar 2020 02:02:43 +0800 Subject: Add fixture meta for single file fixture --- crates/test_utils/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'crates/test_utils/src') diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs index 69deddcb5..2432177b4 100644 --- a/crates/test_utils/src/lib.rs +++ b/crates/test_utils/src/lib.rs @@ -202,6 +202,14 @@ pub fn parse_fixture(fixture: &str) -> Vec { res } +/// Same as `parse_fixture`, except it allow empty fixture +pub fn parse_single_fixture(fixture: &str) -> Option { + if !fixture.lines().any(|it| it.trim_start().starts_with("//-")) { + return None; + } + parse_fixture(fixture).into_iter().nth(0) +} + // Comparison functionality borrowed from cargo: /// Compare a line with an expected pattern. -- cgit v1.2.3