[727d4a]: doc / testdocs  Maximize  Restore  History

Download this file

64 lines (53 with data), 1.2 kB

#!/bin/bash

# testdocs [-p python_command] [ errorfiles_file ]
#
# no arguments.
#
# run in doc directory to test all .txt files.
# 
# exit status > 0 if errors found.

ERRORFILES="/tmp/testdocs.$$"
export PYTHONPATH="examples:$PYTHONPATH"

PYTHON="python3.1 -Wd"

# Go to doc directory:
cd `dirname "$0"`

# Add parent directory to PYTHONPATH:
parent_dir=$(dirname $(pwd))
if [ "$PYTHONPATH" ]
then
    export PYTHONPATH="$parent_dir:$PYTHONPATH"
else
    export PYTHONPATH="$parent_dir"
fi

if [ $# -ge 2 -a "x$1" = x-p ]
then
    PYTHON="$2"
    shift 2
fi

# Generate __init__.pyc so source/knowledge_bases/special.txt doesn't fail...
$PYTHON -c 'import __init__'

> $ERRORFILES
NUM_ERRORS=0

for f in `find source -name '*.txt'`
do
    #echo Testing "$f"
    if ! $PYTHON ../doctest_file.py "$f"
    then
        echo "$f" >> $ERRORFILES
        NUM_ERRORS=$(($NUM_ERRORS + 1))
    fi
done

if [ $NUM_ERRORS -eq 0 ]
then
    echo "No Errors!"
    rm -f $ERRORFILES
else
    echo "********** ERRORS ************* $NUM_ERRORS files had errors:"
    cat $ERRORFILES
    if [ $# -gt 0 ]
    then
        sed 's,^,doc/,' $ERRORFILES >> "$1"
    fi
    rm -f $ERRORFILES
    exit $NUM_ERRORS
fi

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks