testing: Add gcov and cppcheck tests
It doesn't hurt to run even more tests on the code! Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
11df56139d
commit
53f0c2a6aa
|
@ -7,3 +7,6 @@ bin/
|
|||
.sconsign.dblite
|
||||
*.patch
|
||||
tests/*-lib
|
||||
*.gcov
|
||||
*.gcda
|
||||
*.gcno
|
||||
|
|
15
Sconstruct
15
Sconstruct
|
@ -5,6 +5,8 @@ import os
|
|||
CONFIG_VERSION = 6.1
|
||||
CONFIG_DEBUG = True
|
||||
CONFIG_TEST_VALGRIND = False
|
||||
CONFIG_TEST_COVERAGE = False
|
||||
CONFIG_TEST_CPPCHECK = False
|
||||
|
||||
|
||||
# Set up default environment
|
||||
|
@ -16,21 +18,25 @@ class OEnvironment(Environment):
|
|||
Debug = False
|
||||
Version = 0
|
||||
Valgrind = False
|
||||
Coverage = False
|
||||
CppCheck = False
|
||||
|
||||
def __init__(self):
|
||||
Environment.__init__(self, CCFLAGS = CONFIG_CCFLAGS)
|
||||
def __init__(self, CCFLAGS = CONFIG_CCFLAGS):
|
||||
Environment.__init__(self, CCFLAGS = CCFLAGS)
|
||||
self.Append(CPPPATH = os.path.abspath("include"))
|
||||
self.Append(CXXCOMSTR = "C++ $TARGET")
|
||||
self.Append(LINKCOMSTR = "Linking $TARGET")
|
||||
self.Debug = CONFIG_DEBUG
|
||||
self.Version = CONFIG_VERSION
|
||||
self.Valgrind = CONFIG_TEST_VALGRIND
|
||||
self.Coverage = CONFIG_TEST_COVERAGE
|
||||
self.CppCheck = CONFIG_TEST_CPPCHECK
|
||||
|
||||
def UsePackage(self, name):
|
||||
self.ParseConfig("pkg-config --cflags --libs %s" % name)
|
||||
|
||||
env = OEnvironment()
|
||||
test_env = OEnvironment()
|
||||
test_env = OEnvironment( CONFIG_CCFLAGS + [ "-DCONFIG_TEST" ] )
|
||||
Export("env", "test_env")
|
||||
|
||||
|
||||
|
@ -39,6 +45,9 @@ lib = SConscript("lib/Sconscript")
|
|||
gui = SConscript("gui/Sconscript")
|
||||
|
||||
tests = SConscript("tests/Sconscript")
|
||||
Clean(tests, Glob("*.gcov"))
|
||||
Clean(tests, Glob("tests/*.gcda"))
|
||||
Clean(tests, Glob("tests/*.gcno"))
|
||||
|
||||
|
||||
ocarina = env.Program("bin/ocarina", lib + gui)
|
||||
|
|
5
TODO
5
TODO
|
@ -89,3 +89,8 @@ Future work:
|
|||
- Functions to tag individual files
|
||||
- Functions to read multiple tags from a single text file when
|
||||
CONFIG_TEST == true
|
||||
- Doxygen support for documentation?
|
||||
- Jenkins
|
||||
- Run tests
|
||||
- Show gcov graph
|
||||
- Run cppcheck
|
||||
|
|
|
@ -24,13 +24,14 @@ tests = [
|
|||
|
||||
env = test_env
|
||||
env.UsePackage("glib-2.0")
|
||||
if env.Coverage == True:
|
||||
env.Append( CCFLAGS = [ "--coverage" ] )
|
||||
env.Append( LINKFLAGS = [ "-lgcov", "-coverage" ] )
|
||||
check_depends = True
|
||||
|
||||
for arg in sys.argv:
|
||||
if arg.find("tests") == 0:
|
||||
env.Append( CCFLAGS = [ "-DCONFIG_TEST" ] )
|
||||
if len(arg) > 5:
|
||||
check_depends = False
|
||||
if arg.find("tests") == 0 and len(arg) > 5:
|
||||
check_depends = False
|
||||
break
|
||||
|
||||
def expand_files(extra_files):
|
||||
|
@ -80,6 +81,16 @@ for src, lib, extra, pkgs in tests:
|
|||
ignore.write(name + "\n")
|
||||
ignore.close();
|
||||
|
||||
if env.Coverage == True:
|
||||
cov = Command("ocarina.gcov", [], "gcov -r tests/*.gcda")
|
||||
Depends(cov, res[len(res) - 1])
|
||||
res += [ cov ]
|
||||
|
||||
if env.CppCheck == True:
|
||||
check = Command("cpp.check", [], "cppcheck -q .")
|
||||
Depends(check, res[len(res) - 1])
|
||||
res += [ check ]
|
||||
|
||||
Return("res")
|
||||
|
||||
##scripts = [ "library", "deck", "audio", "gui" ]
|
||||
|
|
Loading…
Reference in New Issue