Skip to content

Commit e99364e

Browse files
committed
Remove old-output-capture from compiletest
1 parent cc7bd29 commit e99364e

File tree

3 files changed

+10
-66
lines changed

3 files changed

+10
-66
lines changed

src/tools/compiletest/src/common.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -661,18 +661,10 @@ pub struct Config {
661661
pub builtin_cfg_names: OnceLock<HashSet<String>>,
662662
pub supported_crate_types: OnceLock<HashSet<String>>,
663663

664-
/// FIXME: this is why we still need to depend on *staged* `std`, it's because we currently rely
665-
/// on `#![feature(internal_output_capture)]` for [`std::io::set_output_capture`] to implement
666-
/// `libtest`-esque `--no-capture`.
667-
///
668664
/// FIXME: rename this to the more canonical `no_capture`, or better, invert this to `capture`
669665
/// to avoid `!nocapture` double-negatives.
670666
pub nocapture: bool,
671667

672-
/// True if the experimental new output-capture implementation should be
673-
/// used, avoiding the need for `#![feature(internal_output_capture)]`.
674-
pub new_output_capture: bool,
675-
676668
/// Needed both to construct [`build_helper::git::GitConfig`].
677669
pub nightly_branch: String,
678670
pub git_merge_commit_email: String,
@@ -790,7 +782,6 @@ impl Config {
790782
builtin_cfg_names: Default::default(),
791783
supported_crate_types: Default::default(),
792784
nocapture: Default::default(),
793-
new_output_capture: Default::default(),
794785
nightly_branch: Default::default(),
795786
git_merge_commit_email: Default::default(),
796787
profiler_runtime: Default::default(),

src/tools/compiletest/src/executor.rs

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use std::borrow::Cow;
99
use std::collections::HashMap;
1010
use std::hash::{BuildHasherDefault, DefaultHasher};
1111
use std::num::NonZero;
12-
use std::sync::{Arc, Mutex, mpsc};
13-
use std::{env, hint, io, mem, panic, thread};
12+
use std::sync::{Arc, mpsc};
13+
use std::{env, hint, mem, panic, thread};
1414

1515
use camino::Utf8PathBuf;
1616

@@ -130,10 +130,6 @@ fn run_test_inner(
130130
panic_hook::set_capture_buf(Default::default());
131131
}
132132

133-
if let CaptureKind::Old { ref buf } = capture {
134-
io::set_output_capture(Some(Arc::clone(buf)));
135-
}
136-
137133
let stdout = capture.stdout();
138134
let stderr = capture.stderr();
139135

@@ -144,9 +140,6 @@ fn run_test_inner(
144140
// Forward any captured panic message to (captured) stderr.
145141
write!(stderr, "{panic_buf}");
146142
}
147-
if matches!(capture, CaptureKind::Old { .. }) {
148-
io::set_output_capture(None);
149-
}
150143

151144
let outcome = match (should_panic, panic_payload) {
152145
(ShouldPanic::No, None) | (ShouldPanic::Yes, Some(_)) => TestOutcome::Succeeded,
@@ -167,31 +160,24 @@ enum CaptureKind {
167160
/// runners, whose output is always captured.)
168161
None,
169162

170-
/// Use the old output-capture implementation, which relies on the unstable
171-
/// library feature `#![feature(internal_output_capture)]`.
172-
Old { buf: Arc<Mutex<Vec<u8>>> },
173-
174-
/// Use the new output-capture implementation, which only uses stable Rust.
175-
New { buf: output_capture::CaptureBuf },
163+
/// Capture all console output that would be printed by test runners via
164+
/// their `stdout` and `stderr` trait objects, or via the custom panic hook.
165+
Capture { buf: output_capture::CaptureBuf },
176166
}
177167

178168
impl CaptureKind {
179169
fn for_config(config: &Config) -> Self {
180170
if config.nocapture {
181171
Self::None
182-
} else if config.new_output_capture {
183-
Self::New { buf: output_capture::CaptureBuf::new() }
184172
} else {
185-
// Create a capure buffer for `io::set_output_capture`.
186-
Self::Old { buf: Default::default() }
173+
Self::Capture { buf: output_capture::CaptureBuf::new() }
187174
}
188175
}
189176

190177
fn should_set_panic_hook(&self) -> bool {
191178
match self {
192179
Self::None => false,
193-
Self::Old { .. } => true,
194-
Self::New { .. } => true,
180+
Self::Capture { .. } => true,
195181
}
196182
}
197183

@@ -205,16 +191,15 @@ impl CaptureKind {
205191

206192
fn capture_buf_or<'a>(&'a self, fallback: &'a dyn ConsoleOut) -> &'a dyn ConsoleOut {
207193
match self {
208-
Self::None | Self::Old { .. } => fallback,
209-
Self::New { buf } => buf,
194+
Self::None => fallback,
195+
Self::Capture { buf } => buf,
210196
}
211197
}
212198

213199
fn into_inner(self) -> Option<Vec<u8>> {
214200
match self {
215201
Self::None => None,
216-
Self::Old { buf } => Some(buf.lock().unwrap_or_else(|e| e.into_inner()).to_vec()),
217-
Self::New { buf } => Some(buf.into_inner().into()),
202+
Self::Capture { buf } => Some(buf.into_inner().into()),
218203
}
219204
}
220205
}

src/tools/compiletest/src/lib.rs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
#![crate_name = "compiletest"]
2-
// Needed by the "new" test executor that does not depend on libtest.
3-
// FIXME(Zalathar): We should be able to get rid of `internal_output_capture`,
4-
// by having `runtest` manually capture all of its println-like output instead.
5-
// That would result in compiletest being written entirely in stable Rust!
6-
#![feature(internal_output_capture)]
72

83
#[cfg(test)]
94
mod tests;
@@ -178,12 +173,6 @@ pub fn parse_config(args: Vec<String>) -> Config {
178173
// FIXME: Temporarily retained so we can point users to `--no-capture`
179174
.optflag("", "nocapture", "")
180175
.optflag("", "no-capture", "don't capture stdout/stderr of tests")
181-
.optopt(
182-
"N",
183-
"new-output-capture",
184-
"enables or disables the new output-capture implementation",
185-
"off|on",
186-
)
187176
.optflag("", "profiler-runtime", "is the profiler runtime enabled for this target")
188177
.optflag("h", "help", "show this message")
189178
.reqopt("", "channel", "current Rust channel", "CHANNEL")
@@ -480,14 +469,6 @@ pub fn parse_config(args: Vec<String>) -> Config {
480469
supported_crate_types: OnceLock::new(),
481470

482471
nocapture: matches.opt_present("no-capture"),
483-
new_output_capture: {
484-
let value = matches
485-
.opt_str("new-output-capture")
486-
.or_else(|| env::var("COMPILETEST_NEW_OUTPUT_CAPTURE").ok())
487-
.unwrap_or_else(|| "on".to_owned());
488-
parse_bool_option(&value)
489-
.unwrap_or_else(|| panic!("unknown `--new-output-capture` value `{value}` given"))
490-
},
491472

492473
nightly_branch: matches.opt_str("nightly-branch").unwrap(),
493474
git_merge_commit_email: matches.opt_str("git-merge-commit-email").unwrap(),
@@ -503,19 +484,6 @@ pub fn parse_config(args: Vec<String>) -> Config {
503484
}
504485
}
505486

506-
/// Parses the same set of boolean values accepted by rustc command-line arguments.
507-
///
508-
/// Accepting all of these values is more complicated than just picking one
509-
/// pair, but has the advantage that contributors who are used to rustc
510-
/// shouldn't have to think about which values are legal.
511-
fn parse_bool_option(value: &str) -> Option<bool> {
512-
match value {
513-
"off" | "no" | "n" | "false" => Some(false),
514-
"on" | "yes" | "y" | "true" => Some(true),
515-
_ => None,
516-
}
517-
}
518-
519487
pub fn opt_str(maybestr: &Option<String>) -> &str {
520488
match *maybestr {
521489
None => "(none)",

0 commit comments

Comments
 (0)