-
Notifications
You must be signed in to change notification settings - Fork 13.8k
compiletest: Isolate public APIs and minimize public surface area #147506
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,143 @@ | ||
//! This module isolates the compiletest APIs used by the rustdoc-gui-test tool. | ||
//! | ||
//! Thanks to this isolation layer, changes to compiletest directive parsing | ||
//! might require changes to the items in this module, but shouldn't require | ||
//! changes to rustdoc-gui-test itself. | ||
//! | ||
//! The current relationship between compiletest and rustdoc-gui-test is | ||
//! awkward. Ideally, rustdoc-gui-test should either split off its own | ||
//! directive parser and become fully independent, or be incorporated into | ||
//! compiletest as another test mode. | ||
//! | ||
//! See <https://github.com/rust-lang/rust/issues/143827> for more context. | ||
|
||
use std::path::Path; | ||
|
||
use camino::{Utf8Path, Utf8PathBuf}; | ||
|
||
use crate::common::{CodegenBackend, Config, TestMode, TestSuite}; | ||
use crate::directives::TestProps; | ||
|
||
/// Subset of compiletest directive values that are actually used by | ||
/// rustdoc-gui-test. | ||
#[derive(Debug)] | ||
pub struct RustdocGuiTestProps { | ||
pub compile_flags: Vec<String>, | ||
pub run_flags: Vec<String>, | ||
} | ||
|
||
impl RustdocGuiTestProps { | ||
pub fn from_file(test_file_path: &Path) -> Self { | ||
let test_file_path = Utf8Path::from_path(test_file_path).unwrap(); | ||
let config = incomplete_config_for_rustdoc_gui_test(); | ||
|
||
let props = TestProps::from_file(test_file_path, None, &config); | ||
|
||
let TestProps { compile_flags, run_flags, .. } = props; | ||
Self { compile_flags, run_flags } | ||
} | ||
} | ||
|
||
/// Incomplete config intended for `src/tools/rustdoc-gui-test` **only** as | ||
/// `src/tools/rustdoc-gui-test` wants to reuse `compiletest`'s directive -> test property | ||
/// handling for `//@ {compile,run}-flags`, do not use for any other purpose. | ||
/// | ||
/// FIXME(#143827): this setup feels very hacky. It so happens that `tests/rustdoc-gui/` | ||
/// **only** uses `//@ {compile,run}-flags` for now and not any directives that actually rely on | ||
/// info that is assumed available in a fully populated [`Config`]. | ||
fn incomplete_config_for_rustdoc_gui_test() -> Config { | ||
// FIXME(#143827): spelling this out intentionally, because this is questionable. | ||
// | ||
// For instance, `//@ ignore-stage1` will not work at all. | ||
Config { | ||
mode: TestMode::Rustdoc, | ||
// E.g. this has no sensible default tbh. | ||
suite: TestSuite::Ui, | ||
|
||
// Dummy values. | ||
edition: Default::default(), | ||
bless: Default::default(), | ||
fail_fast: Default::default(), | ||
compile_lib_path: Utf8PathBuf::default(), | ||
run_lib_path: Utf8PathBuf::default(), | ||
rustc_path: Utf8PathBuf::default(), | ||
cargo_path: Default::default(), | ||
stage0_rustc_path: Default::default(), | ||
query_rustc_path: Default::default(), | ||
rustdoc_path: Default::default(), | ||
coverage_dump_path: Default::default(), | ||
python: Default::default(), | ||
jsondocck_path: Default::default(), | ||
jsondoclint_path: Default::default(), | ||
llvm_filecheck: Default::default(), | ||
llvm_bin_dir: Default::default(), | ||
run_clang_based_tests_with: Default::default(), | ||
src_root: Utf8PathBuf::default(), | ||
src_test_suite_root: Utf8PathBuf::default(), | ||
build_root: Utf8PathBuf::default(), | ||
build_test_suite_root: Utf8PathBuf::default(), | ||
sysroot_base: Utf8PathBuf::default(), | ||
stage: Default::default(), | ||
stage_id: String::default(), | ||
debugger: Default::default(), | ||
run_ignored: Default::default(), | ||
with_rustc_debug_assertions: Default::default(), | ||
with_std_debug_assertions: Default::default(), | ||
filters: Default::default(), | ||
skip: Default::default(), | ||
filter_exact: Default::default(), | ||
force_pass_mode: Default::default(), | ||
run: Default::default(), | ||
runner: Default::default(), | ||
host_rustcflags: Default::default(), | ||
target_rustcflags: Default::default(), | ||
rust_randomized_layout: Default::default(), | ||
optimize_tests: Default::default(), | ||
target: Default::default(), | ||
host: Default::default(), | ||
cdb: Default::default(), | ||
cdb_version: Default::default(), | ||
gdb: Default::default(), | ||
gdb_version: Default::default(), | ||
lldb_version: Default::default(), | ||
llvm_version: Default::default(), | ||
system_llvm: Default::default(), | ||
android_cross_path: Default::default(), | ||
adb_path: Default::default(), | ||
adb_test_dir: Default::default(), | ||
adb_device_status: Default::default(), | ||
lldb_python_dir: Default::default(), | ||
verbose: Default::default(), | ||
color: Default::default(), | ||
remote_test_client: Default::default(), | ||
compare_mode: Default::default(), | ||
rustfix_coverage: Default::default(), | ||
has_html_tidy: Default::default(), | ||
has_enzyme: Default::default(), | ||
channel: Default::default(), | ||
git_hash: Default::default(), | ||
cc: Default::default(), | ||
cxx: Default::default(), | ||
cflags: Default::default(), | ||
cxxflags: Default::default(), | ||
ar: Default::default(), | ||
target_linker: Default::default(), | ||
host_linker: Default::default(), | ||
llvm_components: Default::default(), | ||
nodejs: Default::default(), | ||
npm: Default::default(), | ||
force_rerun: Default::default(), | ||
only_modified: Default::default(), | ||
target_cfgs: Default::default(), | ||
builtin_cfg_names: Default::default(), | ||
supported_crate_types: Default::default(), | ||
nocapture: Default::default(), | ||
nightly_branch: Default::default(), | ||
git_merge_commit_email: Default::default(), | ||
profiler_runtime: Default::default(), | ||
diff_command: Default::default(), | ||
minicore_path: Default::default(), | ||
default_codegen_backend: CodegenBackend::Llvm, | ||
override_codegen_backend: None, | ||
} | ||
} |
This file contains hidden or 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 hidden or 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
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.
👍