Sha256: 8647524867a72793ce0fa290de82bbd920caf6155a28ee38d81d710843f78fbf

Contents?: true

Size: 1.89 KB

Versions: 151

Compression:

Stored size: 1.89 KB

Contents

#!/bin/bash

# In DENYWARNINGS mode, do not set -e so that we run all tests.
# This allows us to see all warnings.
if [ -z "$DENYWARNINGS" ]; then
    set -e
fi

if [ -n "$BENCHMARK" ]; then
    files=exercises/*/benches
else
    files=exercises/*/tests
fi

tmp=${TMPDIR:-/tmp/}
mkdir "${tmp}exercises"

exitcode=0

# An exercise worth testing is defined here as any top level directory with
# a 'tests' directory
for exercise in $files; do
    # This assumes that exercises are only one directory deep
    # and that the primary module is named the same as the directory
    directory=$(dirname "${exercise}");

    workdir=$(mktemp -d "${tmp}${directory}.XXXXXXXXXX")

    cp -R -T $directory $workdir

    # Run in subshell to change workdir without affecting current workdir.
    (
        cd $workdir
        [ -d src ] || mkdir src
        cp example.rs src/lib.rs

        # Overwrite empty Cargo.toml if an example specific file exists
        if [ -f Cargo-example.toml ]; then
            cp Cargo-example.toml Cargo.toml
        fi

        # Forcibly strip all "ignore" statements from the testing files
        for test in tests/*.rs; do
            sed -i '/\[ignore\]/d' $test
        done

        # Run benchmarks instead of tests when enabled.
        if [ -n "$BENCHMARK" ]; then
            cargo bench
        elif [ -n "$DENYWARNINGS" ]; then
            sed -i -e '1i #![deny(warnings)]' src/lib.rs

            # No-run mode so we see no test output.
            # Quiet mode so we see no compile output
            # (such as "Compiling"/"Downloading").
            # Compiler errors will still be shown though.
            # Both flags are necessary to keep things quiet.
            cargo test --quiet --no-run
        else
            # Run the test and get the status
            cargo test
        fi
    )

    status=$?

    if [ $status -ne 0 ]
    then
        exitcode=1
    fi
done

exit $exitcode

Version data entries

151 entries across 151 versions & 1 rubygems

Version Path
trackler-2.0.6.22 tracks/rust/_test/check-exercises.sh
trackler-2.0.6.21 tracks/rust/_test/check-exercises.sh
trackler-2.0.6.20 tracks/rust/_test/check-exercises.sh
trackler-2.0.6.19 tracks/rust/_test/check-exercises.sh
trackler-2.0.6.18 tracks/rust/_test/check-exercises.sh
trackler-2.0.6.17 tracks/rust/_test/check-exercises.sh
trackler-2.0.6.16 tracks/rust/_test/check-exercises.sh
trackler-2.0.6.15 tracks/rust/_test/check-exercises.sh
trackler-2.0.6.14 tracks/rust/_test/check-exercises.sh
trackler-2.0.6.13 tracks/rust/_test/check-exercises.sh
trackler-2.0.6.12 tracks/rust/_test/check-exercises.sh