David Tolnay | 3f7d9d3 | 2019-03-10 00:14:28 -0800 | [diff] [blame] | 1 | #![cfg(syn_disable_nightly_tests)] |
| 2 | |
David Tolnay | a1d0bfe | 2019-05-08 13:57:13 -0700 | [diff] [blame^] | 3 | extern crate termcolor; |
David Tolnay | 3f7d9d3 | 2019-03-10 00:14:28 -0800 | [diff] [blame] | 4 | |
David Tolnay | a1d0bfe | 2019-05-08 13:57:13 -0700 | [diff] [blame^] | 5 | use std::io::{self, Write}; |
| 6 | use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; |
David Tolnay | 3f7d9d3 | 2019-03-10 00:14:28 -0800 | [diff] [blame] | 7 | |
David Tolnay | a1d0bfe | 2019-05-08 13:57:13 -0700 | [diff] [blame^] | 8 | const MSG: &str = "\ |
David Tolnay | 3f7d9d3 | 2019-03-10 00:14:28 -0800 | [diff] [blame] | 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] |
David Tolnay | a1d0bfe | 2019-05-08 13:57:13 -0700 | [diff] [blame^] | 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(()) |
David Tolnay | 3f7d9d3 | 2019-03-10 00:14:28 -0800 | [diff] [blame] | 35 | } |