Testing; Moved test/cli tests from travis to github actions
This commit is contained in:
parent
773ca43894
commit
fef956f3f0
|
@ -24,6 +24,7 @@ jobs:
|
||||||
sudo apt-get install libxml2-utils
|
sudo apt-get install libxml2-utils
|
||||||
sudo apt-get install z3 libz3-dev
|
sudo apt-get install z3 libz3-dev
|
||||||
cp externals/z3_version_old.h externals/z3_version.h
|
cp externals/z3_version_old.h externals/z3_version.h
|
||||||
|
sudo apt-get install python3-pytest
|
||||||
|
|
||||||
- name: Install missing software on ubuntu 20.04
|
- name: Install missing software on ubuntu 20.04
|
||||||
if: matrix.os == 'ubuntu-20.04'
|
if: matrix.os == 'ubuntu-20.04'
|
||||||
|
@ -31,6 +32,7 @@ jobs:
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install libxml2-utils
|
sudo apt-get install libxml2-utils
|
||||||
sudo apt-get install z3 libz3-dev
|
sudo apt-get install z3 libz3-dev
|
||||||
|
sudo apt-get install python3-pytest
|
||||||
|
|
||||||
- name: Install missing software on macos
|
- name: Install missing software on macos
|
||||||
if: contains(matrix.os, 'macos')
|
if: contains(matrix.os, 'macos')
|
||||||
|
@ -75,6 +77,14 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
make -j$(nproc) check USE_Z3=yes HAVE_RULES=yes
|
make -j$(nproc) check USE_Z3=yes HAVE_RULES=yes
|
||||||
|
|
||||||
|
- name: Run test/cli
|
||||||
|
if: contains(matrix.os, 'ubuntu')
|
||||||
|
run: |
|
||||||
|
cd ..
|
||||||
|
ln -s cppcheck cpp\ check
|
||||||
|
cd cpp\ check/test/cli
|
||||||
|
pytest-3 test-*.py
|
||||||
|
|
||||||
- name: Validate
|
- name: Validate
|
||||||
run: |
|
run: |
|
||||||
make -j$(nproc) checkCWEEntries validateXML
|
make -j$(nproc) checkCWEEntries validateXML
|
||||||
|
|
|
@ -151,11 +151,6 @@ script:
|
||||||
# compile cppcheck, default build
|
# compile cppcheck, default build
|
||||||
- echo $CXXFLAGS
|
- echo $CXXFLAGS
|
||||||
- make -s check -j$(nproc)
|
- make -s check -j$(nproc)
|
||||||
# Testing cli
|
|
||||||
- cp -R . ../cppcheck\ 2
|
|
||||||
- cd ../cppcheck\ 2/test/cli # path with space
|
|
||||||
- python -m pytest test-*.py
|
|
||||||
- cd -
|
|
||||||
# Testing addons (disabled 2020-11-24 because Travis fails, TODO try to enable these)
|
# Testing addons (disabled 2020-11-24 because Travis fails, TODO try to enable these)
|
||||||
# - PYTHONPATH=./addons python -m pytest addons/test/test-*.py
|
# - PYTHONPATH=./addons python -m pytest addons/test/test-*.py
|
||||||
# - PYTHONPATH=./addons python3 -m pytest addons/test/test-*.py
|
# - PYTHONPATH=./addons python3 -m pytest addons/test/test-*.py
|
||||||
|
|
|
@ -1,35 +1,34 @@
|
||||||
|
|
||||||
# python -m pytest test-other-projects.py
|
# python -m pytest test-more-projects.py
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
from testutils import cppcheck
|
from testutils import cppcheck
|
||||||
|
|
||||||
|
|
||||||
# FIXME make CI happy
|
def test_project_force_U():
|
||||||
#def test_project_force_U():
|
# 10018
|
||||||
# # 10018
|
# -U does not work with compile_commands.json
|
||||||
# # -U does not work with compile_commands.json
|
with tempfile.TemporaryDirectory('10018') as temp_folder:
|
||||||
# with tempfile.TemporaryDirectory('10018') as temp_folder:
|
with open(os.path.join(temp_folder, 'bug1.cpp'), 'wt') as f:
|
||||||
# with open(os.path.join(temp_folder, 'bug1.cpp'), 'wt') as f:
|
f.write("""
|
||||||
# f.write("""
|
int x = 123 / 0;
|
||||||
# int x = 123 / 0;
|
#ifdef MACRO1
|
||||||
# #ifdef MACRO1
|
int y = 1000 / 0;
|
||||||
# int y = 1000 / 0;
|
#endif
|
||||||
# #endif
|
""")
|
||||||
# """)
|
|
||||||
#
|
compile_commands = os.path.join(temp_folder, 'compile_commands.json')
|
||||||
# compile_commands = os.path.join(temp_folder, 'compile_commands.json')
|
|
||||||
#
|
with open(compile_commands, 'wt') as f:
|
||||||
# with open(compile_commands, 'wt') as f:
|
f.write('[ { "directory": "%s", "command": "c++ -o bug1.o -c bug1.cpp", "file": "bug1.cpp", "output": "bug1.o" } ]' % str(temp_folder))
|
||||||
# f.write('[ { "directory": "%s", "command": "c++ -o bug1.o -c bug1.cpp", "file": "bug1.cpp", "output": "bug1.o" } ]' % str(temp_folder))
|
|
||||||
#
|
# Without -U => both bugs are found
|
||||||
# # Without -U => both bugs are found
|
ret, stdout, stderr = cppcheck(['--project=' + compile_commands, '--force', '-rp=' + temp_folder, '--template=cppcheck1'])
|
||||||
# ret, stdout, stderr = cppcheck(['--project=' + compile_commands, '--force', '-rp=' + temp_folder, '--template=cppcheck1'])
|
assert (stderr == '[bug1.cpp:2]: (error) Division by zero.\n'
|
||||||
# assert (stderr == '[bug1.cpp:2]: (error) Division by zero.\n'
|
'[bug1.cpp:4]: (error) Division by zero.\n')
|
||||||
# '[bug1.cpp:4]: (error) Division by zero.\n')
|
|
||||||
#
|
# With -U => only first bug is found
|
||||||
# # With -U => only first bug is found
|
ret, stdout, stderr = cppcheck(['--project=' + compile_commands, '--force', '-UMACRO1', '-rp=' + temp_folder, '--template=cppcheck1'])
|
||||||
# ret, stdout, stderr = cppcheck(['--project=' + compile_commands, '--force', '-UMACRO1', '-rp=' + temp_folder, '--template=cppcheck1'])
|
assert stderr == '[bug1.cpp:2]: (error) Division by zero.\n'
|
||||||
# assert stderr == '[bug1.cpp:2]: (error) Division by zero.\n'
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue