Skip to content

Commit 3c02afe

Browse files
committed
compiletest: Don't load TestProps from a directories
1 parent db7ee95 commit 3c02afe

File tree

1 file changed

+106
-102
lines changed

1 file changed

+106
-102
lines changed

src/tools/compiletest/src/header.rs

+106-102
Original file line numberDiff line numberDiff line change
@@ -391,139 +391,143 @@ impl TestProps {
391391
/// `//[foo]`), then the property is ignored unless `cfg` is
392392
/// `Some("foo")`.
393393
fn load_from(&mut self, testfile: &Path, cfg: Option<&str>, config: &Config) {
394-
let file = File::open(testfile).unwrap();
395-
iter_header(testfile, cfg, file, &mut |ln| {
396-
if let Some(ep) = config.parse_error_pattern(ln) {
397-
self.error_patterns.push(ep);
398-
}
394+
if !testfile.is_dir() {
395+
let file = File::open(testfile).unwrap();
399396

400-
if let Some(flags) = config.parse_compile_flags(ln) {
401-
self.compile_flags.extend(flags.split_whitespace().map(|s| s.to_owned()));
402-
}
397+
iter_header(testfile, cfg, file, &mut |ln| {
398+
if let Some(ep) = config.parse_error_pattern(ln) {
399+
self.error_patterns.push(ep);
400+
}
403401

404-
if let Some(edition) = config.parse_edition(ln) {
405-
self.compile_flags.push(format!("--edition={}", edition));
406-
}
402+
if let Some(flags) = config.parse_compile_flags(ln) {
403+
self.compile_flags.extend(flags.split_whitespace().map(|s| s.to_owned()));
404+
}
407405

408-
if let Some(r) = config.parse_revisions(ln) {
409-
self.revisions.extend(r);
410-
}
406+
if let Some(edition) = config.parse_edition(ln) {
407+
self.compile_flags.push(format!("--edition={}", edition));
408+
}
411409

412-
if self.run_flags.is_none() {
413-
self.run_flags = config.parse_run_flags(ln);
414-
}
410+
if let Some(r) = config.parse_revisions(ln) {
411+
self.revisions.extend(r);
412+
}
415413

416-
if self.pp_exact.is_none() {
417-
self.pp_exact = config.parse_pp_exact(ln, testfile);
418-
}
414+
if self.run_flags.is_none() {
415+
self.run_flags = config.parse_run_flags(ln);
416+
}
419417

420-
if !self.should_ice {
421-
self.should_ice = config.parse_should_ice(ln);
422-
}
418+
if self.pp_exact.is_none() {
419+
self.pp_exact = config.parse_pp_exact(ln, testfile);
420+
}
423421

424-
if !self.build_aux_docs {
425-
self.build_aux_docs = config.parse_build_aux_docs(ln);
426-
}
422+
if !self.should_ice {
423+
self.should_ice = config.parse_should_ice(ln);
424+
}
427425

428-
if !self.force_host {
429-
self.force_host = config.parse_force_host(ln);
430-
}
426+
if !self.build_aux_docs {
427+
self.build_aux_docs = config.parse_build_aux_docs(ln);
428+
}
431429

432-
if !self.check_stdout {
433-
self.check_stdout = config.parse_check_stdout(ln);
434-
}
430+
if !self.force_host {
431+
self.force_host = config.parse_force_host(ln);
432+
}
435433

436-
if !self.check_run_results {
437-
self.check_run_results = config.parse_check_run_results(ln);
438-
}
434+
if !self.check_stdout {
435+
self.check_stdout = config.parse_check_stdout(ln);
436+
}
439437

440-
if !self.dont_check_compiler_stdout {
441-
self.dont_check_compiler_stdout = config.parse_dont_check_compiler_stdout(ln);
442-
}
438+
if !self.check_run_results {
439+
self.check_run_results = config.parse_check_run_results(ln);
440+
}
443441

444-
if !self.dont_check_compiler_stderr {
445-
self.dont_check_compiler_stderr = config.parse_dont_check_compiler_stderr(ln);
446-
}
442+
if !self.dont_check_compiler_stdout {
443+
self.dont_check_compiler_stdout = config.parse_dont_check_compiler_stdout(ln);
444+
}
447445

448-
if !self.no_prefer_dynamic {
449-
self.no_prefer_dynamic = config.parse_no_prefer_dynamic(ln);
450-
}
446+
if !self.dont_check_compiler_stderr {
447+
self.dont_check_compiler_stderr = config.parse_dont_check_compiler_stderr(ln);
448+
}
451449

452-
if !self.pretty_expanded {
453-
self.pretty_expanded = config.parse_pretty_expanded(ln);
454-
}
450+
if !self.no_prefer_dynamic {
451+
self.no_prefer_dynamic = config.parse_no_prefer_dynamic(ln);
452+
}
455453

456-
if let Some(m) = config.parse_pretty_mode(ln) {
457-
self.pretty_mode = m;
458-
}
454+
if !self.pretty_expanded {
455+
self.pretty_expanded = config.parse_pretty_expanded(ln);
456+
}
459457

460-
if !self.pretty_compare_only {
461-
self.pretty_compare_only = config.parse_pretty_compare_only(ln);
462-
}
458+
if let Some(m) = config.parse_pretty_mode(ln) {
459+
self.pretty_mode = m;
460+
}
463461

464-
if let Some(ab) = config.parse_aux_build(ln) {
465-
self.aux_builds.push(ab);
466-
}
462+
if !self.pretty_compare_only {
463+
self.pretty_compare_only = config.parse_pretty_compare_only(ln);
464+
}
467465

468-
if let Some(ac) = config.parse_aux_crate(ln) {
469-
self.aux_crates.push(ac);
470-
}
466+
if let Some(ab) = config.parse_aux_build(ln) {
467+
self.aux_builds.push(ab);
468+
}
471469

472-
if let Some(ee) = config.parse_env(ln, "exec-env") {
473-
self.exec_env.push(ee);
474-
}
470+
if let Some(ac) = config.parse_aux_crate(ln) {
471+
self.aux_crates.push(ac);
472+
}
475473

476-
if let Some(ee) = config.parse_env(ln, "rustc-env") {
477-
self.rustc_env.push(ee);
478-
}
474+
if let Some(ee) = config.parse_env(ln, "exec-env") {
475+
self.exec_env.push(ee);
476+
}
479477

480-
if let Some(ev) = config.parse_name_value_directive(ln, "unset-rustc-env") {
481-
self.unset_rustc_env.push(ev);
482-
}
478+
if let Some(ee) = config.parse_env(ln, "rustc-env") {
479+
self.rustc_env.push(ee);
480+
}
483481

484-
if let Some(cl) = config.parse_check_line(ln) {
485-
self.check_lines.push(cl);
486-
}
482+
if let Some(ev) = config.parse_name_value_directive(ln, "unset-rustc-env") {
483+
self.unset_rustc_env.push(ev);
484+
}
487485

488-
if let Some(of) = config.parse_forbid_output(ln) {
489-
self.forbid_output.push(of);
490-
}
486+
if let Some(cl) = config.parse_check_line(ln) {
487+
self.check_lines.push(cl);
488+
}
491489

492-
if !self.check_test_line_numbers_match {
493-
self.check_test_line_numbers_match = config.parse_check_test_line_numbers_match(ln);
494-
}
490+
if let Some(of) = config.parse_forbid_output(ln) {
491+
self.forbid_output.push(of);
492+
}
495493

496-
self.update_pass_mode(ln, cfg, config);
497-
self.update_fail_mode(ln, config);
494+
if !self.check_test_line_numbers_match {
495+
self.check_test_line_numbers_match =
496+
config.parse_check_test_line_numbers_match(ln);
497+
}
498498

499-
if !self.ignore_pass {
500-
self.ignore_pass = config.parse_ignore_pass(ln);
501-
}
499+
self.update_pass_mode(ln, cfg, config);
500+
self.update_fail_mode(ln, config);
502501

503-
if let Some(rule) = config.parse_custom_normalization(ln, "normalize-stdout") {
504-
self.normalize_stdout.push(rule);
505-
}
506-
if let Some(rule) = config.parse_custom_normalization(ln, "normalize-stderr") {
507-
self.normalize_stderr.push(rule);
508-
}
502+
if !self.ignore_pass {
503+
self.ignore_pass = config.parse_ignore_pass(ln);
504+
}
509505

510-
if let Some(code) = config.parse_failure_status(ln) {
511-
self.failure_status = code;
512-
}
506+
if let Some(rule) = config.parse_custom_normalization(ln, "normalize-stdout") {
507+
self.normalize_stdout.push(rule);
508+
}
509+
if let Some(rule) = config.parse_custom_normalization(ln, "normalize-stderr") {
510+
self.normalize_stderr.push(rule);
511+
}
513512

514-
if !self.run_rustfix {
515-
self.run_rustfix = config.parse_run_rustfix(ln);
516-
}
513+
if let Some(code) = config.parse_failure_status(ln) {
514+
self.failure_status = code;
515+
}
517516

518-
if !self.rustfix_only_machine_applicable {
519-
self.rustfix_only_machine_applicable =
520-
config.parse_rustfix_only_machine_applicable(ln);
521-
}
517+
if !self.run_rustfix {
518+
self.run_rustfix = config.parse_run_rustfix(ln);
519+
}
522520

523-
if self.assembly_output.is_none() {
524-
self.assembly_output = config.parse_assembly_output(ln);
525-
}
526-
});
521+
if !self.rustfix_only_machine_applicable {
522+
self.rustfix_only_machine_applicable =
523+
config.parse_rustfix_only_machine_applicable(ln);
524+
}
525+
526+
if self.assembly_output.is_none() {
527+
self.assembly_output = config.parse_assembly_output(ln);
528+
}
529+
});
530+
}
527531

528532
if self.failure_status == -1 {
529533
self.failure_status = match config.mode {

0 commit comments

Comments
 (0)