#!/usr/bin/env bash function usage() { cat < /dev/null; then echo "Missing $bin in PATH" exit 1 fi done for pkg in "${DEPS_PYTHON[@]}"; do if ! python3 -c "import $pkg" > /dev/null; then echo "Missing python package $pkg" exit 1 fi done if ! rustup component list --installed | grep llvm-tools &> /dev/null; then echo "Missing llvm-tools in the Rust toolchain" exit 1 fi while getopts "ch" opt ; do case "$opt" in h) usage exit 0 ;; *) echo "Unknown option. (Run '$0 -h' for help.)" exit 1 ;; esac done # Remove the parsed flags. shift $((OPTIND-1)) for suite in "$@"; do case "$suite" in unit) UNIT=yes ;; integration) INTEGRATION=yes ;; all) UNIT=yes INTEGRATION=yes ;; *) echo "Unrecognized test suite '$suite'. (Run '$0 -h' for help.)" exit 1 ;; esac done if [ "$UNIT" = no ] && [ "$INTEGRATION" = no ]; then echo "No test suites listed; nothing will be done. (Run '$0 -h' for help.)" exit 1 fi # Clear the old coverage report and profiling data. rm -rf coverage coverage_meta_{unit,integration} mkdir coverage echo 'all
' > coverage/index.html if [ "$UNIT" = yes ] ; then # Run the unit tests, with coverage. ./maint/with_coverage -o coverage/unit cargo test --all-features mv coverage_meta coverage_meta_unit echo 'unit
' >> coverage/index.html fi if [ "$INTEGRATION" = yes ] ; then # Run the integration tests, with coverage. # # (This is just a basic test that uses curl over Arti over a # chutney network. It's taken from the gitlab-ci tests.) # TODO: we might want, at some point, to have a the following stuff # go into a basic extensible integration-testing script that gets # run both from here and from the .gitlab-ci.yml file. trap ./tests/chutney/teardown 0 ./maint/with_coverage -o coverage/integration -s ./tests/chutney/setup proxy curl http://example.com -vs --socks5-hostname 127.0.0.1:9150 -o /dev/null trap - 0 ./tests/chutney/teardown # Report is generated after teardown because chutney/setup returns before any # test was done, so the report would be generated based on incomplete data. ./maint/with_coverage -o coverage/integration -c true mv coverage_meta coverage_meta_integration echo 'integration
' >> coverage/index.html fi # Generate merged coverage report. mkdir coverage_meta cat coverage_meta_*/commands > coverage_meta/commands mv coverage_meta_* coverage_meta ./maint/with_coverage -o coverage/all -c true