<commit_before>{ rust-bindgen-unwrapped, bash, runCommand }:
let
  clang = rust-bindgen-unwrapped.clang;
in
runCommand "rust-bindgen-${rust-bindgen-unwrapped.version}"
{
  #for substituteAll
  inherit bash;
  unwrapped = rust-bindgen-unwrapped;
  libclang = clang.cc.lib;
} ''
  mkdir -p $out/bin
  export cincludes="$(< ${clang}/nix-support/cc-cflags) $(< ${clang}/nix-support/libc-cflags)"
  export cxxincludes="$(< ${clang}/nix-support/libcxx-cxxflags)"
  substituteAll ${./wrapper.sh} $out/bin/bindgen
  chmod +x $out/bin/bindgen
''
<commit_msg>rust-bindgen: add tests<commit_after>{ rust-bindgen-unwrapped, zlib, bash, runCommand, runCommandCC }:
let
  clang = rust-bindgen-unwrapped.clang;
  self = runCommand "rust-bindgen-${rust-bindgen-unwrapped.version}"
    {
      #for substituteAll
      inherit bash;
      unwrapped = rust-bindgen-unwrapped;
      libclang = clang.cc.lib;
      passthru.tests = {
        simple-c = runCommandCC "simple-c-bindgen-tests" { } ''
          echo '#include <stdlib.h>' > a.c
          ${self}/bin/bindgen a.c --whitelist-function atoi | tee output
          grep atoi output
          touch $out
        '';
        simple-cpp = runCommandCC "simple-cpp-bindgen-tests" { } ''
          echo '#include <cmath>' > a.cpp
          ${self}/bin/bindgen a.cpp --whitelist-function erf -- -xc++ | tee output
          grep erf output
          touch $out
        '';
        with-lib = runCommandCC "zlib-bindgen-tests" { buildInputs = [ zlib ]; } ''
          echo '#include <zlib.h>' > a.c
          ${self}/bin/bindgen a.c --whitelist-function compress | tee output
          grep compress output
          touch $out
        '';
      };
    } ''
    mkdir -p $out/bin
    export cincludes="$(< ${clang}/nix-support/cc-cflags) $(< ${clang}/nix-support/libc-cflags)"
    export cxxincludes="$(< ${clang}/nix-support/libcxx-cxxflags)"
    substituteAll ${./wrapper.sh} $out/bin/bindgen
    chmod +x $out/bin/bindgen
  '';
in
self
{'fraction_non_alphanumeric': 0.15685279187817258, 'fraction_numerical': 0.0, 'mean_word_length': 2.60989010989011, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '926886', 'n_tokens_mistral': 706, 'n_tokens_neox': 688, 'n_words': 132}