1 | #![cfg (syn_disable_nightly_tests)] |
2 | |
3 | use std::io::{self, Write}; |
4 | use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; |
5 | |
6 | const MSG: &str = "\ |
7 | ‖ |
8 | ‖ WARNING: |
9 | ‖ This is not a nightly compiler so not all tests were able to |
10 | ‖ run. Syn includes tests that compare Syn's parser against the |
11 | ‖ compiler's parser, which requires access to unstable librustc |
12 | ‖ data structures and a nightly compiler. |
13 | ‖ |
14 | " ; |
15 | |
16 | #[test] |
17 | fn notice() -> io::Result<()> { |
18 | let header = "WARNING" ; |
19 | let index_of_header = MSG.find(header).unwrap(); |
20 | let before = &MSG[..index_of_header]; |
21 | let after = &MSG[index_of_header + header.len()..]; |
22 | |
23 | let mut stderr = StandardStream::stderr(ColorChoice::Auto); |
24 | stderr.set_color(ColorSpec::new().set_fg(Some(Color::Yellow)))?; |
25 | write!(&mut stderr, "{}" , before)?; |
26 | stderr.set_color(ColorSpec::new().set_bold(true).set_fg(Some(Color::Yellow)))?; |
27 | write!(&mut stderr, "{}" , header)?; |
28 | stderr.set_color(ColorSpec::new().set_fg(Some(Color::Yellow)))?; |
29 | write!(&mut stderr, "{}" , after)?; |
30 | stderr.reset()?; |
31 | |
32 | Ok(()) |
33 | } |
34 | |