Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(libtest): Deprecate '--logfile' #134283

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions library/test/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Module converting command-line arguments into test configuration.

use std::env;
use std::io::{self, IsTerminal};
use std::io::{self, IsTerminal, Write};
use std::path::PathBuf;

use super::options::{ColorConfig, Options, OutputFormat, RunIgnored};
Expand Down Expand Up @@ -58,7 +58,7 @@ fn optgroups() -> getopts::Options {
.optflag("", "bench", "Run benchmarks instead of tests")
.optflag("", "list", "List all tests and benchmarks")
.optflag("h", "help", "Display this message")
.optopt("", "logfile", "Write logs to the specified file", "PATH")
.optopt("", "logfile", "Write logs to the specified file (deprecated)", "PATH")
.optflag(
"",
"nocapture",
Expand Down Expand Up @@ -281,6 +281,10 @@ fn parse_opts_impl(matches: getopts::Matches) -> OptRes {

let options = Options::new().display_output(matches.opt_present("show-output"));

if logfile.is_some() && !format.is_programmatic() {
let _ = write!(io::stdout(), "warning: `--logfile` is deprecated");
}

let test_opts = TestOpts {
list,
filters,
Expand Down
9 changes: 9 additions & 0 deletions library/test/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ pub enum OutputFormat {
Junit,
}

impl OutputFormat {
pub(crate) fn is_programmatic(&self) -> bool {
match self {
Self::Pretty | Self::Terse => false,
Self::Json | Self::Junit => true,
}
}
}

/// Whether ignored test should be run or not
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum RunIgnored {
Expand Down
2 changes: 2 additions & 0 deletions src/doc/rustc/src/tests/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ Controls the format of the output. Valid options:

Writes the results of the tests to the given file.

This option is deprecated.

#### `--report-time`

⚠️ 🚧 This option is [unstable](#unstable-options), and requires the `-Z
Expand Down
Loading