From 35d2308f61a7ff032d4dbaf52e84b40d6129da13 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Fri, 11 Oct 2024 17:52:53 -0400 Subject: [PATCH] rcodesign: fix failing tests - Ensure that uutils-coreutils is available for cli_tests; - Fix logging (needed for cli_tests); and - Disable tests that require network access. --- pkgs/development/tools/rcodesign/default.nix | 19 +++++++++++++++++++ .../disable-sign-for-notarization-test.patch | 14 ++++++++++++++ .../tools/rcodesign/fix-verbosity-level.patch | 19 +++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 pkgs/development/tools/rcodesign/disable-sign-for-notarization-test.patch create mode 100644 pkgs/development/tools/rcodesign/fix-verbosity-level.patch diff --git a/pkgs/development/tools/rcodesign/default.nix b/pkgs/development/tools/rcodesign/default.nix index 15636a651437..73434ba95ef0 100644 --- a/pkgs/development/tools/rcodesign/default.nix +++ b/pkgs/development/tools/rcodesign/default.nix @@ -3,6 +3,7 @@ , rustPlatform , fetchFromGitHub , darwin +, uutils-coreutils }: rustPlatform.buildRustPackage rec { @@ -24,6 +25,13 @@ rustPlatform.buildRustPackage rec { ./update-time-rs-in-cargo-lock.patch ]; + patches = [ + # Fix rcodesign’s verbosity level to set the logging level as intended. Needed for cli_tests. + ./fix-verbosity-level.patch + # Disable cli_tests test that requires network access. + ./disable-sign-for-notarization-test.patch + ]; + cargoHash = "sha256-VrexypkCW58asvzXo3wj/Rgi72tiGuchA31BkEZoYpI="; @@ -36,8 +44,19 @@ rustPlatform.buildRustPackage rec { checkFlags = [ # Does network IO "--skip=ticket_lookup::test::lookup_ticket" + # These tests require Xcode to be installed + "--skip=find_all_platform_directories" + "--skip=find_all_sdks" ]; + # Set up uutils-coreutils for cli_tests. Without this, it will be installed with `cargo install`, which will fail + # due to the lack of network access in the build environment. + preCheck = '' + coreutils_dir=''${CARGO_TARGET_DIR:-"$(pwd)/target"}/${stdenv.hostPlatform.rust.cargoShortTarget}/coreutils/bin + install -m 755 -d "$coreutils_dir" + ln -s '${lib.getExe' uutils-coreutils "uutils-coreutils"}' "$coreutils_dir/coreutils" + ''; + meta = with lib; { description = "Cross-platform CLI interface to interact with Apple code signing"; mainProgram = "rcodesign"; diff --git a/pkgs/development/tools/rcodesign/disable-sign-for-notarization-test.patch b/pkgs/development/tools/rcodesign/disable-sign-for-notarization-test.patch new file mode 100644 index 000000000000..ce48e30bbea1 --- /dev/null +++ b/pkgs/development/tools/rcodesign/disable-sign-for-notarization-test.patch @@ -0,0 +1,14 @@ +diff --git a/apple-codesign/tests/cli_tests.rs b/apple-codesign/tests/cli_tests.rs +index 22166712ec..8721a92753 100644 +--- a/apple-codesign/tests/cli_tests.rs ++++ b/apple-codesign/tests/cli_tests.rs +@@ -271,6 +271,9 @@ + + cases.case("tests/cmd/*.trycmd").case("tests/cmd/*.toml"); + ++ // Disable in nixpkgs because it requires network access ++ cases.skip("tests/cmd/sign-for-notarization.trycmd"); ++ + // Help output breaks without notarize feature. + if cfg!(not(feature = "notarize")) { + cases.skip("tests/cmd/encode-app-store-connect-api-key.trycmd"); diff --git a/pkgs/development/tools/rcodesign/fix-verbosity-level.patch b/pkgs/development/tools/rcodesign/fix-verbosity-level.patch new file mode 100644 index 000000000000..5d134bd71165 --- /dev/null +++ b/pkgs/development/tools/rcodesign/fix-verbosity-level.patch @@ -0,0 +1,19 @@ +diff --git a/apple-codesign/src/cli/mod.rs b/apple-codesign/src/cli/mod.rs +index 53e9649271..82d4d061a6 100644 +--- a/apple-codesign/src/cli/mod.rs ++++ b/apple-codesign/src/cli/mod.rs +@@ -2499,9 +2499,11 @@ + _ => LevelFilter::Trace, + }; + +- let mut builder = env_logger::Builder::from_env( +- env_logger::Env::default().default_filter_or(log_level.as_str()), +- ); ++ let mut builder = env_logger::Builder::new(); ++ ++ builder ++ .filter_level(log_level) ++ .parse_default_env(); + + // Disable log context except at higher log levels. + if log_level <= LevelFilter::Info {