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