blob: a81b3df4d0a0734f077f821d049bdbab663256eb [file] [log] [blame]
David Tolnay3f7d9d32019-03-10 00:14:28 -08001#![cfg(syn_disable_nightly_tests)]
2
David Tolnaya1d0bfe2019-05-08 13:57:13 -07003extern crate termcolor;
David Tolnay3f7d9d32019-03-10 00:14:28 -08004
David Tolnaya1d0bfe2019-05-08 13:57:13 -07005use std::io::{self, Write};
6use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
David Tolnay3f7d9d32019-03-10 00:14:28 -08007
David Tolnaya1d0bfe2019-05-08 13:57:13 -07008const MSG: &str = "\
David Tolnay3f7d9d32019-03-10 00:14:28 -08009
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]
David Tolnaya1d0bfe2019-05-08 13:57:13 -070019fn 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(())
David Tolnay3f7d9d32019-03-10 00:14:28 -080035}