Unverified Commit 35d2308f authored by Randy Eckenrode's avatar Randy Eckenrode
Browse files

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.
parent 075dc285
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -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";
+14 −0
Original line number Diff line number Diff line
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");
+19 −0
Original line number Diff line number Diff line
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 {