Skip to content

Commit

Permalink
Fix ch 14, r 3 for TC pass
Browse files Browse the repository at this point in the history
1. Symlink where possible
2. Adjust collect_tests.py to execute dashboard.cmake
3. Use TARGET_FILE
  • Loading branch information
robertodr committed Aug 9, 2018
1 parent 90a2c0f commit 6f633bc
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 57 deletions.
2 changes: 1 addition & 1 deletion chapter-14/recipe-03/cxx-example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR)

# project name and language
project(recipe-03 LANGUAGES CXX)

# require C++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS OFF)
Expand Down
3 changes: 2 additions & 1 deletion chapter-14/recipe-03/cxx-example/dashboard.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set(CTEST_PROJECT_NAME "example")
set(CTEST_SITE "localhost")
cmake_host_system_information(RESULT _site QUERY HOSTNAME)
set(CTEST_SITE ${_site})
set(CTEST_BUILD_NAME "${CMAKE_SYSTEM_NAME}-${CMAKE_HOST_SYSTEM_PROCESSOR}")

set(CTEST_SOURCE_DIRECTORY "${CTEST_SCRIPT_DIRECTORY}")
Expand Down
13 changes: 5 additions & 8 deletions chapter-14/recipe-03/cxx-example/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
add_library(buggy "")

target_sources(
buggy
target_sources(buggy
PRIVATE
buggy.cpp
PUBLIC
${CMAKE_CURRENT_LIST_DIR}/buggy.hpp
)

target_include_directories(
buggy
target_include_directories(buggy
PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)
Expand All @@ -18,13 +16,12 @@ option(ENABLE_ASAN "Enable AddressSanitizer" OFF)

if(ENABLE_ASAN)
if(CMAKE_CXX_COMPILER_ID MATCHES GNU)
target_compile_options(
buggy
message(STATUS "AddressSanitizer enabled")
target_compile_options(buggy
PUBLIC
-g -O1 -fsanitize=address -fno-omit-frame-pointer
)
target_link_libraries(
buggy
target_link_libraries(buggy
PUBLIC
asan
)
Expand Down
2 changes: 1 addition & 1 deletion chapter-14/recipe-03/cxx-example/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ foreach(_test IN ITEMS leaky use_after_free)
NAME
${_test}
COMMAND
${PROJECT_BINARY_DIR}/tests/${_test}
$<TARGET_FILE:${_test}>
)
endforeach()
4 changes: 0 additions & 4 deletions chapter-14/recipe-03/fortran-example/CTestConfig.cmake

This file was deleted.

1 change: 1 addition & 0 deletions chapter-14/recipe-03/fortran-example/CTestConfig.cmake
32 changes: 0 additions & 32 deletions chapter-14/recipe-03/fortran-example/dashboard.cmake

This file was deleted.

1 change: 1 addition & 0 deletions chapter-14/recipe-03/fortran-example/dashboard.cmake
10 changes: 4 additions & 6 deletions chapter-14/recipe-03/fortran-example/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
add_library(buggy "")

target_sources(
buggy
target_sources(buggy
PUBLIC
${CMAKE_CURRENT_LIST_DIR}/buggy.f90
)
Expand All @@ -10,13 +9,12 @@ option(ENABLE_ASAN "Enable AddressSanitizer" OFF)

if(ENABLE_ASAN)
if(CMAKE_Fortran_COMPILER_ID MATCHES GNU)
target_compile_options(
buggy
message(STATUS "AddressSanitizer enabled")
target_compile_options(buggy
PUBLIC
-g -fsanitize=address
)
target_link_libraries(
buggy
target_link_libraries(buggy
PUBLIC
asan
)
Expand Down
2 changes: 1 addition & 1 deletion chapter-14/recipe-03/fortran-example/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ add_test(
NAME
leaky
COMMAND
${PROJECT_BINARY_DIR}/tests/leaky
$<TARGET_FILE:leaky>
)
15 changes: 12 additions & 3 deletions testing/collect_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ def run_example(topdir, generator, ci_environment, buildflags, recipe, example):
return 0

if skip:
sys.stdout.write(
'\nSKIPPING recipe (based on menu.yml)\n'
)
sys.stdout.write('\nSKIPPING recipe (based on menu.yml)\n')
return 0

return_code = 0
Expand Down Expand Up @@ -206,6 +204,17 @@ def run_example(topdir, generator, ci_environment, buildflags, recipe, example):
return_code += run_command(
step=step, command=command, expect_failure=expect_failure)

# execute dashboard script, if it exists
dashboard_script = 'dashboard.cmake'
dashboard_script_path = cmakelists_path / dashboard_script
if dashboard_script_path.exists():
# if this directory contains a dashboard.cmake script, we launch it
step = dashboard_script
command = r'ctest -C {0} -S {1} -DCTEST_CMAKE_GENERATOR={2}'.format(
configuration, dashboard_script_path, generator)
return_code += run_command(
step=step, command=command, expect_failure=expect_failure)

for entry in env:
os.environ.pop(entry)

Expand Down

0 comments on commit 6f633bc

Please sign in to comment.