cargo-show-asm: add tests

This commit is contained in:
oxalica 2022-10-17 18:00:35 +08:00
parent 725658648f
commit 22659c50cf
2 changed files with 26 additions and 2 deletions

View File

@ -6,6 +6,7 @@
, installShellFiles
, openssl
, nix-update-script
, callPackage
}:
rustPlatform.buildRustPackage rec {
pname = "cargo-asm";
@ -30,8 +31,13 @@ rustPlatform.buildRustPackage rec {
--zsh <($out/bin/cargo-asm --bpaf-complete-style-zsh )
'';
passthru.updateScript = nix-update-script {
attrPath = pname;
passthru = {
updateScript = nix-update-script {
attrPath = pname;
};
tests = lib.optionalAttrs stdenv.hostPlatform.isx86_64 {
test-basic-x86_64 = callPackage ./test-basic-x86_64.nix { };
};
};
meta = with lib; {

View File

@ -0,0 +1,18 @@
{ runCommand, cargo, rustc, cargo-show-asm }:
runCommand "test-basic" {
nativeBuildInputs = [ cargo rustc cargo-show-asm ];
} ''
mkdir -p src
cat >Cargo.toml <<EOF
[package]
name = "add"
version = "0.0.0"
EOF
cat >src/lib.rs <<EOF
pub fn add(a: u32, b: u32) -> u32 { a + b }
EOF
[[ "$(cargo asm add::add | tee /dev/stderr)" == *"lea eax, "* ]]
[[ "$(cargo asm --mir add | tee /dev/stderr)" == *"= Add("* ]]
touch $out
''