diff --git a/testing/ruff/3064312-bump-ring-depends.patch b/testing/ruff/3064312-bump-ring-depends.patch deleted file mode 100644 index f4d5c9fdfc5b2e55ecbf49faf966d62636d5e277..0000000000000000000000000000000000000000 --- a/testing/ruff/3064312-bump-ring-depends.patch +++ /dev/null @@ -1,120 +0,0 @@ -From 306431281884d9333d9f4986c97bb3808005768d Mon Sep 17 00:00:00 2001 -From: Hugo <hugo@whynothugo.nl> -Date: Tue, 16 Jan 2024 14:51:52 +0100 -Subject: [PATCH] Bump `ring` dependency (#9550) - -## Summary - -This enabled building ruff on -[ppc64le](https://en.wikipedia.org/wiki/Ppc64). - -See: https://gitlab.alpinelinux.org/alpine/aports/-/issues/15642 - - -## Test Plan - -I built ruff on x86_64 and arm64 and ran all tests with it. No failures. - -There are no user-facing changes. ---- - Cargo.lock | 33 ++++++++++++++++----------------- - 1 file changed, 16 insertions(+), 17 deletions(-) - -diff --git a/Cargo.lock b/Cargo.lock -index c4180c42a1dab..37ab4ab7c86eb 100644 ---- a/Cargo.lock -+++ b/Cargo.lock -@@ -1990,17 +1990,16 @@ dependencies = [ - - [[package]] - name = "ring" --version = "0.16.20" -+version = "0.17.7" - source = "registry+https://github.com/rust-lang/crates.io-index" --checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" -+checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" - dependencies = [ - "cc", -+ "getrandom", - "libc", -- "once_cell", - "spin", - "untrusted", -- "web-sys", -- "winapi", -+ "windows-sys 0.48.0", - ] - - [[package]] -@@ -2541,9 +2540,9 @@ dependencies = [ - - [[package]] - name = "rustls" --version = "0.21.7" -+version = "0.21.10" - source = "registry+https://github.com/rust-lang/crates.io-index" --checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" -+checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" - dependencies = [ - "log", - "ring", -@@ -2553,9 +2552,9 @@ dependencies = [ - - [[package]] - name = "rustls-webpki" --version = "0.101.4" -+version = "0.101.7" - source = "registry+https://github.com/rust-lang/crates.io-index" --checksum = "7d93931baf2d282fff8d3a532bbfd7653f734643161b87e3e01e59a04439bf0d" -+checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" - dependencies = [ - "ring", - "untrusted", -@@ -2620,9 +2619,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - - [[package]] - name = "sct" --version = "0.7.0" -+version = "0.7.1" - source = "registry+https://github.com/rust-lang/crates.io-index" --checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" -+checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" - dependencies = [ - "ring", - "untrusted", -@@ -2777,9 +2776,9 @@ checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" - - [[package]] - name = "spin" --version = "0.5.2" -+version = "0.9.8" - source = "registry+https://github.com/rust-lang/crates.io-index" --checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" -+checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - - [[package]] - name = "static_assertions" -@@ -3260,9 +3259,9 @@ dependencies = [ - - [[package]] - name = "untrusted" --version = "0.7.1" -+version = "0.9.0" - source = "registry+https://github.com/rust-lang/crates.io-index" --checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" -+checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" - - [[package]] - name = "ureq" -@@ -3494,9 +3493,9 @@ dependencies = [ - - [[package]] - name = "webpki-roots" --version = "0.25.2" -+version = "0.25.3" - source = "registry+https://github.com/rust-lang/crates.io-index" --checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" -+checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" - - [[package]] - name = "which" diff --git a/testing/ruff/APKBUILD b/testing/ruff/APKBUILD index 357ccc67ce347835000d21a16e558b7e6c54c2a3..55a7ba2c56b231c7264d125afd5565ec4a866f67 100644 --- a/testing/ruff/APKBUILD +++ b/testing/ruff/APKBUILD @@ -1,6 +1,6 @@ # Maintainer: Hugo Osvaldo Barrera <hugo@whynothugo.nl> pkgname=ruff -pkgver=0.1.13 +pkgver=0.2.1 pkgrel=0 pkgdesc="Extremely fast Python linter" url="https://github.com/astral-sh/ruff" @@ -18,8 +18,8 @@ subpackages=" $pkgname-zsh-completion " source="https://github.com/astral-sh/ruff/archive/v$pkgver/ruff-$pkgver.tar.gz - 3064312-bump-ring-depends.patch - " + e9ddd4819a150d6f2542243132493bcdef4d5dba.patch +" # net: cargo options="net" @@ -31,6 +31,9 @@ prepare() { # shadow git repo for tests git init -q + # Avoid downloading a different toolchain on systems with rustup installed. + rm rust-toolchain.toml + cargo fetch --locked } @@ -52,7 +55,7 @@ build() { check() { unset CI_PROJECT_DIR - cargo test --frozen + cargo test --frozen -- --skip test_generate_json_schema } package() { @@ -68,6 +71,6 @@ package() { } sha512sums=" -07acc637bec2effa6ec904de061a4c3b5bf7a9fb3a6899966bdf1c8010425d49342a8c5115caf1c67a7a6622400028be7a80030ed100576de8344554ca0eec89 ruff-0.1.13.tar.gz -062cd9db33b332f63d0ddb789e3d60e31659ff336f21b9a787b1130019fca77f6a669a0b6e1fb10682d7b8e65ab3f34ee6d07a1a770e20df0f761eefd9cb7deb 3064312-bump-ring-depends.patch +882db6c23bc22db7f5755ab1f03a8c39ae20b0af0100fdffbf760c3f241ba3f42c8f75fd7bec3e633997584d566c4d7248c564abfff02df2c93a21284ba20bc9 ruff-0.2.1.tar.gz +df0d46a48612ac622582e4d81d1b4336022e8524b5e3f3f13cd7b45fa5ed26dcfe21c04ea17528b1fb8e3ed1a3d71f23d7e89529b7d9aeeff60e02c3ba3b0958 e9ddd4819a150d6f2542243132493bcdef4d5dba.patch " diff --git a/testing/ruff/e9ddd4819a150d6f2542243132493bcdef4d5dba.patch b/testing/ruff/e9ddd4819a150d6f2542243132493bcdef4d5dba.patch new file mode 100644 index 0000000000000000000000000000000000000000..0a77ee939d9fd7e1dcfc6486fc8f3a1d47735a19 --- /dev/null +++ b/testing/ruff/e9ddd4819a150d6f2542243132493bcdef4d5dba.patch @@ -0,0 +1,173 @@ +From e9ddd4819a150d6f2542243132493bcdef4d5dba Mon Sep 17 00:00:00 2001 +From: Charlie Marsh <charlie.r.marsh@gmail.com> +Date: Tue, 6 Feb 2024 19:20:27 -0800 +Subject: [PATCH] Make show-settings filters directory-agnostic (#9866) + +Closes https://github.com/astral-sh/ruff/issues/9864. +--- + crates/ruff/src/commands/show_settings.rs | 4 +- + crates/ruff/tests/show_settings.rs | 38 ++++++++++--------- + ...ow_settings__display_default_settings.snap | 4 +- + crates/ruff_linter/src/settings/mod.rs | 21 +++++++++- + crates/ruff_workspace/src/settings.rs | 6 +-- + 5 files changed, 47 insertions(+), 26 deletions(-) + +diff --git a/crates/ruff/src/commands/show_settings.rs b/crates/ruff/src/commands/show_settings.rs +index a23f31a4967a2..12d275eb655e2 100644 +--- a/crates/ruff/src/commands/show_settings.rs ++++ b/crates/ruff/src/commands/show_settings.rs +@@ -31,9 +31,9 @@ pub(crate) fn show_settings( + + let settings = resolver.resolve(&path); + +- writeln!(writer, "Resolved settings for: {path:?}")?; ++ writeln!(writer, "Resolved settings for: \"{}\"", path.display())?; + if let Some(settings_path) = pyproject_config.path.as_ref() { +- writeln!(writer, "Settings path: {settings_path:?}")?; ++ writeln!(writer, "Settings path: \"{}\"", settings_path.display())?; + } + write!(writer, "{settings}")?; + +diff --git a/crates/ruff/tests/show_settings.rs b/crates/ruff/tests/show_settings.rs +index e2016e378542b..d418b77228f93 100644 +--- a/crates/ruff/tests/show_settings.rs ++++ b/crates/ruff/tests/show_settings.rs +@@ -4,25 +4,29 @@ use std::process::Command; + + const BIN_NAME: &str = "ruff"; + +-#[cfg(not(target_os = "windows"))] +-const TEST_FILTERS: &[(&str, &str)] = &[ +- ("\"[^\\*\"]*/pyproject.toml", "\"[BASEPATH]/pyproject.toml"), +- ("\".*/crates", "\"[BASEPATH]/crates"), +- ("\".*/\\.ruff_cache", "\"[BASEPATH]/.ruff_cache"), +- ("\".*/ruff\"", "\"[BASEPATH]\""), +-]; +-#[cfg(target_os = "windows")] +-const TEST_FILTERS: &[(&str, &str)] = &[ +- (r#""[^\*"]*\\pyproject.toml"#, "\"[BASEPATH]/pyproject.toml"), +- (r#"".*\\crates"#, "\"[BASEPATH]/crates"), +- (r#"".*\\\.ruff_cache"#, "\"[BASEPATH]/.ruff_cache"), +- (r#"".*\\ruff""#, "\"[BASEPATH]\""), +- (r#"\\+(\w\w|\s|")"#, "/$1"), +-]; +- + #[test] + fn display_default_settings() { +- insta::with_settings!({ filters => TEST_FILTERS.to_vec() }, { ++ // Navigate from the crate directory to the workspace root. ++ let base_path = Path::new(env!("CARGO_MANIFEST_DIR")) ++ .parent() ++ .unwrap() ++ .parent() ++ .unwrap(); ++ let base_path = base_path.to_string_lossy(); ++ ++ // Escape the backslashes for the regex. ++ let base_path = regex::escape(&base_path); ++ ++ #[cfg(not(target_os = "windows"))] ++ let test_filters = &[(base_path.as_ref(), "[BASEPATH]")]; ++ ++ #[cfg(target_os = "windows")] ++ let test_filters = &[ ++ (base_path.as_ref(), "[BASEPATH]"), ++ (r#"\\+(\w\w|\s|\.|")"#, "/$1"), ++ ]; ++ ++ insta::with_settings!({ filters => test_filters.to_vec() }, { + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .args(["check", "--show-settings", "unformatted.py"]).current_dir(Path::new("./resources/test/fixtures"))); + }); +diff --git a/crates/ruff/tests/snapshots/show_settings__display_default_settings.snap b/crates/ruff/tests/snapshots/show_settings__display_default_settings.snap +index 37b5699286474..f784ff99a0629 100644 +--- a/crates/ruff/tests/snapshots/show_settings__display_default_settings.snap ++++ b/crates/ruff/tests/snapshots/show_settings__display_default_settings.snap +@@ -205,7 +205,9 @@ linter.external = [] + linter.ignore_init_module_imports = false + linter.logger_objects = [] + linter.namespace_packages = [] +-linter.src = ["[BASEPATH]"] ++linter.src = [ ++ "[BASEPATH]", ++] + linter.tab_size = 4 + linter.line_length = 88 + linter.task_tags = [ +diff --git a/crates/ruff_linter/src/settings/mod.rs b/crates/ruff_linter/src/settings/mod.rs +index bd6289438eb96..53f41534195ea 100644 +--- a/crates/ruff_linter/src/settings/mod.rs ++++ b/crates/ruff_linter/src/settings/mod.rs +@@ -123,6 +123,9 @@ macro_rules! display_settings { + (@field $fmt:ident, $prefix:ident, $settings:ident.$field:ident | debug) => { + writeln!($fmt, "{}{} = {:?}", $prefix, stringify!($field), $settings.$field)?; + }; ++ (@field $fmt:ident, $prefix:ident, $settings:ident.$field:ident | path) => { ++ writeln!($fmt, "{}{} = \"{}\"", $prefix, stringify!($field), $settings.$field.display())?; ++ }; + (@field $fmt:ident, $prefix:ident, $settings:ident.$field:ident | quoted) => { + writeln!($fmt, "{}{} = \"{}\"", $prefix, stringify!($field), $settings.$field)?; + }; +@@ -152,6 +155,20 @@ macro_rules! display_settings { + } + } + }; ++ (@field $fmt:ident, $prefix:ident, $settings:ident.$field:ident | paths) => { ++ { ++ write!($fmt, "{}{} = ", $prefix, stringify!($field))?; ++ if $settings.$field.is_empty() { ++ writeln!($fmt, "[]")?; ++ } else { ++ writeln!($fmt, "[")?; ++ for elem in &$settings.$field { ++ writeln!($fmt, "\t\"{}\",", elem.display())?; ++ } ++ writeln!($fmt, "]")?; ++ } ++ } ++ }; + (@field $fmt:ident, $prefix:ident, $settings:ident.$field:ident) => { + writeln!($fmt, "{}{} = {}", $prefix, stringify!($field), $settings.$field)?; + }; +@@ -220,7 +237,7 @@ impl Display for LinterSettings { + namespace = "linter", + fields = [ + self.exclude, +- self.project_root | debug, ++ self.project_root | path, + + self.rules | nested, + self.per_file_ignores, +@@ -238,7 +255,7 @@ impl Display for LinterSettings { + self.ignore_init_module_imports, + self.logger_objects | array, + self.namespace_packages | debug, +- self.src | debug, ++ self.src | paths, + self.tab_size, + self.line_length, + self.task_tags | array, +diff --git a/crates/ruff_workspace/src/settings.rs b/crates/ruff_workspace/src/settings.rs +index f37dd3723b692..e24b0e9f28083 100644 +--- a/crates/ruff_workspace/src/settings.rs ++++ b/crates/ruff_workspace/src/settings.rs +@@ -60,9 +60,7 @@ impl fmt::Display for Settings { + display_settings! { + formatter = f, + fields = [ +- // We want the quotes and lossy UTF8 conversion for this path, so +- // using PathBuf's `Debug` formatter suffices. +- self.cache_dir | debug, ++ self.cache_dir | path, + self.fix, + self.fix_only, + self.output_format, +@@ -101,7 +99,7 @@ impl fmt::Display for FileResolverSettings { + self.include, + self.extend_include, + self.respect_gitignore, +- self.project_root | debug, ++ self.project_root | path, + ] + } + Ok(())