Skip to content

Commit

Permalink
[test] Add new test cases for plist-to-html
Browse files Browse the repository at this point in the history
  • Loading branch information
csordasmarton committed Mar 20, 2019
1 parent 4150db3 commit f12d981
Show file tree
Hide file tree
Showing 18 changed files with 837 additions and 11 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ venv_dev
Makefile.local

# tools
tools/plist_to_html/build
tools/tu_collector/build

# external sources
Expand Down
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ services:
matrix:
include:
- os: linux
name: "Analyzer and web test cases (sqlite, psycopg2, pg8000)"
name: "Analyzer, web (sqlite, psycopg2, pg8000) and tools test cases."
sudo: required
dist: xenial
python: "2.7"
- os: osx
osx_image: xcode9.4
name: "Analyzer and web test cases (sqlite, psycopg2, pg8000)"
name: "Analyzer, web (sqlite, psycopg2, pg8000) and tools test cases."
sudo: false
language: generic
env:
Expand Down Expand Up @@ -84,6 +84,7 @@ addons:
script:
- make clean_travis
- make package
- make -C tools/plist_to_html test
- make -C analyzer test_unit test_functional
- if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then make -C analyzer test_tu_collector test_build_logger; fi
- make -C web test_unit test_functional
Expand Down
19 changes: 11 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ CC_SERVER = $(CC_WEB)/server/
CC_CLIENT = $(CC_WEB)/client/
CC_ANALYZER = $(CURRENT_DIR)/analyzer

CC_TOOLS = $(CURRENT_DIR)/tools

# Root of the repository.
ROOT = $(CURRENT_DIR)

Expand Down Expand Up @@ -50,12 +52,12 @@ package: clean_package build_dir gen-docs thrift userguide build_plist_to_html b
mkdir -p $(CC_BUILD_PLUGIN_DIR)

# Copy plist-to-html files.
cp -r $(ROOT)/tools/plist_to_html/plist_to_html $(CC_BUILD_LIB_DIR) && \
cp -r $(CC_TOOLS)/plist_to_html/plist_to_html $(CC_BUILD_LIB_DIR) && \
ln -s $(CC_BUILD_LIB_DIR)/plist_to_html/PlistToHtml.py $(CC_BUILD_BIN_DIR)/plist-to-html

# Copy tu_collector files.
cp -r $(ROOT)/tools/tu_collector/tu_collector $(CC_BUILD_LIB_DIR) && \
cp -r $(ROOT)/tools/tu_collector/build $(CC_BUILD_DIR)/tu_collector && \
cp -r $(CC_TOOLS)/tu_collector/tu_collector $(CC_BUILD_LIB_DIR) && \
cp -r $(CC_TOOLS)/tu_collector/build $(CC_BUILD_DIR)/tu_collector && \
ln -s $(CC_BUILD_DIR)/tu_collector/bin/tu-collector $(CC_BUILD_DIR)/bin/tu-collector

# Copy generated thrift files.
Expand Down Expand Up @@ -158,10 +160,10 @@ build_dir:
mkdir -p $(BUILD_DIR)

build_plist_to_html:
$(MAKE) -C tools/plist_to_html
$(MAKE) -C $(CC_TOOLS)/plist_to_html

build_tu_collector:
$(MAKE) -C tools/tu_collector
$(MAKE) -C $(CC_TOOLS)/tu_collector

venv:
# Create a virtual environment which can be used to run the build package.
Expand All @@ -187,7 +189,8 @@ venv_dev:
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_WEB)/requirements_py/test/requirements.txt && \
pip install -r $(CC_TOOLS)/plist_to_html/requirements_py/test/requirements.txt

clean_venv_dev:
rm -rf venv_dev
Expand All @@ -206,10 +209,10 @@ clean_userguide:
rm -rf www/userguide/gen-docs

clean_plist_to_html:
rm -rf tools/plist_to_html/build
rm -rf $(CC_TOOLS)/plist_to_html/build

clean_tu_collector:
rm -rf tools/tu_collector/build
rm -rf $(CC_TOOLS)/tu_collector/build

clean_travis:
# Clean CodeChecker config files stored in the users home directory.
Expand Down
13 changes: 13 additions & 0 deletions tools/plist_to_html/.noserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[nosetests]

# increase verbosity level
verbosity=3

# more detailed error messages on failed asserts
detailed-errors=1

# stop running tests on first error
stop=1

# do not capture stdout
#nocapture=1
16 changes: 16 additions & 0 deletions tools/plist_to_html/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@ STATIC_DIR = $(CURRENT_DIR)/plist_to_html/static
VENDOR_DIR = $(STATIC_DIR)/vendor
CODEMIRROR_DIR = $(VENDOR_DIR)/codemirror

ACTIVATE_DEV_VENV ?= . venv_dev/bin/activate
ACTIVATE_RUNTIME_VENV ?= . venv/bin/activate

VENV_TEST_REQ_FILE ?= requirements_py/test/requirements.txt

include tests/Makefile

venv:
# Create a virtual environment which can be used to run the build package.
virtualenv -p python2 venv && $(ACTIVATE_RUNTIME_VENV)

venv_dev:
# Create a virtual environment for development.
virtualenv -p python2 venv_dev && \
$(ACTIVATE_DEV_VENV) && pip install -r $(VENV_TEST_REQ_FILE)

default: all

all: package
Expand Down
3 changes: 3 additions & 0 deletions tools/plist_to_html/requirements_py/test/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nose==1.3.7
pycodestyle==2.4.0
pylint==1.9.4
36 changes: 36 additions & 0 deletions tools/plist_to_html/tests/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Environment variables to run tests.

# Test project configuration, tests are run on these files.
TEST_PROJECT ?= TEST_PROJ=$(CURRENT_DIR)/tests/projects

REPO_ROOT ?= REPO_ROOT=$(ROOT)

LAYOUT_DIR ?= LAYOUT_DIR=$(STATIC_DIR)

# Nose test runner configuration options.
NOSECFG = --config .noserc

test: test_unit

test_novenv: test_unit_novenv

PYCODESTYLE_TEST_CMD = pycodestyle plist_to_html tests

pycodestyle: 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
$(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
$(UNIT_TEST_CMD)
5 changes: 5 additions & 0 deletions tools/plist_to_html/tests/libtest/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -----------------------------------------------------------------------------
# The CodeChecker Infrastructure
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
# -----------------------------------------------------------------------------
35 changes: 35 additions & 0 deletions tools/plist_to_html/tests/libtest/env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -----------------------------------------------------------------------------
# The CodeChecker Infrastructure
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
# -----------------------------------------------------------------------------
"""
Test environment setup and configuration helpers.
"""
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division

import os
import tempfile


def test_proj_root():
return os.path.abspath(os.environ['TEST_PROJ'])


def get_workspace(test_id='test'):
""" Return a temporary workspace for the tests. """
workspace_root = os.environ.get("PLIST_TO_HTML_TEST_WORKSPACE_ROOT")
if not workspace_root:
# if no external workspace is set create under the build dir
workspace_root = os.path.join(os.environ['REPO_ROOT'], 'build',
'workspace')

if not os.path.exists(workspace_root):
os.makedirs(workspace_root)

if test_id:
return tempfile.mkdtemp(prefix=test_id + "-", dir=workspace_root)
else:
return workspace_root
14 changes: 14 additions & 0 deletions tools/plist_to_html/tests/projects/macros/macros.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// -----------------------------------------------------------------------------
// The CodeChecker Infrastructure
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// -----------------------------------------------------------------------------

#define SET_PTR_VAR_TO_NULL \
ptr = 0

void nonFunctionLikeMacroTest() {
int *ptr;
SET_PTR_VAR_TO_NULL;
*ptr = 5; // expected-warning{{Dereference of null pointer}}
}
Loading

0 comments on commit f12d981

Please sign in to comment.