aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-07-25 01:32:51 +0800
committerGitHub <noreply@github.com>2018-07-25 01:32:51 +0800
commitfc68d22ba4f98bc9cd44d3c8e6376cba21b528d6 (patch)
tree6cb349270bc7c77d1712fd3c33a8148fdcc6daf5
parent1dac6effed5fd2ca9548dde8b8e1c3a3e0985fa7 (diff)
parenta1d3e72bb51fe45a6af531c20863037c759c6765 (diff)
downloaddexon-solidity-fc68d22ba4f98bc9cd44d3c8e6376cba21b528d6.tar.gz
dexon-solidity-fc68d22ba4f98bc9cd44d3c8e6376cba21b528d6.tar.zst
dexon-solidity-fc68d22ba4f98bc9cd44d3c8e6376cba21b528d6.zip
Merge pull request #4544 from ethereum/code-coverage
Code coverage
-rw-r--r--.circleci/config.yml20
-rw-r--r--cmake/EthCompilerSettings.cmake32
2 files changed, 34 insertions, 18 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml
index c577be7b..a2e34b37 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -14,7 +14,7 @@ defaults:
command: |
mkdir -p build
cd build
- cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo
+ cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo $CMAKE_OPTIONS
make -j4
- run_tests: &run_tests
name: Tests
@@ -122,6 +122,7 @@ jobs:
- image: buildpack-deps:artful
environment:
TERM: xterm
+ CMAKE_OPTIONS: -DCOVERAGE=ON
steps:
- checkout
- run:
@@ -133,7 +134,10 @@ jobs:
- run: *setup_prerelease_commit_hash
- run: *run_build
- store_artifacts: *solc_artifact
- - persist_to_workspace: *all_artifacts
+ - persist_to_workspace:
+ root: build
+ paths:
+ - "*"
build_x86_mac:
macos:
@@ -188,9 +192,19 @@ jobs:
name: Install dependencies
command: |
apt-get -qq update
- apt-get -qy install libz3-dev libleveldb1v5
+ apt-get -qy install libz3-dev libleveldb1v5 python-pip
+ pip install codecov
- run: mkdir -p test_results
+ - run:
+ name: Test type checker
+ command: build/test/soltest -t 'syntaxTest*' -- --no-ipc --testpath test
+ - run:
+ name: Coverage of type checker
+ command: codecov --flags type_checker --gcov-root build
- run: *run_tests
+ - run:
+ name: Coverage of all
+ command: codecov --flags all --gcov-root build
- store_test_results:
path: test_results/
diff --git a/cmake/EthCompilerSettings.cmake b/cmake/EthCompilerSettings.cmake
index ff3a5edb..ee8cb1b3 100644
--- a/cmake/EthCompilerSettings.cmake
+++ b/cmake/EthCompilerSettings.cmake
@@ -151,21 +151,23 @@ if (SANITIZE)
endif()
endif()
-if (PROFILING AND (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")))
- set(CMAKE_CXX_FLAGS "-g ${CMAKE_CXX_FLAGS}")
- set(CMAKE_C_FLAGS "-g ${CMAKE_C_FLAGS}")
- add_definitions(-DETH_PROFILING_GPERF)
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lprofiler")
-# set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} -lprofiler")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lprofiler")
-endif ()
-
-if (PROFILING AND (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")))
- set(CMAKE_CXX_FLAGS "-g --coverage ${CMAKE_CXX_FLAGS}")
- set(CMAKE_C_FLAGS "-g --coverage ${CMAKE_C_FLAGS}")
- set(CMAKE_SHARED_LINKER_FLAGS "--coverage ${CMAKE_SHARED_LINKER_FLAGS} -lprofiler")
- set(CMAKE_EXE_LINKER_FLAGS "--coverage ${CMAKE_EXE_LINKER_FLAGS} -lprofiler")
-endif ()
+# Code coverage support.
+# Copied from Cable:
+# https://github.com/ethereum/cable/blob/v0.2.4/CableCompilerSettings.cmake#L118-L132
+option(COVERAGE "Build with code coverage support" OFF)
+if(COVERAGE)
+ # Set the linker flags first, they are required to properly test the compiler flag.
+ set(CMAKE_SHARED_LINKER_FLAGS "--coverage ${CMAKE_SHARED_LINKER_FLAGS}")
+ set(CMAKE_EXE_LINKER_FLAGS "--coverage ${CMAKE_EXE_LINKER_FLAGS}")
+
+ set(CMAKE_REQUIRED_LIBRARIES "--coverage ${CMAKE_REQUIRED_LIBRARIES}")
+ check_cxx_compiler_flag(--coverage have_coverage)
+ string(REPLACE "--coverage " "" CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+ if(NOT have_coverage)
+ message(FATAL_ERROR "Coverage not supported")
+ endif()
+ add_compile_options(-g --coverage)
+endif()
if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"))
option(USE_LD_GOLD "Use GNU gold linker" ON)