-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
180 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
feature_cant_emit_mir = | ||
could not emit unstable feature usage metrics: {$error} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use rustc_macros::Diagnostic; | ||
use std::io; | ||
|
||
#[derive(Diagnostic)] | ||
pub(crate) enum CantEmitFeatureUsageMetrics { | ||
#[diag(feature_cant_emit_feature_usage_metrics)] | ||
FileCreate { | ||
error: io::Error, | ||
}, | ||
#[diag(feature_cant_emit_feature_usage_metrics)] | ||
JsonWrite { | ||
error: io::Error, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#![feature(ascii_char)] // random lib feature | ||
#![feature(box_patterns)] // random lang feature | ||
|
||
// picked arbitrary unstable features, just need a random lib and lang feature, ideally ones that | ||
// won't be stabilized any time soon so we don't have to update this test | ||
|
||
fn main() { | ||
println!("foobar"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
//! This test checks if unstable feature usage metric dump files `unstable-feature-usage*.json` work | ||
//! as expected. | ||
//! | ||
//! - Basic sanity checks on a default ICE dump. | ||
//! | ||
//! See <https://github.com/rust-lang/rust/issues/129485>. | ||
//! | ||
//! # Test history | ||
//! | ||
//! - forked from dump-ice-to-disk test, which has flakeyness issues on i686-mingw, I'm assuming | ||
//! those will be present in this test as well on the same platform | ||
|
||
//@ ignore-windows | ||
//FIXME(#128911): still flakey on i686-mingw. | ||
|
||
use std::path::{Path, PathBuf}; | ||
|
||
use run_make_support::{ | ||
cwd, has_extension, filename_contains, rfs, run_in_tmpdir, rustc, serde_json, shallow_find_files, | ||
}; | ||
|
||
fn find_feature_usage_metrics<P: AsRef<Path>>(dir: P) -> Vec<PathBuf> { | ||
shallow_find_files(dir, |path| { | ||
if filename_contains(path, "unstable_feature_usage") && has_extension(path, "json") { | ||
true | ||
} else { | ||
dbg!(path); | ||
false | ||
} | ||
}) | ||
} | ||
|
||
fn main() { | ||
test_metrics_dump(); | ||
} | ||
|
||
#[track_caller] | ||
fn test_metrics_dump() { | ||
run_in_tmpdir(|| { | ||
let metrics_dir = cwd().join("metrics"); | ||
rustc() | ||
.input("lib.rs") | ||
.env("RUST_BACKTRACE", "short") | ||
.arg(format!("-Zmetrics-dir={}", metrics_dir.display())) | ||
.run(); | ||
let mut metrics = find_feature_usage_metrics(&metrics_dir); | ||
let json_path = | ||
metrics.pop().expect("there should be one metrics file in the output directory"); | ||
|
||
assert_eq!( | ||
0, | ||
metrics.len(), | ||
"there should be no more than one metrics file in the output directory" | ||
); | ||
|
||
let message = rfs::read_to_string(json_path); | ||
let parsed: serde_json::Value = | ||
serde_json::from_str(&message).expect("metrics should be dumped as json"); | ||
let expected = serde_json::json!( | ||
{ | ||
"lib_features":[{"symbol":"ascii_char"}], | ||
"lang_features":[{"symbol":"box_patterns","since":null}] | ||
} | ||
); | ||
|
||
assert_eq!(expected, parsed); | ||
}); | ||
} |