-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace
--show-source
and --no-show-source
with `--output_format=…
…<full|concise>` (#9687) Fixes #7350 ## Summary * `--show-source` and `--no-show-source` are now deprecated. * `output-format` supports two new variants, `full` and `concise`. `text` is now a deprecated variant, and any use of it is treated as the default serialization format. * `--output-format` now default to `concise` * In preview mode, `--output-format` defaults to `full` * `--show-source` will still set `--output-format` to `full` if the output format is not otherwise specified. * likewise, `--no-show-source` can override an output format that was set in a file-based configuration, though it will also be overridden by `--output-format` ## Test Plan A lot of tests were updated to use `--output-format=full`. Additional tests were added to ensure the correct deprecation warnings appeared, and that deprecated options behaved as intended. # Conflicts: # crates/ruff/tests/integration_test.rs
- Loading branch information
Showing
13 changed files
with
352 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
//! A test suite that ensures deprecated command line options have appropriate warnings / behaviors | ||
use ruff_linter::settings::types::SerializationFormat; | ||
use std::process::Command; | ||
|
||
use insta_cmd::{assert_cmd_snapshot, get_cargo_bin}; | ||
|
||
const BIN_NAME: &str = "ruff"; | ||
|
||
const STDIN: &str = "l = 1"; | ||
|
||
fn ruff_check(show_source: Option<bool>, output_format: Option<String>) -> Command { | ||
let mut cmd = Command::new(get_cargo_bin(BIN_NAME)); | ||
let output_format = output_format.unwrap_or(format!("{}", SerializationFormat::default(false))); | ||
cmd.arg("--output-format"); | ||
cmd.arg(output_format); | ||
cmd.arg("--no-cache"); | ||
match show_source { | ||
Some(true) => { | ||
cmd.arg("--show-source"); | ||
} | ||
Some(false) => { | ||
cmd.arg("--no-show-source"); | ||
} | ||
None => {} | ||
} | ||
cmd.arg("-"); | ||
|
||
cmd | ||
} | ||
|
||
#[test] | ||
fn ensure_show_source_is_deprecated() { | ||
assert_cmd_snapshot!(ruff_check(Some(true), None).pass_stdin(STDIN), @r###" | ||
success: false | ||
exit_code: 1 | ||
----- stdout ----- | ||
-:1:1: E741 Ambiguous variable name: `l` | ||
Found 1 error. | ||
----- stderr ----- | ||
warning: The `--show-source` argument is deprecated and has been ignored in favor of `--output-format=concise`. | ||
"###); | ||
} | ||
|
||
#[test] | ||
fn ensure_no_show_source_is_deprecated() { | ||
assert_cmd_snapshot!(ruff_check(Some(false), None).pass_stdin(STDIN), @r###" | ||
success: false | ||
exit_code: 1 | ||
----- stdout ----- | ||
-:1:1: E741 Ambiguous variable name: `l` | ||
Found 1 error. | ||
----- stderr ----- | ||
warning: The `--no-show-source` argument is deprecated and has been ignored in favor of `--output-format=concise`. | ||
"###); | ||
} | ||
|
||
#[test] | ||
fn ensure_output_format_is_deprecated() { | ||
assert_cmd_snapshot!(ruff_check(None, Some("text".into())).pass_stdin(STDIN), @r###" | ||
success: false | ||
exit_code: 1 | ||
----- stdout ----- | ||
-:1:1: E741 Ambiguous variable name: `l` | ||
Found 1 error. | ||
----- stderr ----- | ||
warning: `--output-format=text` is deprecated. Use `--output-format=full` or `--output-format=concise` instead. `text` will be treated as `concise`. | ||
"###); | ||
} | ||
|
||
#[test] | ||
fn ensure_output_format_overrides_show_source() { | ||
assert_cmd_snapshot!(ruff_check(Some(true), Some("concise".into())).pass_stdin(STDIN), @r###" | ||
success: false | ||
exit_code: 1 | ||
----- stdout ----- | ||
-:1:1: E741 Ambiguous variable name: `l` | ||
Found 1 error. | ||
----- stderr ----- | ||
warning: The `--show-source` argument is deprecated and has been ignored in favor of `--output-format=concise`. | ||
"###); | ||
} | ||
|
||
#[test] | ||
fn ensure_full_output_format_overrides_no_show_source() { | ||
assert_cmd_snapshot!(ruff_check(Some(false), Some("full".into())).pass_stdin(STDIN), @r###" | ||
success: false | ||
exit_code: 1 | ||
----- stdout ----- | ||
-:1:1: E741 Ambiguous variable name: `l` | ||
| | ||
1 | l = 1 | ||
| ^ E741 | ||
| | ||
Found 1 error. | ||
----- stderr ----- | ||
warning: The `--no-show-source` argument is deprecated and has been ignored in favor of `--output-format=full`. | ||
"###); | ||
} | ||
|
||
#[test] | ||
fn ensure_output_format_uses_concise_over_no_show_source() { | ||
assert_cmd_snapshot!(ruff_check(Some(false), Some("concise".into())).pass_stdin(STDIN), @r###" | ||
success: false | ||
exit_code: 1 | ||
----- stdout ----- | ||
-:1:1: E741 Ambiguous variable name: `l` | ||
Found 1 error. | ||
----- stderr ----- | ||
warning: The `--no-show-source` argument is deprecated and has been ignored in favor of `--output-format=concise`. | ||
"###); | ||
} | ||
|
||
#[test] | ||
fn ensure_deprecated_output_format_overrides_show_source() { | ||
assert_cmd_snapshot!(ruff_check(Some(true), Some("text".into())).pass_stdin(STDIN), @r###" | ||
success: false | ||
exit_code: 1 | ||
----- stdout ----- | ||
-:1:1: E741 Ambiguous variable name: `l` | ||
Found 1 error. | ||
----- stderr ----- | ||
warning: The `--show-source` argument is deprecated and has been ignored in favor of `--output-format=text`. | ||
warning: `--output-format=text` is deprecated. Use `--output-format=full` or `--output-format=concise` instead. `text` will be treated as `concise`. | ||
"###); | ||
} | ||
|
||
#[test] | ||
fn ensure_deprecated_output_format_overrides_no_show_source() { | ||
assert_cmd_snapshot!(ruff_check(Some(false), Some("text".into())).pass_stdin(STDIN), @r###" | ||
success: false | ||
exit_code: 1 | ||
----- stdout ----- | ||
-:1:1: E741 Ambiguous variable name: `l` | ||
Found 1 error. | ||
----- stderr ----- | ||
warning: The `--no-show-source` argument is deprecated and has been ignored in favor of `--output-format=text`. | ||
warning: `--output-format=text` is deprecated. Use `--output-format=full` or `--output-format=concise` instead. `text` will be treated as `concise`. | ||
"###); | ||
} |
Oops, something went wrong.