#!/bin/bash

if [ -n "$SF_SYSTEM_FUNC" ]; then
	if [ -z "$VIRTUAL_ENV" ]; then
        source /var/local/env-allura/bin/activate
	fi
fi

# main

if [ "$TEST_MODULES"  == "" ]; then
    TEST_MODULES="\
    AlluraTesting \
    Allura \
    ForgeBlog \
    ForgeLink \
    ForgeChat \
    ForgeDiscussion \
    ForgeGit \
    ForgeHg \
    ForgeSVN \
    ForgeTracker \
    ForgeWiki \
    ForgeDownloads \
    ForgeActivity \
    "
fi

# Run with --with-coverage for coverage (add --cover-html for html report)
for module in $TEST_MODULES; do
    (
        echo "Running tests in module $module"
        cd $module
        cover_package=$(echo $module | tr "[:upper:]" "[:lower:]")
        nosetests --cover-package=$cover_package --cover-html-dir=report.coverage --cover-erase $* || exit
    ) || exit
done
