cargo-benchcmp: init at 0.4.4

https://github.com/BurntSushi/cargo-benchcmp
This commit is contained in:
figsoda 2023-05-21 11:52:19 -04:00
parent 4916216d76
commit ab2095c815
3 changed files with 72 additions and 0 deletions

View file

@ -0,0 +1,41 @@
{ lib
, rustPlatform
, fetchFromGitHub
, substituteAll
, rust
, stdenv
}:
rustPlatform.buildRustPackage rec {
pname = "cargo-benchcmp";
version = "0.4.4";
src = fetchFromGitHub {
owner = "BurntSushi";
repo = "cargo-benchcmp";
rev = version;
hash = "sha256-pg3/VUC1DQ7GbSQDfVZ0WNisXvzXy0O0pr2ik2ar2h0=";
};
cargoHash = "sha256-vxy9Ym3Twx034I1E5fWNnbP1ttfLolMbO1IgRiPfhRw=";
patches = [
# patch the binary path so tests can find the binary when `--target` is present
(substituteAll {
src = ./fix-test-binary-path.patch;
shortTarget = rust.toRustTarget stdenv.hostPlatform;
})
];
checkFlags = [
# thread 'different_input_colored' panicked at 'assertion failed: `(left == right)`
"--skip=different_input_colored"
];
meta = with lib; {
description = "A small utility to compare Rust micro-benchmarks";
homepage = "https://github.com/BurntSushi/cargo-benchcmp";
license = with licenses; [ mit unlicense ];
maintainers = with maintainers; [ figsoda ];
};
}

View file

@ -0,0 +1,30 @@
--- a/tests/integration.rs
+++ b/tests/integration.rs
@@ -16,20 +16,13 @@ impl CommandUnderTest {
fn new() -> CommandUnderTest {
// To find the directory where the built binary is, we walk up the directory tree of the test binary until the
// parent is "target/".
- let mut binary_path = env::current_exe().expect("need current binary path to find binary to test");
- loop {
- {
- let parent = binary_path.parent();
- if parent.is_none() {
- panic!("Failed to locate binary path from original path: {:?}", env::current_exe());
- }
- let parent = parent.unwrap();
- if parent.is_dir() && parent.file_name().unwrap() == "target" {
- break;
- }
- }
- binary_path.pop();
- }
+ let mut binary_path = PathBuf::from(
+ env::current_dir()
+ .unwrap()
+ .join("target")
+ .join("@shortTarget@")
+ .join(env!("cargoBuildType")),
+ );
binary_path.push(
if cfg!(target_os = "windows") {

View file

@ -16273,6 +16273,7 @@ with pkgs;
cargo-audit = callPackage ../development/tools/rust/cargo-audit {
inherit (darwin.apple_sdk.frameworks) Security;
};
cargo-benchcmp = callPackage ../development/tools/rust/cargo-benchcmp { };
cargo-binstall = callPackage ../development/tools/rust/cargo-binstall { };
cargo-bisect-rustc = callPackage ../development/tools/rust/cargo-bisect-rustc {
inherit (darwin.apple_sdk.frameworks) Security;