gd-libgd / windows / msys / run_tests.sh

#!/bin/bash

set -e

# Parameters
CFLAGS_EXTRA=$1     # Extra C flags
    

LOG=run_tests.log

CFLAGS="-g -Igdtest/ -I. -I../src/ -D_WIN32 $CFLAGS_EXTRA"
LDFLAGS='-L../src -llibgd.3.0.1'
DLLPATH=../src:/c/Progra~1/GnuWin32/bin

function run_gcc {
    if msg=`gcc $* 2>&1`; then
        true
    else
        echo "COMMAND: gcc $*" >> $LOG
        echo $msg >> $LOG
        false
    fi
}

# Switch to the working directory
PATH=$PATH:$DLLPATH
cd ../../tests

# Initial setup
echo "Setting up..."
[ -f $LOG ] && rm -f $LOG
[ -f test_config.h ] || echo '#define GDTEST_TOP_DIR "."' > test_config.h
run_gcc -c $CFLAGS gdtest/gdtest.c


echo "Running tests:"
count=0
failures=0
compile_failures=0
for test in `find . -name \*.c | grep -v '^./gdtest'`; do
    count=`expr $count + 1`

    exe=${test%.c}.exe
    if run_gcc -o $exe $CFLAGS $LDFLAGS $test gdtest.o; then
        true;
    else
        echo "COMPILE_FAIL: $test"
        compile_failures=`expr $compile_failures + 1`
        continue
    fi
    
    echo "Running $exe:" >> $LOG
    if $exe 2>&1 >> $LOG; then
        echo "PASS: $test"
    else
        failures=`expr $failures + 1`
        echo "FAIL: $test"
    fi
    echo >> $LOG
done

echo "$failures failures and $compile_failures compile failures out of $count tests."
echo "Error messages in $LOG"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.