queue: self.queue,
// 100 here is somewhat arbitrary. It is a few screenfulls of
// output, and hopefully at most a few megabytes of memory for
- // typical messages.
+ // typical messages. If you change this, please update the test
+ // caching_large_output, too.
messages: Arc::new(Queue::new(100)),
active: HashMap::new(),
compiled: HashSet::new(),
)
.run();
}
+
+#[cargo_test]
+fn caching_large_output() {
+ // Handles large number of messages.
+ // This is an arbitrary amount that is greater than the 100 used in
+ // job_queue. This is here to check for deadlocks or any other problems.
+ const COUNT: usize = 250;
+ let rustc = project()
+ .at("rustc")
+ .file("Cargo.toml", &basic_manifest("rustc_alt", "1.0.0"))
+ .file(
+ "src/main.rs",
+ &format!(
+ r#"
+ fn main() {{
+ for i in 0..{} {{
+ eprintln!("{{{{\"message\": \"test message {{}}\", \"level\": \"warning\", \
+ \"spans\": [], \"children\": [], \"rendered\": \"test message {{}}\"}}}}",
+ i, i);
+ }}
+ let r = std::process::Command::new("rustc")
+ .args(std::env::args_os().skip(1))
+ .status();
+ std::process::exit(r.unwrap().code().unwrap_or(2));
+ }}
+ "#,
+ COUNT
+ ),
+ )
+ .build();
+
+ let mut expected = String::new();
+ for i in 0..COUNT {
+ expected.push_str(&format!("test message {}\n", i));
+ }
+
+ rustc.cargo("build").run();
+ let p = project().file("src/lib.rs", "").build();
+ p.cargo("check")
+ .env("RUSTC", rustc.bin("rustc_alt"))
+ .with_stderr(&format!(
+ "\
+[CHECKING] foo [..]
+{}[FINISHED] dev [..]
+",
+ expected
+ ))
+ .run();
+
+ p.cargo("check")
+ .env("RUSTC", rustc.bin("rustc_alt"))
+ .with_stderr(&format!(
+ "\
+{}[FINISHED] dev [..]
+",
+ expected
+ ))
+ .run();
+}