Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 14ea491

Browse files
committedApr 22, 2020
Add all the missing option tests.
1 parent 4348f31 commit 14ea491

File tree

1 file changed

+273
-15
lines changed

1 file changed

+273
-15
lines changed
 

‎src/librustc_interface/tests.rs

Lines changed: 273 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ use rustc_errors::{emitter::HumanReadableErrorType, registry, ColorConfig};
55
use rustc_middle::middle::cstore;
66
use rustc_session::config::{build_configuration, build_session_options, to_crate_config};
77
use rustc_session::config::{rustc_optgroups, ErrorOutputType, ExternLocation, Options, Passes};
8-
use rustc_session::config::{ExternEntry, LinkerPluginLto, LtoCli, SwitchWithOptPath};
9-
use rustc_session::config::{Externs, OutputType, OutputTypes, SymbolManglingVersion};
8+
use rustc_session::config::{CFGuard, ExternEntry, LinkerPluginLto, LtoCli, SwitchWithOptPath};
9+
use rustc_session::config::{Externs, OutputType, OutputTypes, Sanitizer, SymbolManglingVersion};
1010
use rustc_session::getopts;
1111
use rustc_session::lint::Level;
1212
use rustc_session::search_paths::SearchPath;
1313
use rustc_session::{build_session, Session};
1414
use rustc_span::edition::{Edition, DEFAULT_EDITION};
1515
use rustc_span::symbol::sym;
16-
use rustc_target::spec::{MergeFunctions, PanicStrategy, RelroLevel};
16+
use rustc_span::SourceFileHashAlgorithm;
17+
use rustc_target::spec::{LinkerFlavor, MergeFunctions, PanicStrategy, RelroLevel};
1718
use std::collections::{BTreeMap, BTreeSet};
1819
use std::iter::FromIterator;
1920
use std::path::PathBuf;
@@ -383,12 +384,17 @@ fn test_codegen_options_tracking_hash() {
383384
opts.cg.codegen_units = Some(42);
384385
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
385386

387+
opts.cg.default_linker_libraries = true;
388+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
389+
386390
opts.cg.extra_filename = String::from("extra-filename");
387391
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
388392

389393
opts.cg.incremental = Some(String::from("abc"));
390394
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
391395

396+
// `link_arg` is omitted because it just forwards to `link_args`.
397+
392398
opts.cg.link_args = vec![String::from("abc"), String::from("def")];
393399
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
394400

@@ -398,6 +404,12 @@ fn test_codegen_options_tracking_hash() {
398404
opts.cg.linker = Some(PathBuf::from("linker"));
399405
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
400406

407+
opts.cg.linker_flavor = Some(LinkerFlavor::Gcc);
408+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
409+
410+
opts.cg.no_stack_check = true;
411+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
412+
401413
opts.cg.remark = Passes::Some(vec![String::from("pass1"), String::from("pass2")]);
402414
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
403415

@@ -411,19 +423,19 @@ fn test_codegen_options_tracking_hash() {
411423
// This list is in alphabetical order.
412424

413425
opts = reference.clone();
414-
opts.cg.code_model = Some(String::from("code model"));
426+
opts.cg.bitcode_in_rlib = false;
415427
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
416428

417429
opts = reference.clone();
418-
opts.cg.debug_assertions = Some(true);
430+
opts.cg.code_model = Some(String::from("code model"));
419431
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
420432

421433
opts = reference.clone();
422-
opts.cg.debuginfo = 0xdeadbeef;
434+
opts.cg.debug_assertions = Some(true);
423435
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
424436

425437
opts = reference.clone();
426-
opts.cg.debuginfo = 0xba5eba11;
438+
opts.cg.debuginfo = 0xdeadbeef;
427439
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
428440

429441
opts = reference.clone();
@@ -466,6 +478,10 @@ fn test_codegen_options_tracking_hash() {
466478
opts.cg.no_vectorize_slp = true;
467479
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
468480

481+
opts = reference.clone();
482+
opts.cg.opt_level = "3".to_string();
483+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
484+
469485
opts = reference.clone();
470486
opts.cg.overflow_checks = Some(true);
471487
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
@@ -505,14 +521,6 @@ fn test_codegen_options_tracking_hash() {
505521
opts = reference.clone();
506522
opts.cg.target_feature = String::from("all the features, all of them");
507523
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
508-
509-
opts = reference.clone();
510-
opts.debugging_opts.tls_model = Some(String::from("tls model"));
511-
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
512-
513-
opts = reference.clone();
514-
opts.cg.bitcode_in_rlib = false;
515-
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
516524
}
517525

518526
#[test]
@@ -529,9 +537,24 @@ fn test_debugging_options_tracking_hash() {
529537
opts.debugging_opts.ast_json_noexpand = true;
530538
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
531539

540+
opts.debugging_opts.borrowck = String::from("other");
541+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
542+
532543
opts.debugging_opts.borrowck_stats = true;
533544
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
534545

546+
opts.debugging_opts.control_flow_guard = CFGuard::Checks;
547+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
548+
549+
opts.debugging_opts.deduplicate_diagnostics = true;
550+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
551+
552+
opts.debugging_opts.dep_tasks = true;
553+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
554+
555+
opts.debugging_opts.dont_buffer_diagnostics = true;
556+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
557+
535558
opts.debugging_opts.dump_dep_graph = true;
536559
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
537560

@@ -544,27 +567,80 @@ fn test_debugging_options_tracking_hash() {
544567
opts.debugging_opts.dump_mir_dir = String::from("abc");
545568
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
546569

570+
opts.debugging_opts.dump_mir_exclude_pass_number = true;
571+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
572+
547573
opts.debugging_opts.dump_mir_graphviz = true;
548574
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
549575

576+
opts.debugging_opts.emit_stack_sizes = true;
577+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
578+
579+
opts.debugging_opts.hir_stats = true;
580+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
581+
582+
opts.debugging_opts.identify_regions = true;
583+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
584+
585+
opts.debugging_opts.incremental_ignore_spans = true;
586+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
587+
588+
opts.debugging_opts.incremental_info = true;
589+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
590+
591+
opts.debugging_opts.incremental_verify_ich = true;
592+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
593+
550594
opts.debugging_opts.input_stats = true;
551595
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
552596

553597
opts.debugging_opts.keep_hygiene_data = true;
554598
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
555599

600+
opts.debugging_opts.link_native_libraries = false;
601+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
602+
603+
opts.debugging_opts.llvm_time_trace = true;
604+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
605+
556606
opts.debugging_opts.ls = true;
557607
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
558608

609+
opts.debugging_opts.macro_backtrace = true;
610+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
611+
559612
opts.debugging_opts.meta_stats = true;
560613
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
561614

615+
opts.debugging_opts.nll_facts = true;
616+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
617+
562618
opts.debugging_opts.no_analysis = true;
563619
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
564620

621+
opts.debugging_opts.no_interleave_lints = true;
622+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
623+
624+
opts.debugging_opts.no_leak_check = true;
625+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
626+
627+
opts.debugging_opts.no_parallel_llvm = true;
628+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
629+
565630
opts.debugging_opts.parse_only = true;
566631
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
567632

633+
opts.debugging_opts.perf_stats = true;
634+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
635+
636+
opts.debugging_opts.polonius = true;
637+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
638+
639+
// `pre_link_arg` is omitted because it just forwards to `pre_link_args`.
640+
641+
opts.debugging_opts.pre_link_args = vec![String::from("abc"), String::from("def")];
642+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
643+
568644
opts.debugging_opts.print_link_args = true;
569645
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
570646

@@ -577,12 +653,36 @@ fn test_debugging_options_tracking_hash() {
577653
opts.debugging_opts.print_region_graph = true;
578654
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
579655

656+
opts.debugging_opts.print_type_sizes = true;
657+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
658+
580659
opts.debugging_opts.query_dep_graph = true;
581660
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
582661

662+
opts.debugging_opts.query_stats = true;
663+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
664+
583665
opts.debugging_opts.save_analysis = true;
584666
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
585667

668+
opts.debugging_opts.self_profile = SwitchWithOptPath::Enabled(None);
669+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
670+
671+
opts.debugging_opts.self_profile_events = Some(vec![String::new()]);
672+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
673+
674+
opts.debugging_opts.span_free_formats = true;
675+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
676+
677+
opts.debugging_opts.terminal_width = Some(80);
678+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
679+
680+
opts.debugging_opts.threads = 99;
681+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
682+
683+
opts.debugging_opts.time = true;
684+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
685+
586686
opts.debugging_opts.time_llvm_passes = true;
587687
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
588688

@@ -592,6 +692,12 @@ fn test_debugging_options_tracking_hash() {
592692
opts.debugging_opts.trace_macros = true;
593693
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
594694

695+
opts.debugging_opts.ui_testing = true;
696+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
697+
698+
opts.debugging_opts.unpretty = Some("expanded".to_string());
699+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
700+
595701
opts.debugging_opts.unstable_options = true;
596702
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
597703

@@ -605,10 +711,42 @@ fn test_debugging_options_tracking_hash() {
605711
opts.debugging_opts.allow_features = Some(vec![String::from("lang_items")]);
606712
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
607713

714+
opts = reference.clone();
715+
opts.debugging_opts.always_encode_mir = true;
716+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
717+
608718
opts = reference.clone();
609719
opts.debugging_opts.asm_comments = true;
610720
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
611721

722+
opts = reference.clone();
723+
opts.debugging_opts.binary_dep_depinfo = true;
724+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
725+
726+
opts = reference.clone();
727+
opts.debugging_opts.codegen_backend = Some("abc".to_string());
728+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
729+
730+
opts = reference.clone();
731+
opts.debugging_opts.crate_attr = vec!["abc".to_string()];
732+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
733+
734+
opts = reference.clone();
735+
opts.debugging_opts.debug_macros = true;
736+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
737+
738+
opts = reference.clone();
739+
opts.debugging_opts.dep_info_omit_d_target = true;
740+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
741+
742+
opts = reference.clone();
743+
opts.debugging_opts.dual_proc_macros = true;
744+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
745+
746+
opts = reference.clone();
747+
opts.debugging_opts.embed_bitcode = true;
748+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
749+
612750
opts = reference.clone();
613751
opts.debugging_opts.fewer_names = true;
614752
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
@@ -617,22 +755,94 @@ fn test_debugging_options_tracking_hash() {
617755
opts.debugging_opts.force_overflow_checks = Some(true);
618756
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
619757

758+
opts = reference.clone();
759+
opts.debugging_opts.force_unstable_if_unmarked = true;
760+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
761+
762+
opts = reference.clone();
763+
opts.debugging_opts.fuel = Some(("abc".to_string(), 99));
764+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
765+
766+
opts = reference.clone();
767+
opts.debugging_opts.human_readable_cgu_names = true;
768+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
769+
770+
opts = reference.clone();
771+
opts.debugging_opts.inline_in_all_cgus = Some(true);
772+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
773+
774+
opts = reference.clone();
775+
opts.debugging_opts.insert_sideeffect = true;
776+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
777+
778+
opts = reference.clone();
779+
opts.debugging_opts.instrument_mcount = true;
780+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
781+
782+
opts = reference.clone();
783+
opts.debugging_opts.link_only = true;
784+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
785+
620786
opts = reference.clone();
621787
opts.debugging_opts.merge_functions = Some(MergeFunctions::Disabled);
622788
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
623789

790+
opts = reference.clone();
791+
opts.debugging_opts.mir_emit_retag = true;
792+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
793+
624794
opts = reference.clone();
625795
opts.debugging_opts.mir_opt_level = 3;
626796
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
627797

798+
opts = reference.clone();
799+
opts.debugging_opts.mutable_noalias = true;
800+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
801+
802+
opts = reference.clone();
803+
opts.debugging_opts.new_llvm_pass_manager = true;
804+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
805+
628806
opts = reference.clone();
629807
opts.debugging_opts.no_codegen = true;
630808
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
631809

810+
opts = reference.clone();
811+
opts.debugging_opts.no_generate_arange_section = true;
812+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
813+
632814
opts = reference.clone();
633815
opts.debugging_opts.no_landing_pads = true;
634816
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
635817

818+
opts = reference.clone();
819+
opts.debugging_opts.no_link = true;
820+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
821+
822+
opts = reference.clone();
823+
opts.debugging_opts.no_profiler_runtime = true;
824+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
825+
826+
opts = reference.clone();
827+
opts.debugging_opts.osx_rpath_install_name = true;
828+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
829+
830+
opts = reference.clone();
831+
opts.debugging_opts.panic_abort_tests = true;
832+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
833+
834+
opts = reference.clone();
835+
opts.debugging_opts.plt = Some(true);
836+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
837+
838+
opts = reference.clone();
839+
opts.debugging_opts.print_fuel = Some("abc".to_string());
840+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
841+
842+
opts = reference.clone();
843+
opts.debugging_opts.profile = true;
844+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
845+
636846
opts = reference.clone();
637847
opts.debugging_opts.relro_level = Some(RelroLevel::Full);
638848
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
@@ -641,18 +851,66 @@ fn test_debugging_options_tracking_hash() {
641851
opts.debugging_opts.report_delayed_bugs = true;
642852
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
643853

854+
opts = reference.clone();
855+
opts.debugging_opts.run_dsymutil = false;
856+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
857+
858+
opts = reference.clone();
859+
opts.debugging_opts.sanitizer = Some(Sanitizer::Address);
860+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
861+
862+
opts = reference.clone();
863+
opts.debugging_opts.sanitizer_memory_track_origins = 2;
864+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
865+
866+
opts = reference.clone();
867+
opts.debugging_opts.sanitizer_recover = vec![Sanitizer::Address];
868+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
869+
870+
opts = reference.clone();
871+
opts.debugging_opts.saturating_float_casts = true;
872+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
873+
874+
opts = reference.clone();
875+
opts.debugging_opts.share_generics = Some(true);
876+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
877+
644878
opts = reference.clone();
645879
opts.debugging_opts.show_span = Some(String::from("abc"));
646880
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
647881

882+
opts = reference.clone();
883+
opts.debugging_opts.src_hash_algorithm = Some(SourceFileHashAlgorithm::Sha1);
884+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
885+
886+
opts = reference.clone();
887+
opts.debugging_opts.strip_debuginfo_if_disabled = true;
888+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
889+
648890
opts = reference.clone();
649891
opts.debugging_opts.symbol_mangling_version = SymbolManglingVersion::V0;
650892
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
651893

894+
opts = reference.clone();
895+
opts.debugging_opts.teach = true;
896+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
897+
898+
opts = reference.clone();
899+
opts.debugging_opts.thinlto = Some(true);
900+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
901+
902+
opts = reference.clone();
903+
opts.debugging_opts.tls_model = Some(String::from("tls model"));
904+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
905+
652906
opts = reference.clone();
653907
opts.debugging_opts.treat_err_as_bug = Some(1);
654908
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
655909

910+
opts = reference.clone();
911+
opts.debugging_opts.unleash_the_miri_inside_of_you = true;
912+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
913+
656914
opts = reference.clone();
657915
opts.debugging_opts.verify_llvm_ir = true;
658916
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());

0 commit comments

Comments
 (0)
Please sign in to comment.