-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unstable feature usage metrics #130236
Merged
Merged
unstable feature usage metrics #130236
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,87 @@ | ||
//! 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::rfs::create_dir_all; | ||
use run_make_support::{ | ||
cwd, filename_contains, has_extension, 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(); | ||
test_metrics_errors(); | ||
} | ||
|
||
#[track_caller] | ||
fn test_metrics_dump() { | ||
run_in_tmpdir(|| { | ||
let metrics_dir = cwd().join("metrics"); | ||
create_dir_all(&metrics_dir); | ||
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"); | ||
|
||
// After the `pop` above, there should be no files left. | ||
assert!( | ||
metrics.is_empty(), | ||
"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); | ||
}); | ||
} | ||
|
||
#[track_caller] | ||
fn test_metrics_errors() { | ||
run_in_tmpdir(|| { | ||
rustc() | ||
.input("lib.rs") | ||
.env("RUST_BACKTRACE", "short") | ||
.arg("-Zmetrics-dir=invaliddirectorythatdefinitelydoesntexist") | ||
.run_fail() | ||
.assert_stderr_contains( | ||
"error: cannot dump feature usage metrics: No such file or directory", | ||
) | ||
.assert_stdout_not_contains("internal compiler error"); | ||
}); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we use
dyn Error
/IOError
we don't display the file path that we couldn't open. That's not ideal but ok for now. Let's revisit in the future.