Merge pull request #197478 from CobaltCause/add-cargo-llvm-cov

cargo-llvm-cov: fix tests, mark broken as needed

authored by Matthias Beyer and committed by GitHub ac1367d4 6ef5ca47

+66 -23
+66 -23
pkgs/development/tools/rust/cargo-llvm-cov/default.nix
··· 1 { stdenv 2 , lib 3 - , fetchCrate 4 , rustPlatform 5 }: 6 7 - rustPlatform.buildRustPackage rec { 8 pname = "cargo-llvm-cov"; 9 version = "0.5.31"; 10 11 - src = fetchCrate { 12 - inherit pname version; 13 - sha256 = "sha256-HjnP9H1t660PJ5eXzgAhrdDEgqdzzb+9Dbk5RGUPjaQ="; 14 }; 15 - cargoSha256 = "sha256-p6zpRRNX4g+jESNSwouWMjZlFhTBFJhe7LirYtFrZ1g="; 16 17 - # skip tests which require llvm-tools-preview 18 - checkFlags = [ 19 - "--skip bin_crate" 20 - "--skip cargo_config" 21 - "--skip clean_ws" 22 - "--skip instantiations" 23 - "--skip merge" 24 - "--skip merge_failure_mode_all" 25 - "--skip no_test" 26 - "--skip open_report" 27 - "--skip real1" 28 - "--skip show_env" 29 - "--skip virtual1" 30 - ]; 31 32 - meta = rec { 33 - homepage = "https://github.com/taiki-e/${pname}"; 34 changelog = homepage + "/blob/v${version}/CHANGELOG.md"; 35 description = "Cargo subcommand to easily use LLVM source-based code coverage"; 36 longDescription = '' ··· 39 library (e.g. fenix or rust-overlay) 40 ''; 41 license = with lib.licenses; [ asl20 /* or */ mit ]; 42 - maintainers = with lib.maintainers; [ wucke13 matthiasbeyer ]; 43 }; 44 }
··· 1 + # If the tests are broken, it's probably for one of two reasons: 2 + # 3 + # 1. The version of llvm used doesn't match the expectations of rustc and/or 4 + # cargo-llvm-cov. This is relatively unlikely because we pull llvm out of 5 + # rustc's attrset, so it *should* be the right version as long as this is the 6 + # case. 7 + # 2. Nixpkgs has changed its rust infrastructure in a way that causes 8 + # cargo-llvm-cov to misbehave under test. It's likely that even though the 9 + # tests are failing, cargo-llvm-cov will still function properly in actual 10 + # use. This has happened before, and is described [here][0] (along with a 11 + # feature request that would fix this instance of the problem). 12 + # 13 + # For previous test-troubleshooting discussion, see [here][1]. 14 + # 15 + # [0]: https://github.com/taiki-e/cargo-llvm-cov/issues/242 16 + # [1]: https://github.com/NixOS/nixpkgs/pull/197478 17 + 18 { stdenv 19 , lib 20 + , fetchurl 21 + , fetchFromGitHub 22 , rustPlatform 23 + , rustc 24 }: 25 26 + let 27 pname = "cargo-llvm-cov"; 28 version = "0.5.31"; 29 30 + owner = "taiki-e"; 31 + homepage = "https://github.com/${owner}/${pname}"; 32 + 33 + llvm = rustc.llvmPackages.llvm; 34 + 35 + # Download `Cargo.lock` from crates.io so we don't clutter up Nixpkgs 36 + cargoLock = fetchurl { 37 + name = "Cargo.lock"; 38 + url = "https://crates.io/api/v1/crates/${pname}/${version}/download"; 39 + sha256 = "sha256-BbrdyJgZSIz6GaTdQv1GiFHufRBSbcoHcqqEmr/HvAM="; 40 + downloadToTemp = true; 41 + postFetch = '' 42 + tar xzf $downloadedFile ${pname}-${version}/Cargo.lock 43 + mv ${pname}-${version}/Cargo.lock $out 44 + ''; 45 + }; 46 + in 47 + 48 + rustPlatform.buildRustPackage { 49 + inherit pname version; 50 + 51 + # Use `fetchFromGitHub` instead of `fetchCrate` because the latter does not 52 + # pull in fixtures needed for the test suite 53 + src = fetchFromGitHub { 54 + inherit owner; 55 + repo = pname; 56 + rev = "v${version}"; 57 + sha256 = "sha256-wRo94JVn4InkhrMHFSsEvm2FFIxUsltA57sMMOcL8b0="; 58 }; 59 60 + # Upstream doesn't include the lockfile so we need to add it back 61 + postUnpack = '' 62 + cp ${cargoLock} source/Cargo.lock 63 + ''; 64 + 65 + cargoSha256 = "sha256-XcsognndhHenYnlJCNMbrNh+S8FX7qxXUjuV1j2qsmY="; 66 67 + # `cargo-llvm-cov` reads these environment variables to find these binaries, 68 + # which are needed to run the tests 69 + LLVM_COV = "${llvm}/bin/llvm-cov"; 70 + LLVM_PROFDATA = "${llvm}/bin/llvm-profdata"; 71 + 72 + meta = { 73 + inherit homepage; 74 changelog = homepage + "/blob/v${version}/CHANGELOG.md"; 75 description = "Cargo subcommand to easily use LLVM source-based code coverage"; 76 longDescription = '' ··· 79 library (e.g. fenix or rust-overlay) 80 ''; 81 license = with lib.licenses; [ asl20 /* or */ mit ]; 82 + maintainers = with lib.maintainers; [ wucke13 matthiasbeyer CobaltCause ]; 83 + 84 + # The profiler runtime is (currently) disabled on non-Linux platforms 85 + broken = !(stdenv.isLinux && !stdenv.targetPlatform.isRedox); 86 }; 87 }