Skip to content

Commit

Permalink
added cleanup for the temporary test package and documentation update
Browse files Browse the repository at this point in the history
  • Loading branch information
Gyorgy Orban committed Jun 1, 2016
1 parent 7326a36 commit 18cea7c
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@ script:

- export CODECHECKER_DB_DRIVER=pg8000
- nosetests tests/test_packages/functional/package_test/

- ./clean_tests.sh
3 changes: 2 additions & 1 deletion build_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,8 @@ def main():
dest="compress", default=False,
help="Compress package to tar.gz")

parser.add_argument("-v", action="store_true", dest="verbose_log")
parser.add_argument("-v", action="store_true", dest="verbose_log",
help='Set log level to higher verbosity.')

args = vars(parser.parse_args())

Expand Down
12 changes: 12 additions & 0 deletions clean_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

echo "Removing temporary directory created for testing: " $TEST_CODECHECKER_PACKAGE_DIR

rm -rf $TEST_CODECHECKER_PACKAGE_DIR

echo "Unsetting environment variables used for testing"
unset TEST_TESTS_DIR
unset TEST_CODECHECKER_PACKAGE_DIR
unset TEST_CODECHECKER_DIR
unset TEST_CLANG_VERSION
unset TEST_TEST_PROJECT_CONFIG
8 changes: 8 additions & 0 deletions run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
#!/usr/bin/env bash

# setup environment variables, temporary directories
. tests/test_env_setup.sh

# build the package used for the tests
./build_package.py -o $TEST_CODECHECKER_PACKAGE_DIR -v

# run all the tests
nosetests tests/test_packages/

# cleanup the environment variables and temporary
# directories
clean_tests.sh

63 changes: 63 additions & 0 deletions tests/package_test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# How to run the tests

## Rrequirements

Additionaly to the package building requirements the python nosetest running framework is required.

~~~~~~{.sh}
# source the already created python virtualenv for package building
source ~/checker_env/bin/activate
# install nosetest
pip install nose
~~~~~~

## Running the tests

To run the tests call the run_test.sh script.
It will build a package, and run the all the unit and functional tests.
~~~~~~{.sh}
run_tests.sh
~~~~~~

## More detailed test running
~~~~~~{.sh}
# setup some required environment variables to run the tests
# create temporary directories
source tests/test_env_setup.sh
# build the CodeChecker package
build_package.py -o $TEST_CODECHECKER_PACKAGE_DIR -v
# do not use PostgreSQL for running the tests (SQLite will be used)
export TEST_USE_POSTGRESQL=false
# run all the tests
nosetests tests/test_packages/
# run only the unittests
nosetests tests/test_packages/unit
# run only the functional tests
nosetests tests/test_packages/functional
# remove the temporary directories and unset the environment variables
# set by sourcing the test_env_setup.sh script
clean_tests.sh
~~~~~~

### Testing with PostgresSQL database backend

To run the tests with PostgreSQL backend set these environment variables:
~~~~~~{.sh}
export TEST_USE_POSTGRESQL=true
~~~~~~

Multiple PostgreSQL database drivers are supported (psycopg2, pg8000).
Select explicitly a database driver to used for testing.
~~~~~~{.sh}
export CODECHECKER_DB_DRIVER=psycopg2
~~~~~~

At least one of the database drivers needs to be available to use the PostgreSQL database backend.
Psycopg2 is used by default if not found pg8000 is used.
1 change: 1 addition & 0 deletions tests/test_env_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export TEST_TESTS_DIR=$(readlink -f "$(dirname "$BASH_SOURCE")")

export TEST_CODECHECKER_PACKAGE_DIR=`mktemp -d`
export TEST_CODECHECKER_DIR="$TEST_CODECHECKER_PACKAGE_DIR/CodeChecker"
echo "Temporary directory for testing created: " $TEST_CODECHECKER_PACKAGE_DIR
export TEST_CLANG_VERSION="stable"

export TEST_TEST_PROJECT_CONFIG="$TEST_TESTS_DIR/test_projects/test_files/project_info.json"
29 changes: 0 additions & 29 deletions tests/test_packages/functional/package_test.md

This file was deleted.

0 comments on commit 18cea7c

Please sign in to comment.