diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-03-10 16:46:21 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-03-10 16:46:21 +0000 |
commit | 6b9d66bbee865bd4337366f1540f8e5aa8d82c18 (patch) | |
tree | 8a7e50f9cef97fcadcd3832ff196010e03177068 /crates/test_utils | |
parent | 34bc0f4f55a9c2239d77b550b9bbd61b4eef6bb1 (diff) | |
parent | 95ba7da1abcd18b49c1a2dfc16c8d0e34c64ef45 (diff) |
Merge #3536
3536: Add get and set for `Env` r=matklad a=edwin0cheng
This PR add three things :
1. Add `get` and `set` in `Env`.
2. Implement fixture meta for `with_single_file`.
3. Add `env` meta in fixture.
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/test_utils')
-rw-r--r-- | crates/test_utils/src/lib.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs index 69deddcb5..a0d8f4d37 100644 --- a/crates/test_utils/src/lib.rs +++ b/crates/test_utils/src/lib.rs | |||
@@ -202,6 +202,19 @@ pub fn parse_fixture(fixture: &str) -> Vec<FixtureEntry> { | |||
202 | res | 202 | res |
203 | } | 203 | } |
204 | 204 | ||
205 | /// Same as `parse_fixture`, except it allow empty fixture | ||
206 | pub fn parse_single_fixture(fixture: &str) -> Option<FixtureEntry> { | ||
207 | if !fixture.lines().any(|it| it.trim_start().starts_with("//-")) { | ||
208 | return None; | ||
209 | } | ||
210 | |||
211 | let fixtures = parse_fixture(fixture); | ||
212 | if fixtures.len() > 1 { | ||
213 | panic!("too many fixtures"); | ||
214 | } | ||
215 | fixtures.into_iter().nth(0) | ||
216 | } | ||
217 | |||
205 | // Comparison functionality borrowed from cargo: | 218 | // Comparison functionality borrowed from cargo: |
206 | 219 | ||
207 | /// Compare a line with an expected pattern. | 220 | /// Compare a line with an expected pattern. |