Skip to content

Commit 51c1edc

Browse files
committed
Make everything work without the rustc feature
1 parent 00762eb commit 51c1edc

File tree

7 files changed

+51
-12
lines changed

7 files changed

+51
-12
lines changed

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
- name: Run unit tests
6060
run: cargo test --verbose
6161
- name: Test no-rustc mode
62-
run: cargo check --no-default-features
62+
run: cargo test --no-default-features
6363

6464
build-std:
6565
strategy:

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ features = ["capture-spantrace"]
4646
[[test]]
4747
name = "integration"
4848
harness = false
49+
required-features = ["rustc"]
4950

5051
[[test]]
5152
name = "build_std"

examples/rustc_basic.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
#[cfg(feature = "rustc")]
12
use std::sync::atomic::Ordering;
3+
#[cfg(feature = "rustc")]
24
use ui_test::{run_tests, Config};
35

6+
#[cfg(feature = "rustc")]
47
fn main() -> ui_test::color_eyre::Result<()> {
58
let config = Config::rustc("examples_tests/rustc_basic");
69
let abort_check = config.abort_check.clone();
@@ -11,3 +14,8 @@ fn main() -> ui_test::color_eyre::Result<()> {
1114
// `.stderr` files.
1215
run_tests(config)
1316
}
17+
18+
#[cfg(not(feature = "rustc"))]
19+
fn main() -> ui_test::color_eyre::Result<()> {
20+
Ok(())
21+
}

src/config.rs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use regex::bytes::Regex;
2-
#[cfg(feature = "rustc")]
32
use spanned::Spanned;
43

54
#[cfg(feature = "rustc")]
@@ -70,6 +69,36 @@ pub struct Config {
7069
}
7170

7271
impl Config {
72+
/// Create a blank configuration that doesn't do anything interesting
73+
pub fn dummy() -> Self {
74+
let mut comment_defaults = Comments::default();
75+
comment_defaults.base().require_annotations = Spanned::dummy(true).into();
76+
Self {
77+
host: Default::default(),
78+
target: Default::default(),
79+
root_dir: Default::default(),
80+
program: CommandBuilder::cmd(""),
81+
output_conflict_handling: OutputConflictHandling::Error,
82+
bless_command: Default::default(),
83+
out_dir: Default::default(),
84+
skip_files: Default::default(),
85+
filter_files: Default::default(),
86+
threads: Default::default(),
87+
list: Default::default(),
88+
run_only_ignored: Default::default(),
89+
filter_exact: Default::default(),
90+
comment_defaults,
91+
comment_start: "//",
92+
custom_comments: Default::default(),
93+
diagnostic_extractor: |_, _| Diagnostics {
94+
rendered: Default::default(),
95+
messages: Default::default(),
96+
messages_from_unknown_file_or_line: Default::default(),
97+
},
98+
abort_check: Default::default(),
99+
}
100+
}
101+
73102
/// Create a configuration for testing the output of running
74103
/// `rustc` on the test files.
75104
#[cfg(feature = "rustc")]

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use status_emitter::RevisionStyle;
2525
use status_emitter::{StatusEmitter, TestStatus};
2626
use std::collections::VecDeque;
2727
use std::path::Path;
28+
#[cfg(feature = "rustc")]
2829
use std::process::Command;
2930
use std::sync::atomic::Ordering;
3031
use std::sync::Arc;

src/parser/tests.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn main() {
4343
bytes: 0..s.len(),
4444
},
4545
),
46-
&Config::rustc(""),
46+
&Config::dummy(),
4747
)
4848
.unwrap();
4949
println!("parsed comments: {:#?}", comments);
@@ -79,7 +79,7 @@ fn main() {
7979
bytes: 0..s.len(),
8080
},
8181
),
82-
&Config::rustc(""),
82+
&Config::dummy(),
8383
)
8484
.unwrap();
8585
println!("parsed comments: {:#?}", comments);
@@ -109,7 +109,7 @@ fn main() {
109109
bytes: 0..s.len(),
110110
},
111111
),
112-
&Config::rustc(""),
112+
&Config::dummy(),
113113
)
114114
.unwrap_err();
115115
println!("parsed comments: {:#?}", errors);
@@ -137,7 +137,7 @@ use std::mem;
137137
bytes: 0..s.len(),
138138
},
139139
),
140-
&Config::rustc(""),
140+
&Config::dummy(),
141141
)
142142
.unwrap();
143143
println!("parsed comments: {:#?}", comments);
@@ -163,7 +163,7 @@ use std::mem;
163163
bytes: 0..s.len(),
164164
},
165165
),
166-
&Config::rustc(""),
166+
&Config::dummy(),
167167
)
168168
.unwrap();
169169
println!("parsed comments: {:#?}", comments);
@@ -189,7 +189,7 @@ use std::mem;
189189
bytes: 0..s.len(),
190190
},
191191
),
192-
&Config::rustc(""),
192+
&Config::dummy(),
193193
)
194194
.unwrap_err();
195195
println!("parsed comments: {:#?}", errors);
@@ -223,7 +223,7 @@ use std::mem;
223223
bytes: 0..s.len(),
224224
},
225225
),
226-
&Config::rustc(""),
226+
&Config::dummy(),
227227
)
228228
.unwrap_err();
229229
println!("parsed comments: {:#?}", errors);
@@ -247,7 +247,7 @@ fn parse_x86_64() {
247247
bytes: 0..s.len(),
248248
},
249249
),
250-
&Config::rustc(""),
250+
&Config::dummy(),
251251
)
252252
.unwrap();
253253
println!("parsed comments: {:#?}", comments);
@@ -271,7 +271,7 @@ fn parse_two_only_filters() {
271271
bytes: 0..s.len(),
272272
},
273273
),
274-
&Config::rustc(""),
274+
&Config::dummy(),
275275
)
276276
.unwrap();
277277
println!("parsed comments: {:#?}", comments);

src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fn config() -> Config {
1111
Config {
1212
root_dir: PathBuf::from("$RUSTROOT"),
1313
program: CommandBuilder::cmd("cake"),
14-
..Config::rustc(PathBuf::new())
14+
..Config::dummy()
1515
}
1616
}
1717

0 commit comments

Comments
 (0)