Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

Commit bc1f019

Browse files
authored
Merge pull request #1415 from BGR360/filtering+issue-101696
2 parents 92cfad4 + 37f9de2 commit bc1f019

File tree

4 files changed

+45
-10
lines changed

4 files changed

+45
-10
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ Contributing to Glacier is fairly easy:
2121

2222
1. Check out [this list][ices] of bugs on the Rust issue tracker.
2323
2. Pick one.
24-
3. Create a file in `ices/` with the same digit as the bug.
24+
3. Create a file in `ices/` with the same number as the issue reporting the ICE.
2525
4. Copy the code that causes the ICE into your new file.
26-
5. (optional) Verify it works by running `rustup update nightly`, then `cargo run` to run the tests.
26+
5. (optional) Verify it works by running `rustup update nightly`, then
27+
`cargo run $ISSUE_NUMBER` to run your ICE.
2728
6. Send a pull request!
2829

2930
Note: Running this on Windows may give false positives and report some ICEs as fixed,

labeler/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fn main() {
1010
let mut tested_issue_list = glacier::discover("./ices")
1111
.unwrap()
1212
.into_iter()
13-
.map(|ice| ice.id())
13+
.map(|ice| ice.id().0)
1414
.collect::<Vec<_>>();
1515
tested_issue_list.sort_unstable();
1616
tested_issue_list.dedup();

src/lib.rs

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl ICE {
3333
Ok(Self { path, mode })
3434
}
3535

36-
pub fn id(&self) -> usize {
36+
pub fn id(&self) -> IssueId {
3737
let s = self
3838
.path
3939
.file_stem()
@@ -43,7 +43,7 @@ impl ICE {
4343
.unwrap();
4444
// Some files have names like 123-1.rs; only get the first part of it
4545
let s = s.split('-').next().unwrap();
46-
s.parse().unwrap()
46+
IssueId(s.parse().unwrap())
4747
}
4848

4949
fn test(self) -> Result<TestResult> {
@@ -80,6 +80,29 @@ impl ICE {
8080
}
8181
}
8282

83+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
84+
pub struct IssueId(pub usize);
85+
86+
/// Filters which ICEs should be tested.
87+
#[derive(Default)]
88+
pub struct Filter {
89+
ids: Vec<IssueId>,
90+
}
91+
92+
impl Filter {
93+
pub fn try_from_args(args: std::env::Args) -> Result<Self> {
94+
let ids = args
95+
.skip(1)
96+
.map(|arg| Ok(IssueId(arg.parse()?)))
97+
.collect::<Result<_>>()?;
98+
Ok(Self { ids })
99+
}
100+
101+
pub fn matches(&self, ice: &ICE) -> bool {
102+
self.ids.is_empty() || self.ids.contains(&ice.id())
103+
}
104+
}
105+
83106
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
84107
pub enum Outcome {
85108
NoError,
@@ -200,7 +223,9 @@ pub fn discover(dir: &str) -> Result<Vec<ICE>> {
200223
Ok(ices)
201224
}
202225

203-
pub fn test_all() -> Result<impl IndexedParallelIterator<Item = Result<TestResult>>> {
226+
pub fn test_all_matching_filter(
227+
filter: &Filter,
228+
) -> Result<impl IndexedParallelIterator<Item = Result<TestResult>>> {
204229
env::set_var("RUSTUP_TOOLCHAIN", "nightly");
205230

206231
let output = Command::new("rustc").arg("--version").output()?;
@@ -209,13 +234,21 @@ pub fn test_all() -> Result<impl IndexedParallelIterator<Item = Result<TestResul
209234
output.status.success(),
210235
"nightly toolchain is not installed, run `rustup install nightly`"
211236
);
212-
let ices = discover(ICES_PATH)?;
237+
let all_ices = discover(ICES_PATH)?;
238+
let ices_to_test: Vec<ICE> = all_ices
239+
.into_iter()
240+
.filter(|ice| filter.matches(ice))
241+
.collect();
213242

214243
eprintln!(
215244
"running {} tests for {}",
216-
ices.len(),
245+
ices_to_test.len(),
217246
String::from_utf8_lossy(&output.stdout)
218247
);
219248

220-
Ok(ices.into_par_iter().map(|ice| ice.test()))
249+
Ok(ices_to_test.into_par_iter().map(|ice| ice.test()))
250+
}
251+
252+
pub fn test_all() -> Result<impl IndexedParallelIterator<Item = Result<TestResult>>> {
253+
test_all_matching_filter(&Filter::default())
221254
}

src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use glacier::{Outcome, TestResult};
33
use rayon::prelude::*;
44

55
fn main() -> Result<()> {
6-
let failed = glacier::test_all()?
6+
let filter = glacier::Filter::try_from_args(std::env::args())?;
7+
let failed = glacier::test_all_matching_filter(&filter)?
78
.filter(|res| {
89
if let Ok(test) = res {
910
eprint!("{}", test.outcome_token());

0 commit comments

Comments
 (0)