| 
1 | 1 | use std::io::Read;  | 
2 | 2 | use std::path::Path;  | 
 | 3 | +use std::str::FromStr;  | 
3 | 4 | 
 
  | 
4 |  | -use crate::common::{Config, Debugger};  | 
 | 5 | +use crate::common::{Config, Debugger, Mode};  | 
5 | 6 | use crate::header::{parse_normalization_string, EarlyProps, HeadersCache};  | 
6 | 7 | 
 
  | 
7 | 8 | fn make_test_description<R: Read>(  | 
@@ -55,16 +56,23 @@ fn test_parse_normalization_string() {  | 
55 | 56 | 
 
  | 
56 | 57 | #[derive(Default)]  | 
57 | 58 | struct ConfigBuilder {  | 
 | 59 | +    mode: Option<String>,  | 
58 | 60 |     channel: Option<String>,  | 
59 | 61 |     host: Option<String>,  | 
60 | 62 |     target: Option<String>,  | 
61 | 63 |     stage_id: Option<String>,  | 
62 | 64 |     llvm_version: Option<String>,  | 
63 | 65 |     git_hash: bool,  | 
64 | 66 |     system_llvm: bool,  | 
 | 67 | +    profiler_support: bool,  | 
65 | 68 | }  | 
66 | 69 | 
 
  | 
67 | 70 | impl ConfigBuilder {  | 
 | 71 | +    fn mode(&mut self, s: &str) -> &mut Self {  | 
 | 72 | +        self.mode = Some(s.to_owned());  | 
 | 73 | +        self  | 
 | 74 | +    }  | 
 | 75 | + | 
68 | 76 |     fn channel(&mut self, s: &str) -> &mut Self {  | 
69 | 77 |         self.channel = Some(s.to_owned());  | 
70 | 78 |         self  | 
@@ -100,10 +108,16 @@ impl ConfigBuilder {  | 
100 | 108 |         self  | 
101 | 109 |     }  | 
102 | 110 | 
 
  | 
 | 111 | +    fn profiler_support(&mut self, s: bool) -> &mut Self {  | 
 | 112 | +        self.profiler_support = s;  | 
 | 113 | +        self  | 
 | 114 | +    }  | 
 | 115 | + | 
103 | 116 |     fn build(&mut self) -> Config {  | 
104 | 117 |         let args = &[  | 
105 | 118 |             "compiletest",  | 
106 |  | -            "--mode=ui",  | 
 | 119 | +            "--mode",  | 
 | 120 | +            self.mode.as_deref().unwrap_or("ui"),  | 
107 | 121 |             "--suite=ui",  | 
108 | 122 |             "--compile-lib-path=",  | 
109 | 123 |             "--run-lib-path=",  | 
@@ -142,6 +156,9 @@ impl ConfigBuilder {  | 
142 | 156 |         if self.system_llvm {  | 
143 | 157 |             args.push("--system-llvm".to_owned());  | 
144 | 158 |         }  | 
 | 159 | +        if self.profiler_support {  | 
 | 160 | +            args.push("--profiler-support".to_owned());  | 
 | 161 | +        }  | 
145 | 162 | 
 
  | 
146 | 163 |         args.push("--rustc-path".to_string());  | 
147 | 164 |         // This is a subtle/fragile thing. On rust-lang CI, there is no global  | 
@@ -340,6 +357,15 @@ fn sanitizers() {  | 
340 | 357 |     assert!(check_ignore(&config, "// needs-sanitizer-thread"));  | 
341 | 358 | }  | 
342 | 359 | 
 
  | 
 | 360 | +#[test]  | 
 | 361 | +fn profiler_support() {  | 
 | 362 | +    let config: Config = cfg().profiler_support(false).build();  | 
 | 363 | +    assert!(check_ignore(&config, "// needs-profiler-support"));  | 
 | 364 | + | 
 | 365 | +    let config: Config = cfg().profiler_support(true).build();  | 
 | 366 | +    assert!(!check_ignore(&config, "// needs-profiler-support"));  | 
 | 367 | +}  | 
 | 368 | + | 
343 | 369 | #[test]  | 
344 | 370 | fn asm_support() {  | 
345 | 371 |     let asms = [  | 
@@ -530,3 +556,17 @@ fn families() {  | 
530 | 556 |         assert!(!check_ignore(&config, &format!("// ignore-{other}")));  | 
531 | 557 |     }  | 
532 | 558 | }  | 
 | 559 | + | 
 | 560 | +#[test]  | 
 | 561 | +fn ignore_mode() {  | 
 | 562 | +    for &mode in Mode::STR_VARIANTS {  | 
 | 563 | +        // Indicate profiler support so that "coverage-run" tests aren't skipped.  | 
 | 564 | +        let config: Config = cfg().mode(mode).profiler_support(true).build();  | 
 | 565 | +        let other = if mode == "coverage-run" { "coverage-map" } else { "coverage-run" };  | 
 | 566 | +        assert_ne!(mode, other);  | 
 | 567 | +        assert_eq!(config.mode, Mode::from_str(mode).unwrap());  | 
 | 568 | +        assert_ne!(config.mode, Mode::from_str(other).unwrap());  | 
 | 569 | +        assert!(check_ignore(&config, &format!("// ignore-mode-{mode}")));  | 
 | 570 | +        assert!(!check_ignore(&config, &format!("// ignore-mode-{other}")));  | 
 | 571 | +    }  | 
 | 572 | +}  | 
0 commit comments