#!/usr/bin/env bash# PRE-REQUIREMENTS:## To execute this script you have to have a few additional things installed# on your system. You can run the following commands to do so:## ```sh# # nightly toolchain# rustup toolchain install nightly## # llvm toolchain for nightly# rustup component add --toolchain nightly llvm-tools-preview## # cargo-binutils and rustfilt for nightly# cargo +nightly install cargo-binutils rustfilt## # jq from your package manager of choice (just replace brew with apt or a similar manager)# brew install jq# ```# switch to the etherparse root directorypushd "$(dirname "${BASH_SOURCE[0]}")/.."# folder for all the coverage filescoverage_dir="target/coverage"# make sure no cached data is used (can interfere with the instrumentalisation and testruns)cargo clean# remove previous runs and setup the result foldersrm -rf "${coverage_dir}"mkdir -p "${coverage_dir}"mkdir -p "${coverage_dir}/raw"# run the instrumented testsRUSTFLAGS="-Zinstrument-coverage" \LLVM_PROFILE_FILE="${coverage_dir}/raw/coverage-%m.profraw" \cargo +nightly test --tests# determine the filenames of the run executablesRUSTFLAGS="-Zinstrument-coverage" \LLVM_PROFILE_FILE="${coverage_dir}/raw/coverage-%m.profraw" \cargo +nightly test --no-run --message-format=json | jq -r "select(.profile.test == true) | .filenames[]" | grep -v dSYM - > "${coverage_dir}/raw/filenames.txt"cargo profdata -- merge -sparse "${coverage_dir}/raw/coverage-"*".profraw" -o "${coverage_dir}/raw/merge.profdata"cargo cov -- report \--use-color \--summary-only \--Xdemangler=rustfilt \--ignore-filename-regex='/.cargo/registry' \--ignore-filename-regex='/.rustup/toolchains' \--ignore-filename-regex='/rustc' \"--instr-profile=${coverage_dir}/raw/merge.profdata" \$(printf -- "-object %s " $(cat "${coverage_dir}/raw/filenames.txt")) \> "${coverage_dir}/report_all.txt"cargo cov -- report \--use-color \--summary-only \--Xdemangler=rustfilt \--ignore-filename-regex='/.cargo/registry' \--ignore-filename-regex='/.rustup/toolchains' \--ignore-filename-regex='/rustc' \--ignore-filename-regex='tests/' \"--instr-profile=${coverage_dir}/raw/merge.profdata" \$(printf -- "-object %s " $(cat "${coverage_dir}/raw/filenames.txt")) \> "${coverage_dir}/report_without_tests.txt"cargo cov -- show --format=html \--Xdemangler=rustfilt \--ignore-filename-regex='/.cargo/registry' \--ignore-filename-regex='/.rustup/toolchains' \--ignore-filename-regex='/rustc' \"--instr-profile=${coverage_dir}/raw/merge.profdata" \$(printf -- "-object %s " $(cat "${coverage_dir}/raw/filenames.txt")) \"--output-dir=${coverage_dir}/html_all"cargo cov -- show --format=html \--Xdemangler=rustfilt \--ignore-filename-regex='/.cargo/registry' \--ignore-filename-regex='/.rustup/toolchains' \--ignore-filename-regex='/rustc' \--ignore-filename-regex='tests/' \"--instr-profile=${coverage_dir}/raw/merge.profdata" \$(printf -- "-object %s " $(cat "${coverage_dir}/raw/filenames.txt")) \"--output-dir=${coverage_dir}/html_without_tests"cargo cov -- export --format=lcov \--Xdemangler=rustfilt \--ignore-filename-regex='/.cargo/registry' \--ignore-filename-regex='/.rustup/toolchains' \--ignore-filename-regex='/rustc' \"--instr-profile=${coverage_dir}/raw/merge.profdata" \$(printf -- "-object %s " $(cat "${coverage_dir}/raw/filenames.txt")) \> "${coverage_dir}/export.lcov.txt"cargo cov -- export --format=text \--Xdemangler=rustfilt \--ignore-filename-regex='/.cargo/registry' \--ignore-filename-regex='/.rustup/toolchains' \--ignore-filename-regex='/rustc' \"--instr-profile=${coverage_dir}/raw/merge.profdata" \$(printf -- "-object %s " $(cat "${coverage_dir}/raw/filenames.txt")) \> "${coverage_dir}/export.json"popd
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。