mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-07 17:18:32 +03:00
Prepare TestProps::load_from for handler extraction
This step consists of two changes: - Renaming `self` to `props` - Inserting temporary comments to preserve line breaks This will make it easier to verify that the main migration commit preserves all of the lines being migrated.
This commit is contained in:
@@ -360,21 +360,22 @@ fn load_from(&mut self, testfile: &Utf8Path, test_revision: Option<&str>, config
|
||||
}
|
||||
|
||||
use directives::*;
|
||||
let props = &mut *self;
|
||||
|
||||
config.push_name_value_directive(
|
||||
ln,
|
||||
ERROR_PATTERN,
|
||||
&mut self.error_patterns,
|
||||
&mut props.error_patterns,
|
||||
|r| r,
|
||||
);
|
||||
config.push_name_value_directive(
|
||||
ln,
|
||||
REGEX_ERROR_PATTERN,
|
||||
&mut self.regex_error_patterns,
|
||||
&mut props.regex_error_patterns,
|
||||
|r| r,
|
||||
);
|
||||
|
||||
config.push_name_value_directive(ln, DOC_FLAGS, &mut self.doc_flags, |r| r);
|
||||
config.push_name_value_directive(ln, DOC_FLAGS, &mut props.doc_flags, |r| r);
|
||||
|
||||
fn split_flags(flags: &str) -> Vec<String> {
|
||||
// Individual flags can be single-quoted to preserve spaces; see
|
||||
@@ -383,6 +384,7 @@ fn split_flags(flags: &str) -> Vec<String> {
|
||||
.split('\'')
|
||||
.enumerate()
|
||||
.flat_map(|(i, f)| {
|
||||
// (preserve line breaks)
|
||||
if i % 2 == 1 { vec![f] } else { f.split_whitespace().collect() }
|
||||
})
|
||||
.map(move |s| s.to_owned())
|
||||
@@ -400,115 +402,125 @@ fn split_flags(flags: &str) -> Vec<String> {
|
||||
|| flag.starts_with("-Cincremental=")
|
||||
{
|
||||
panic!(
|
||||
// (preserve line breaks)
|
||||
"you must use `//@ incremental` to enable incremental compilation"
|
||||
);
|
||||
}
|
||||
}
|
||||
self.compile_flags.extend(flags);
|
||||
props.compile_flags.extend(flags);
|
||||
}
|
||||
|
||||
if let Some(range) = parse_edition_range(config, ln) {
|
||||
self.edition = Some(range.edition_to_test(config.edition));
|
||||
props.edition = Some(range.edition_to_test(config.edition));
|
||||
}
|
||||
|
||||
config.parse_and_update_revisions(ln, &mut self.revisions);
|
||||
config.parse_and_update_revisions(ln, &mut props.revisions);
|
||||
|
||||
if let Some(flags) = config.parse_name_value_directive(ln, RUN_FLAGS) {
|
||||
self.run_flags.extend(split_flags(&flags));
|
||||
props.run_flags.extend(split_flags(&flags));
|
||||
}
|
||||
|
||||
if self.pp_exact.is_none() {
|
||||
self.pp_exact = config.parse_pp_exact(ln);
|
||||
if props.pp_exact.is_none() {
|
||||
props.pp_exact = config.parse_pp_exact(ln);
|
||||
}
|
||||
|
||||
config.set_name_directive(ln, SHOULD_ICE, &mut self.should_ice);
|
||||
config.set_name_directive(ln, BUILD_AUX_DOCS, &mut self.build_aux_docs);
|
||||
config.set_name_directive(ln, UNIQUE_DOC_OUT_DIR, &mut self.unique_doc_out_dir);
|
||||
config.set_name_directive(ln, SHOULD_ICE, &mut props.should_ice);
|
||||
config.set_name_directive(ln, BUILD_AUX_DOCS, &mut props.build_aux_docs);
|
||||
config.set_name_directive(
|
||||
// (preserve line breaks)
|
||||
ln,
|
||||
UNIQUE_DOC_OUT_DIR,
|
||||
&mut props.unique_doc_out_dir,
|
||||
);
|
||||
|
||||
config.set_name_directive(ln, FORCE_HOST, &mut self.force_host);
|
||||
config.set_name_directive(ln, CHECK_STDOUT, &mut self.check_stdout);
|
||||
config.set_name_directive(ln, CHECK_RUN_RESULTS, &mut self.check_run_results);
|
||||
config.set_name_directive(ln, FORCE_HOST, &mut props.force_host);
|
||||
config.set_name_directive(ln, CHECK_STDOUT, &mut props.check_stdout);
|
||||
config.set_name_directive(ln, CHECK_RUN_RESULTS, &mut props.check_run_results);
|
||||
config.set_name_directive(
|
||||
ln,
|
||||
DONT_CHECK_COMPILER_STDOUT,
|
||||
&mut self.dont_check_compiler_stdout,
|
||||
&mut props.dont_check_compiler_stdout,
|
||||
);
|
||||
config.set_name_directive(
|
||||
ln,
|
||||
DONT_CHECK_COMPILER_STDERR,
|
||||
&mut self.dont_check_compiler_stderr,
|
||||
&mut props.dont_check_compiler_stderr,
|
||||
);
|
||||
config.set_name_directive(ln, NO_PREFER_DYNAMIC, &mut self.no_prefer_dynamic);
|
||||
config.set_name_directive(ln, NO_PREFER_DYNAMIC, &mut props.no_prefer_dynamic);
|
||||
|
||||
if let Some(m) = config.parse_name_value_directive(ln, PRETTY_MODE) {
|
||||
self.pretty_mode = m;
|
||||
props.pretty_mode = m;
|
||||
}
|
||||
|
||||
config.set_name_directive(
|
||||
// (preserve line breaks)
|
||||
ln,
|
||||
PRETTY_COMPARE_ONLY,
|
||||
&mut self.pretty_compare_only,
|
||||
&mut props.pretty_compare_only,
|
||||
);
|
||||
|
||||
// Call a helper method to deal with aux-related directives.
|
||||
parse_and_update_aux(config, ln, &mut self.aux);
|
||||
parse_and_update_aux(config, ln, &mut props.aux);
|
||||
|
||||
config.push_name_value_directive(
|
||||
// (preserve line breaks)
|
||||
ln,
|
||||
EXEC_ENV,
|
||||
&mut self.exec_env,
|
||||
&mut props.exec_env,
|
||||
Config::parse_env,
|
||||
);
|
||||
config.push_name_value_directive(
|
||||
// (preserve line breaks)
|
||||
ln,
|
||||
UNSET_EXEC_ENV,
|
||||
&mut self.unset_exec_env,
|
||||
&mut props.unset_exec_env,
|
||||
|r| r.trim().to_owned(),
|
||||
);
|
||||
config.push_name_value_directive(
|
||||
ln,
|
||||
RUSTC_ENV,
|
||||
&mut self.rustc_env,
|
||||
&mut props.rustc_env,
|
||||
Config::parse_env,
|
||||
);
|
||||
config.push_name_value_directive(
|
||||
ln,
|
||||
UNSET_RUSTC_ENV,
|
||||
&mut self.unset_rustc_env,
|
||||
&mut props.unset_rustc_env,
|
||||
|r| r.trim().to_owned(),
|
||||
);
|
||||
config.push_name_value_directive(
|
||||
// (preserve line breaks)
|
||||
ln,
|
||||
FORBID_OUTPUT,
|
||||
&mut self.forbid_output,
|
||||
&mut props.forbid_output,
|
||||
|r| r,
|
||||
);
|
||||
config.set_name_directive(
|
||||
ln,
|
||||
CHECK_TEST_LINE_NUMBERS_MATCH,
|
||||
&mut self.check_test_line_numbers_match,
|
||||
&mut props.check_test_line_numbers_match,
|
||||
);
|
||||
|
||||
self.update_pass_mode(ln, config);
|
||||
self.update_fail_mode(ln, config);
|
||||
props.update_pass_mode(ln, config);
|
||||
props.update_fail_mode(ln, config);
|
||||
|
||||
config.set_name_directive(ln, IGNORE_PASS, &mut self.ignore_pass);
|
||||
config.set_name_directive(ln, IGNORE_PASS, &mut props.ignore_pass);
|
||||
|
||||
if let Some(NormalizeRule { kind, regex, replacement }) =
|
||||
config.parse_custom_normalization(ln)
|
||||
{
|
||||
let rule_tuple = (regex, replacement);
|
||||
match kind {
|
||||
NormalizeKind::Stdout => self.normalize_stdout.push(rule_tuple),
|
||||
NormalizeKind::Stderr => self.normalize_stderr.push(rule_tuple),
|
||||
NormalizeKind::Stdout => props.normalize_stdout.push(rule_tuple),
|
||||
NormalizeKind::Stderr => props.normalize_stderr.push(rule_tuple),
|
||||
NormalizeKind::Stderr32bit => {
|
||||
if config.target_cfg().pointer_width == 32 {
|
||||
self.normalize_stderr.push(rule_tuple);
|
||||
props.normalize_stderr.push(rule_tuple);
|
||||
}
|
||||
}
|
||||
NormalizeKind::Stderr64bit => {
|
||||
if config.target_cfg().pointer_width == 64 {
|
||||
self.normalize_stderr.push(rule_tuple);
|
||||
props.normalize_stderr.push(rule_tuple);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -518,33 +530,35 @@ fn split_flags(flags: &str) -> Vec<String> {
|
||||
.parse_name_value_directive(ln, FAILURE_STATUS)
|
||||
.and_then(|code| code.trim().parse::<i32>().ok())
|
||||
{
|
||||
self.failure_status = Some(code);
|
||||
props.failure_status = Some(code);
|
||||
}
|
||||
|
||||
config.set_name_directive(
|
||||
ln,
|
||||
DONT_CHECK_FAILURE_STATUS,
|
||||
&mut self.dont_check_failure_status,
|
||||
&mut props.dont_check_failure_status,
|
||||
);
|
||||
|
||||
config.set_name_directive(ln, RUN_RUSTFIX, &mut self.run_rustfix);
|
||||
config.set_name_directive(ln, RUN_RUSTFIX, &mut props.run_rustfix);
|
||||
config.set_name_directive(
|
||||
ln,
|
||||
RUSTFIX_ONLY_MACHINE_APPLICABLE,
|
||||
&mut self.rustfix_only_machine_applicable,
|
||||
&mut props.rustfix_only_machine_applicable,
|
||||
);
|
||||
config.set_name_value_directive(
|
||||
// (preserve line breaks)
|
||||
ln,
|
||||
ASSEMBLY_OUTPUT,
|
||||
&mut self.assembly_output,
|
||||
&mut props.assembly_output,
|
||||
|r| r.trim().to_string(),
|
||||
);
|
||||
config.set_name_directive(
|
||||
// (preserve line breaks)
|
||||
ln,
|
||||
STDERR_PER_BITWIDTH,
|
||||
&mut self.stderr_per_bitwidth,
|
||||
&mut props.stderr_per_bitwidth,
|
||||
);
|
||||
config.set_name_directive(ln, INCREMENTAL, &mut self.incremental);
|
||||
config.set_name_directive(ln, INCREMENTAL, &mut props.incremental);
|
||||
|
||||
// Unlike the other `name_value_directive`s this needs to be handled manually,
|
||||
// because it sets a `bool` flag.
|
||||
@@ -556,12 +570,13 @@ fn split_flags(flags: &str) -> Vec<String> {
|
||||
.trim()
|
||||
.split_once('#')
|
||||
.filter(|(_, number)| {
|
||||
// (preserve line breaks)
|
||||
number.chars().all(|digit| digit.is_numeric())
|
||||
})
|
||||
.is_some()
|
||||
})
|
||||
{
|
||||
self.known_bug = true;
|
||||
props.known_bug = true;
|
||||
} else {
|
||||
panic!(
|
||||
"Invalid known-bug value: {known_bug}\nIt requires comma-separated issue references (`#000` or `chalk#000`) or `known-bug: unknown`."
|
||||
@@ -574,26 +589,28 @@ fn split_flags(flags: &str) -> Vec<String> {
|
||||
}
|
||||
|
||||
config.set_name_value_directive(
|
||||
// (preserve line breaks)
|
||||
ln,
|
||||
TEST_MIR_PASS,
|
||||
&mut self.mir_unit_test,
|
||||
&mut props.mir_unit_test,
|
||||
|s| s.trim().to_string(),
|
||||
);
|
||||
config.set_name_directive(ln, REMAP_SRC_BASE, &mut self.remap_src_base);
|
||||
config.set_name_directive(ln, REMAP_SRC_BASE, &mut props.remap_src_base);
|
||||
|
||||
if let Some(flags) = config.parse_name_value_directive(ln, LLVM_COV_FLAGS) {
|
||||
self.llvm_cov_flags.extend(split_flags(&flags));
|
||||
props.llvm_cov_flags.extend(split_flags(&flags));
|
||||
}
|
||||
|
||||
if let Some(flags) = config.parse_name_value_directive(ln, FILECHECK_FLAGS) {
|
||||
self.filecheck_flags.extend(split_flags(&flags));
|
||||
props.filecheck_flags.extend(split_flags(&flags));
|
||||
}
|
||||
|
||||
config.set_name_directive(ln, NO_AUTO_CHECK_CFG, &mut self.no_auto_check_cfg);
|
||||
config.set_name_directive(ln, NO_AUTO_CHECK_CFG, &mut props.no_auto_check_cfg);
|
||||
|
||||
self.update_add_minicore(ln, config);
|
||||
props.update_add_minicore(ln, config);
|
||||
|
||||
if let Some(flags) =
|
||||
// (preserve line breaks)
|
||||
config.parse_name_value_directive(ln, MINICORE_COMPILE_FLAGS)
|
||||
{
|
||||
let flags = split_flags(&flags);
|
||||
@@ -602,25 +619,27 @@ fn split_flags(flags: &str) -> Vec<String> {
|
||||
panic!("you must use `//@ edition` to configure the edition");
|
||||
}
|
||||
}
|
||||
self.minicore_compile_flags.extend(flags);
|
||||
props.minicore_compile_flags.extend(flags);
|
||||
}
|
||||
|
||||
if let Some(err_kind) =
|
||||
// (preserve line breaks)
|
||||
config.parse_name_value_directive(ln, DONT_REQUIRE_ANNOTATIONS)
|
||||
{
|
||||
self.dont_require_annotations
|
||||
props
|
||||
.dont_require_annotations
|
||||
.insert(ErrorKind::expect_from_user_str(err_kind.trim()));
|
||||
}
|
||||
|
||||
config.set_name_directive(
|
||||
ln,
|
||||
DISABLE_GDB_PRETTY_PRINTERS,
|
||||
&mut self.disable_gdb_pretty_printers,
|
||||
&mut props.disable_gdb_pretty_printers,
|
||||
);
|
||||
config.set_name_directive(
|
||||
ln,
|
||||
COMPARE_OUTPUT_BY_LINES,
|
||||
&mut self.compare_output_by_lines,
|
||||
&mut props.compare_output_by_lines,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user