From 04ba15d9f2f934a168e6525521705cea9d03196b Mon Sep 17 00:00:00 2001 From: Dan Hirsch <thequux@upstandinghackers.com> Date: Fri, 13 Sep 2013 01:14:40 -0700 Subject: [PATCH] Added coverage support --- .gitignore | 1 + .travis.yml | 7 ++++++- SConstruct | 12 ++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fdd65143..572f2d60 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ TAGS docs/milestone2.dot.pdf *.dot.pdf Session.vim +*.gcov diff --git a/.travis.yml b/.travis.yml index 8fedfa43..90542d17 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,11 @@ language: c compiler: - gcc - clang -script: scons +before_install: + - sudo pip install cpp-coveralls --use-mirrors +script: + - scons --coverage +after_success: + - coveralls notifications: irc: "irc.upstandinghackers.com#hammer" diff --git a/SConstruct b/SConstruct index 429b0d8b..8f68832a 100644 --- a/SConstruct +++ b/SConstruct @@ -12,6 +12,12 @@ AddOption("--variant", action="store", help="Build variant (debug or opt)") +AddOption("--coverage", + dest="coverage", + default=False, + action="store_true", + help="Build with coverage instrumentation") + env['BUILDDIR'] = 'build/$VARIANT' dbg = env.Clone(VARIANT='debug') @@ -25,6 +31,12 @@ if GetOption("variant") == 'debug': else: env = opt +if GetOption("coverage"): + env.Append(CFLAGS=["-fprofile-arcs", "-ftest-coverage"], + CXXFLAGS=["-fprofile-arcs", "-ftest-coverage"], + LDFLAGS=["-fprofile-arcs", "-ftest-coverage"], + LIBS=['gcov']) + if os.getenv("CC") == "clang": env.Replace(CC="clang", CXX="clang++") -- GitLab