Skip to content

Commit 19b04f2

Browse files
committed
test: add ui test for highlighter
1 parent 6dc3762 commit 19b04f2

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

‎compiler/rustc_driver_impl/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub mod args;
8686
pub mod pretty;
8787
#[macro_use]
8888
mod print;
89-
mod highlighter;
89+
pub mod highlighter;
9090
mod session_diagnostics;
9191

9292
// Keep the OS parts of this `cfg` in sync with the `cfg` on the `libc`
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//@ run-pass
2+
//@ check-run-results
3+
4+
#![feature(rustc_private)]
5+
use std::io::Write;
6+
extern crate rustc_driver;
7+
extern crate rustc_driver_impl;
8+
9+
use rustc_driver_impl::highlighter::highlight;
10+
11+
const TEST_INPUT: &str = "
12+
struct Foo;
13+
14+
fn baz(x: i32) {
15+
// A function
16+
}
17+
18+
fn main() {
19+
let foo = Foo;
20+
foo.bar();
21+
}
22+
";
23+
24+
fn main() {
25+
let mut buf = Vec::new();
26+
highlight(TEST_INPUT, &mut buf).unwrap();
27+
let mut stdout = std::io::stdout();
28+
stdout.write_all(&buf).unwrap();
29+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+

2+
struct Foo;
3+
4+
fn baz(x: i32) {
5+
// A function
6+
}
7+
8+
fn main() {
9+
let foo = Foo;
10+
foo.bar();
11+
}
12+


0 commit comments

Comments
 (0)