Skip to content

Commit

Permalink
Merge pull request Ericsson#2007 from gyorb/fix-missing-env
Browse files Browse the repository at this point in the history
cleanup make targets with/without virtualenv
  • Loading branch information
csordasmarton authored Mar 27, 2019
2 parents e66ddc3 + a1259fa commit e122027
Show file tree
Hide file tree
Showing 10 changed files with 172 additions and 119 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then while ! pg_isready; do sleep 1; done; createuser -s postgres; fi

install:
- pip install nose pycodestyle
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then pip install --ignore-installed nose --user; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH=/Users/travis/Library/Python/2.7/bin:$PATH; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then pip install virtualenv; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-7 100; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-7 100; fi
Expand Down Expand Up @@ -82,6 +83,9 @@ addons:
postgresql: "9.6"

script:
- make pip_dev_deps
- make pycodestyle
- make pylint
- make clean_travis
- make package
- make -C tools/plist_to_html test
Expand Down
61 changes: 40 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,18 @@ venv_osx:
clean_venv:
rm -rf venv

PIP_DEV_DEPS_CMD = make -C $(CC_ANALYZER) pip_dev_deps && \
make -C $(CC_WEB) pip_dev_deps && \
make -C $(CC_TOOLS)/plist_to_html pip_dev_deps

pip_dev_deps:
# Install the depencies for analyze, web and the tools.
$(PIP_DEV_DEPS_CMD)

venv_dev:
# Create a virtual environment for development.
virtualenv -p python2 venv_dev && \
$(ACTIVATE_DEV_VENV) && \
pip install -r $(CC_ANALYZER)/requirements_py/dev/requirements.txt && \
pip install -r $(CC_ANALYZER)/requirements_py/test/requirements.txt && \
pip install -r $(CC_WEB)/requirements_py/dev/requirements.txt && \
pip install -r $(CC_WEB)/requirements_py/test/requirements.txt && \
pip install -r $(CC_TOOLS)/plist_to_html/requirements_py/test/requirements.txt
$(ACTIVATE_DEV_VENV) && $(PIP_DEV_DEPS_CMD)

clean_venv_dev:
rm -rf venv_dev
Expand Down Expand Up @@ -218,38 +221,54 @@ clean_travis:
# Clean CodeChecker config files stored in the users home directory.
rm -rf ~/.codechecker*

pylint: venv_dev
$(MAKE) -C $(CC_ANALYZER) pylint && \
$(MAKE) -C $(CC_WEB) pylint && \
pylint ./bin ./codechecker_common ./scripts \
--disable=all \
--enable=logging-format-interpolation,old-style-class
PYLINT_CMD = $(MAKE) -C $(CC_ANALYZER) pylint && \
$(MAKE) -C $(CC_WEB) pylint && \
pylint ./bin ./codechecker_common ./scripts \
--disable=all \
--enable=logging-format-interpolation,old-style-class

pylint:
$(PYLINT_CMD)

pylint_in_env: venv_dev
$(ACTIVATE_DEV_VENV) && $(PYLINT_CMD)

pycodestyle: venv_dev
$(MAKE) -C $(CC_ANALYZER) pycodestyle && \
PYCODE_CMD = $(MAKE) -C $(CC_ANALYZER) pycodestyle && \
$(MAKE) -C $(CC_WEB) pycodestyle && \
pycodestyle bin codechecker_common scripts

pycodestyle:
$(PYCODE_CMD)

pycodestyle_in_env:
$(ACTIVATE_DEV_VENV) && $(PYCODE_CMD)

test: test_analyzer test_server

test_analyzer:
$(MAKE) -C $(CC_ANALYZER) test

test_analyzer_in_env:
$(MAKE) -C $(CC_ANALYZER) test_in_env

test_server:
$(MAKE) -C $(CC_WEB) test

test_server_in_env:
$(MAKE) -C $(CC_WEB) test_in_env

test_unit:
$(MAKE) -C $(CC_ANALYZER) test_unit
$(MAKE) -C $(CC_WEB) test_unit

test_unit_novenv:
$(MAKE) -C $(CC_ANALYZER) test_unit_novenv
$(MAKE) -C $(CC_WEB) test_unit_novenv
test_unit_in_env:
$(MAKE) -C $(CC_ANALYZER) test_unit_in_env
$(MAKE) -C $(CC_WEB) test_unit_in_env

test_functional: package
test_functional:
$(MAKE) -C $(CC_ANALYZER) test_functional
$(MAKE) -C $(CC_WEB) test_functional

test_functional_novenv: package
$(MAKE) -C $(CC_ANALYZER) test_functional_novenv
$(MAKE) -C $(CC_WEB) test_functional_novenv
test_functional_in_env:
$(MAKE) -C $(CC_ANALYZER) test_functional_in_env
$(MAKE) -C $(CC_WEB) test_functional_in_env
3 changes: 3 additions & 0 deletions analyzer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ VENV_DEV_REQ_FILE ?= requirements_py/dev/requirements.txt

include tests/Makefile

pip_dev_deps:
pip install -r $(VENV_DEV_REQ_FILE)

venv_dev:
# Create a virtual environment for development.
virtualenv -p python2 venv_dev && \
Expand Down
45 changes: 29 additions & 16 deletions analyzer/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,62 @@ REPO_ROOT ?= REPO_ROOT=$(ROOT)
# Nose test runner configuration options.
NOSECFG = --config .noserc

test: test_unit test_functional test_build_logger test_tu_collector
test_in_env: pycodestyle_in_env pylint_in_env test_unit_in_env test_functional_in_env test_build_logger test_tu_collector_in_env

test_novenv: test_unit_novenv test_functional_novenv
test: pycodestyle pylint test_unit test_functional test_build_logger test_tu_collector

PYCODESTYLE_TEST_CMD = pycodestyle bin codechecker_analyzer tests

pycodestyle: venv_dev
pycodestyle:
$(PYCODESTYLE_TEST_CMD)

pycodestyle_in_env: venv_dev
$(ACTIVATE_DEV_VENV) && $(PYCODESTYLE_TEST_CMD)

PYLINT_TEST_CMD = pylint ./bin ./cmd ./codechecker_analyzer ./tests \
--rcfile=$(ROOT)/.pylintrc \
--disable=all \
--enable=logging-format-interpolation,old-style-class

pylint: venv_dev
$(ACTIVATE_DEV_VENV) && $(PYLINT_TEST_CMD)
pylint:
$(PYLINT_TEST_CMD)

UNIT_TEST_CMD = $(REPO_ROOT) nosetests $(NOSECFG) tests/unit
pylint_in_env: venv_dev
$(ACTIVATE_DEV_VENV) && $(PYLINT_TEST_CMD)

FUNCTIONAL_TEST_CMD = $(REPO_ROOT) $(TEST_PROJECT) \
nosetests $(NOSECFG) tests/functional || exit 1
run_test:
$(REPO_ROOT) $(TEST_PROJECT) \
nosetests $(NOSECFG) ${TEST} || exit 1

run_test: venv_dev
run_test_in_env: venv_dev
$(ACTIVATE_DEV_VENV) && $(REPO_ROOT) $(TEST_PROJECT) \
nosetests $(NOSECFG) ${TEST} || exit 1

test_unit: venv_dev
$(ACTIVATE_DEV_VENV) && $(UNIT_TEST_CMD)
UNIT_TEST_CMD = $(REPO_ROOT) nosetests $(NOSECFG) tests/unit

test_unit_novenv:
test_unit:
$(UNIT_TEST_CMD)

test_functional: venv_dev
python $(ROOT)/scripts/test/check_clang.py || exit 1;
$(ACTIVATE_DEV_VENV) && $(FUNCTIONAL_TEST_CMD)
test_unit_in_env: venv_dev
$(ACTIVATE_DEV_VENV) && $(UNIT_TEST_CMD)

FUNCTIONAL_TEST_CMD = $(REPO_ROOT) $(TEST_PROJECT) \
nosetests $(NOSECFG) tests/functional || exit 1

test_functional_novenv:
test_functional:
python $(ROOT)/scripts/test/check_clang.py || exit 1;
$(FUNCTIONAL_TEST_CMD)

test_functional_in_env: venv_dev
python $(ROOT)/scripts/test/check_clang.py || exit 1;
$(ACTIVATE_DEV_VENV) && $(FUNCTIONAL_TEST_CMD)

test_build_logger:
make -C tools/build-logger -f Makefile.manual test

test_tu_collector:
$(REPO_ROOT) make -C $(ROOT)/tools/tu_collector test

test_tu_collector_in_env:
$(ACTIVATE_DEV_VENV) && \
$(REPO_ROOT) make -C $(ROOT)/tools/tu_collector test
6 changes: 4 additions & 2 deletions docs/tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
__At least Clang 7.0 and Clant-tidy 7.0 is required to run the tests.__

**Before running the tests the CodeChecker package needs to be built!**
~~~~~~{.sh}
```sh
# Build the package
make package
~~~~~~
```

__Every test target has an `*in_env` version (Eg. `make test_in_env`) which automatically creates and sources a virtualenv for the tests.__
|cmd||
|----|---|
|`make test`| run all tests (unit and functional)|
|`make test_in_env`| run all tests (unit and functional), automatically setup and source a virtualenv|
|`make test_unit` | unittests |
|`make test_functional` | functional tests (SQLite and PostgreSQL) |
|`make test_sqlite` | functional test (SQLite) |
Expand Down
3 changes: 3 additions & 0 deletions tools/plist_to_html/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ venv:
# Create a virtual environment which can be used to run the build package.
virtualenv -p python2 venv && $(ACTIVATE_RUNTIME_VENV)

pip_dev_deps:
pip install -r $(VENV_DEV_REQ_FILE)

venv_dev:
# Create a virtual environment for development.
virtualenv -p python2 venv_dev && \
Expand Down
22 changes: 14 additions & 8 deletions tools/plist_to_html/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,33 @@ LAYOUT_DIR ?= LAYOUT_DIR=$(STATIC_DIR)
# Nose test runner configuration options.
NOSECFG = --config .noserc

test: test_unit
test: pycodestyle pylint test_unit

test_novenv: test_unit_novenv
test_in_env: pycodestyle_in_env pylint_in_env test_unit_in_env

PYCODESTYLE_TEST_CMD = pycodestyle plist_to_html tests

pycodestyle: venv_dev
pycodestyle:
$(PYCODESTYLE_TEST_CMD)

pycodestyle_in_env: venv_dev
$(ACTIVATE_DEV_VENV) && $(PYCODESTYLE_TEST_CMD)

PYLINT_TEST_CMD = pylint ./plist_to_html ./tests \
--disable=all \
--enable=logging-format-interpolation,old-style-class

pylint: venv
pylint:
$(PYLINT_TEST_CMD)

pylint_in_env: venv
$(ACTIVATE_DEV_VENV) && $(PYLINT_TEST_CMD)

UNIT_TEST_CMD = $(REPO_ROOT) $(TEST_PROJECT) $(LAYOUT_DIR) \
nosetests $(NOSECFG) tests/unit

test_unit: venv_dev dep
$(ACTIVATE_DEV_VENV) && $(UNIT_TEST_CMD)

test_unit_novenv: dep
test_unit: dep
$(UNIT_TEST_CMD)

test_unit_in_env: venv_dev dep
$(ACTIVATE_DEV_VENV) && $(UNIT_TEST_CMD)
3 changes: 3 additions & 0 deletions web/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ VENV_DEV_REQ_FILE ?= requirements_py/dev/requirements.txt
include tests/Makefile
include server/tests/Makefile

pip_dev_deps:
pip install -r $(VENV_DEV_REQ_FILE)

thrift: build_dir
if [ -d "$(BUILD_DIR)/thrift" ]; then rm -rf $(BUILD_DIR)/thrift; fi
mkdir $(BUILD_DIR)/thrift
Expand Down
8 changes: 4 additions & 4 deletions web/server/tests/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
UNIT_TEST_CMD = $(REPO_ROOT) BUILD_DIR=$(BUILD_DIR) nosetests $(NOSECFG) -w server tests/unit

test_unit_server: venv_dev thrift
$(ACTIVATE_DEV_VENV) && $(UNIT_TEST_CMD)

test_unit_novenv_server: thrift
test_unit_server: thrift
$(UNIT_TEST_CMD)

test_unit_server_in_env: venv_dev thrift
$(ACTIVATE_DEV_VENV) && $(UNIT_TEST_CMD)
Loading

0 comments on commit e122027

Please sign in to comment.