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.2.1.0 tracks/rust/_test/check-exercises.sh
trackler-2.2.0.6 tracks/rust/_test/check-exercises.sh
trackler-2.2.0.5 tracks/rust/_test/check-exercises.sh
trackler-2.2.0.4 tracks/rust/_test/check-exercises.sh
trackler-2.2.0.3 tracks/rust/_test/check-exercises.sh
trackler-2.2.0.2 tracks/rust/_test/check-exercises.sh
trackler-2.2.0.1 tracks/rust/_test/check-exercises.sh
trackler-2.2.0.0 tracks/rust/_test/check-exercises.sh
trackler-2.1.0.55 tracks/rust/_test/check-exercises.sh
trackler-2.1.0.54 tracks/rust/_test/check-exercises.sh
trackler-2.1.0.53 tracks/rust/_test/check-exercises.sh
trackler-2.1.0.52 tracks/rust/_test/check-exercises.sh
trackler-2.1.0.51 tracks/rust/_test/check-exercises.sh
trackler-2.1.0.50 tracks/rust/_test/check-exercises.sh
trackler-2.1.0.49 tracks/rust/_test/check-exercises.sh
trackler-2.1.0.48 tracks/rust/_test/check-exercises.sh
trackler-2.1.0.47 tracks/rust/_test/check-exercises.sh
trackler-2.1.0.46 tracks/rust/_test/check-exercises.sh
trackler-2.1.0.45 tracks/rust/_test/check-exercises.sh
trackler-2.1.0.44 tracks/rust/_test/check-exercises.sh