update: revert formatting

Co-authored-by: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
This commit is contained in:
Lorenzo Fontana
2019-07-01 10:11:27 +00:00
committed by Lorenzo Fontana
parent 583be9ce22
commit 9bc28951ad
6 changed files with 543 additions and 844 deletions

View File

@@ -1,119 +0,0 @@
# --------------------------
# General Formatting Options
# --------------------------
# How wide to allow formatted cmake files
line_width = 80
# How many spaces to tab for indent
tab_size = 2
# If arglists are longer than this, break them always
max_subargs_per_line = 3
# If true, separate flow control names from their parentheses with a space
separate_ctrl_name_with_space = False
# If true, separate function names from parentheses with a space
separate_fn_name_with_space = False
# If a statement is wrapped to more than one line, than dangle the closing
# parenthesis on it's own line
dangle_parens = False
# If the statement spelling length (including space and parenthesis is larger
# than the tab width by more than this amoung, then force reject un-nested
# layouts.
max_prefix_chars = 2
# If a candidate layout is wrapped horizontally but it exceeds this many lines,
# then reject the layout.
max_lines_hwrap = 2
# What style line endings to use in the output.
line_ending = 'unix'
# Format command names consistently as 'lower' or 'upper' case
command_case = 'canonical'
# Format keywords consistently as 'lower' or 'upper' case
keyword_case = 'unchanged'
# Specify structure for custom cmake functions
additional_commands = {
"pkg_find": {
"kwargs": {
"PKG": "*"
}
}
}
# A list of command names which should always be wrapped
always_wrap = []
# Specify the order of wrapping algorithms during successive reflow attempts
algorithm_order = [0, 1, 2, 3, 4]
# If true, the argument lists which are known to be sortable will be sorted
# lexicographicall
enable_sort = True
# If true, the parsers may infer whether or not an argument list is sortable
# (without annotation).
autosort = False
# If a comment line starts with at least this many consecutive hash characters,
# then don't lstrip() them off. This allows for lazy hash rulers where the first
# hash char is not separated by space
hashruler_min_length = 10
# A dictionary containing any per-command configuration overrides. Currently
# only `command_case` is supported.
per_command = {}
# --------------------------
# Comment Formatting Options
# --------------------------
# What character to use for bulleted lists
bullet_char = '*'
# What character to use as punctuation after numerals in an enumerated list
enum_char = '.'
# enable comment markup parsing and reflow
enable_markup = True
# If comment markup is enabled, don't reflow the first comment block in each
# listfile. Use this to preserve formatting of your copyright/license
# statements.
first_comment_is_literal = False
# If comment markup is enabled, don't reflow any comment block which matches
# this (regex) pattern. Default is `None` (disabled).
literal_comment_pattern = None
# Regular expression to match preformat fences in comments
# default=r'^\s*([`~]{3}[`~]*)(.*)$'
fence_pattern = '^\\s*([`~]{3}[`~]*)(.*)$'
# Regular expression to match rulers in comments
# default=r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'
ruler_pattern = '^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$'
# If true, then insert a space between the first hash char and remaining hash
# chars in a hash ruler, and normalize it's length to fill the column
canonicalize_hashrulers = True
# ---------------------------------
# Miscellaneous Options
# ---------------------------------
# If true, emit the unicode byte-order mark (BOM) at the start of the file
emit_byteorder_mark = False
# Specify the encoding of the input file. Defaults to utf-8.
input_encoding = 'utf-8'
# Specify the encoding of the output file. Defaults to utf-8. Note that cmake
# only claims to support utf-8 so be careful when using anything else
output_encoding = 'utf-8'

View File

@@ -3,45 +3,29 @@
# #
# This file is part of falco . # This file is part of falco .
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may not # Licensed under the Apache License, Version 2.0 (the "License");
# use this file except in compliance with the License. You may obtain a copy of # you may not use this file except in compliance with the License.
# the License at # You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # distributed under the License is distributed on an "AS IS" BASIS,
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# License for the specific language governing permissions and limitations under # See the License for the specific language governing permissions and
# the License. # limitations under the License.
# #
if(CPACK_GENERATOR MATCHES "DEB") if(CPACK_GENERATOR MATCHES "DEB")
list( list(APPEND CPACK_INSTALL_COMMANDS "mkdir -p _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/etc/init.d/")
APPEND list(APPEND CPACK_INSTALL_COMMANDS "cp scripts/debian/falco _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/etc/init.d")
CPACK_INSTALL_COMMANDS
"mkdir -p _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/etc/init.d/"
)
list(
APPEND
CPACK_INSTALL_COMMANDS
"cp scripts/debian/falco _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/etc/init.d"
)
endif() endif()
if(CPACK_GENERATOR MATCHES "RPM") if(CPACK_GENERATOR MATCHES "RPM")
list( list(APPEND CPACK_INSTALL_COMMANDS "mkdir -p _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/etc/rc.d/init.d/")
APPEND list(APPEND CPACK_INSTALL_COMMANDS "cp scripts/rpm/falco _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/etc/rc.d/init.d")
CPACK_INSTALL_COMMANDS
"mkdir -p _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/etc/rc.d/init.d/"
)
list(
APPEND
CPACK_INSTALL_COMMANDS
"cp scripts/rpm/falco _CPack_Packages/${CPACK_TOPLEVEL_TAG}/${CPACK_GENERATOR}/${CPACK_PACKAGE_FILE_NAME}/etc/rc.d/init.d"
)
endif() endif()
if(CPACK_GENERATOR MATCHES "TGZ") if(CPACK_GENERATOR MATCHES "TGZ")
set(CPACK_SET_DESTDIR "ON") set(CPACK_SET_DESTDIR "ON")
set(CPACK_STRIP_FILES "OFF") set(CPACK_STRIP_FILES "OFF")
endif() endif()

File diff suppressed because it is too large Load Diff

View File

@@ -92,13 +92,15 @@ same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``.
#]=======================================================================] #]=======================================================================]
# ------------------------------------------------------------------------------ #------------------------------------------------------------------------------
function(catch_discover_tests TARGET) function(catch_discover_tests TARGET)
cmake_parse_arguments("" cmake_parse_arguments(
"" ""
"TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST" ""
"TEST_SPEC;EXTRA_ARGS;PROPERTIES" "TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST"
${ARGN}) "TEST_SPEC;EXTRA_ARGS;PROPERTIES"
${ARGN}
)
if(NOT _WORKING_DIRECTORY) if(NOT _WORKING_DIRECTORY)
set(_WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") set(_WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
@@ -107,78 +109,67 @@ function(catch_discover_tests TARGET)
set(_TEST_LIST ${TARGET}_TESTS) set(_TEST_LIST ${TARGET}_TESTS)
endif() endif()
# Generate a unique name based on the extra arguments ## Generate a unique name based on the extra arguments
string(SHA1 args_hash "${_TEST_SPEC} ${_EXTRA_ARGS}") string(SHA1 args_hash "${_TEST_SPEC} ${_EXTRA_ARGS}")
string(SUBSTRING ${args_hash} string(SUBSTRING ${args_hash} 0 7 args_hash)
0
7
args_hash)
# Define rule to generate test list for aforementioned test executable # Define rule to generate test list for aforementioned test executable
set(ctest_include_file set(ctest_include_file "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_include-${args_hash}.cmake")
"${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_include-${args_hash}.cmake") set(ctest_tests_file "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_tests-${args_hash}.cmake")
set(ctest_tests_file
"${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_tests-${args_hash}.cmake")
get_property(crosscompiling_emulator get_property(crosscompiling_emulator
TARGET ${TARGET} TARGET ${TARGET}
PROPERTY CROSSCOMPILING_EMULATOR) PROPERTY CROSSCOMPILING_EMULATOR
add_custom_command(TARGET )
${TARGET} add_custom_command(
POST_BUILD TARGET ${TARGET} POST_BUILD
BYPRODUCTS BYPRODUCTS "${ctest_tests_file}"
"${ctest_tests_file}" COMMAND "${CMAKE_COMMAND}"
COMMAND "${CMAKE_COMMAND}" -D "TEST_TARGET=${TARGET}"
-D -D "TEST_EXECUTABLE=$<TARGET_FILE:${TARGET}>"
"TEST_TARGET=${TARGET}" -D "TEST_EXECUTOR=${crosscompiling_emulator}"
-D -D "TEST_WORKING_DIR=${_WORKING_DIRECTORY}"
"TEST_EXECUTABLE=$<TARGET_FILE:${TARGET}>" -D "TEST_SPEC=${_TEST_SPEC}"
-D -D "TEST_EXTRA_ARGS=${_EXTRA_ARGS}"
"TEST_EXECUTOR=${crosscompiling_emulator}" -D "TEST_PROPERTIES=${_PROPERTIES}"
-D -D "TEST_PREFIX=${_TEST_PREFIX}"
"TEST_WORKING_DIR=${_WORKING_DIRECTORY}" -D "TEST_SUFFIX=${_TEST_SUFFIX}"
-D -D "TEST_LIST=${_TEST_LIST}"
"TEST_SPEC=${_TEST_SPEC}" -D "CTEST_FILE=${ctest_tests_file}"
-D -P "${_CATCH_DISCOVER_TESTS_SCRIPT}"
"TEST_EXTRA_ARGS=${_EXTRA_ARGS}" VERBATIM
-D )
"TEST_PROPERTIES=${_PROPERTIES}"
-D
"TEST_PREFIX=${_TEST_PREFIX}"
-D
"TEST_SUFFIX=${_TEST_SUFFIX}"
-D
"TEST_LIST=${_TEST_LIST}"
-D
"CTEST_FILE=${ctest_tests_file}"
-P
"${_CATCH_DISCOVER_TESTS_SCRIPT}"
VERBATIM)
file( file(WRITE "${ctest_include_file}"
WRITE "${ctest_include_file}"
"if(EXISTS \"${ctest_tests_file}\")\n" "if(EXISTS \"${ctest_tests_file}\")\n"
" include(\"${ctest_tests_file}\")\n" " include(\"${ctest_tests_file}\")\n"
"else()\n" "else()\n"
" add_test(${TARGET}_NOT_BUILT-${args_hash} ${TARGET}_NOT_BUILT-${args_hash})\n" " add_test(${TARGET}_NOT_BUILT-${args_hash} ${TARGET}_NOT_BUILT-${args_hash})\n"
"endif()\n") "endif()\n"
)
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0") if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0")
# Add discovered tests to directory TEST_INCLUDE_FILES # Add discovered tests to directory TEST_INCLUDE_FILES
set_property(DIRECTORY set_property(DIRECTORY
APPEND APPEND PROPERTY TEST_INCLUDE_FILES "${ctest_include_file}"
PROPERTY TEST_INCLUDE_FILES "${ctest_include_file}") )
else() else()
# Add discovered tests as directory TEST_INCLUDE_FILE if possible # Add discovered tests as directory TEST_INCLUDE_FILE if possible
get_property(test_include_file_set DIRECTORY PROPERTY TEST_INCLUDE_FILE SET) get_property(test_include_file_set DIRECTORY PROPERTY TEST_INCLUDE_FILE SET)
if(NOT ${test_include_file_set}) if (NOT ${test_include_file_set})
set_property(DIRECTORY PROPERTY TEST_INCLUDE_FILE "${ctest_include_file}") set_property(DIRECTORY
PROPERTY TEST_INCLUDE_FILE "${ctest_include_file}"
)
else() else()
message(FATAL_ERROR "Cannot set more than one TEST_INCLUDE_FILE") message(FATAL_ERROR
"Cannot set more than one TEST_INCLUDE_FILE"
)
endif() endif()
endif() endif()
endfunction() endfunction()
# ############################################################################## ###############################################################################
set(_CATCH_DISCOVER_TESTS_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/CatchAddTests.cmake) set(_CATCH_DISCOVER_TESTS_SCRIPT
${CMAKE_CURRENT_LIST_DIR}/CatchAddTests.cmake
)

View File

@@ -24,50 +24,49 @@ endfunction()
# Run test executable to get list of available tests # Run test executable to get list of available tests
if(NOT EXISTS "${TEST_EXECUTABLE}") if(NOT EXISTS "${TEST_EXECUTABLE}")
message( message(FATAL_ERROR
FATAL_ERROR "Specified test executable '${TEST_EXECUTABLE}' does not exist") "Specified test executable '${TEST_EXECUTABLE}' does not exist"
)
endif() endif()
execute_process(COMMAND ${TEST_EXECUTOR} execute_process(
"${TEST_EXECUTABLE}" COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec} --list-test-names-only
${spec} OUTPUT_VARIABLE output
--list-test-names-only RESULT_VARIABLE result
OUTPUT_VARIABLE output )
RESULT_VARIABLE result) # Catch --list-test-names-only reports the number of tests, so 0 is... surprising
# Catch --list-test-names-only reports the number of tests, so 0 is...
# surprising
if(${result} EQUAL 0) if(${result} EQUAL 0)
message(WARNING "Test executable '${TEST_EXECUTABLE}' contains no tests!\n") message(WARNING
"Test executable '${TEST_EXECUTABLE}' contains no tests!\n"
)
elseif(${result} LESS 0) elseif(${result} LESS 0)
message(FATAL_ERROR "Error running test executable '${TEST_EXECUTABLE}':\n" message(FATAL_ERROR
" Result: ${result}\n" " Output: ${output}\n") "Error running test executable '${TEST_EXECUTABLE}':\n"
" Result: ${result}\n"
" Output: ${output}\n"
)
endif() endif()
string(REPLACE "\n" string(REPLACE "\n" ";" output "${output}")
";"
output
"${output}")
# Parse output # Parse output
foreach(line ${output}) foreach(line ${output})
set(test ${line}) set(test ${line})
# use escape commas to handle properly test cases with commans inside the name # use escape commas to handle properly test cases with commans inside the name
string(REPLACE "," string(REPLACE "," "\\," test_name ${test})
"\\,"
test_name
${test})
# ...and add to script # ...and add to script
add_command(add_test add_command(add_test
"${prefix}${test}${suffix}" "${prefix}${test}${suffix}"
${TEST_EXECUTOR} ${TEST_EXECUTOR}
"${TEST_EXECUTABLE}" "${TEST_EXECUTABLE}"
"${test_name}" "${test_name}"
${extra_args}) ${extra_args}
)
add_command(set_tests_properties add_command(set_tests_properties
"${prefix}${test}${suffix}" "${prefix}${test}${suffix}"
PROPERTIES PROPERTIES
WORKING_DIRECTORY WORKING_DIRECTORY "${TEST_WORKING_DIR}"
"${TEST_WORKING_DIR}" ${properties}
${properties}) )
list(APPEND tests "${prefix}${test}${suffix}") list(APPEND tests "${prefix}${test}${suffix}")
endforeach() endforeach()

View File

@@ -0,0 +1,34 @@
#
# Copyright (C) 2016-2019 Draios Inc dba Sysdig.
#
# This file is part of falco .
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
include(ExternalProject)
set(CATCH_EXTERNAL_URL
URL https://github.com/catchorg/Catch2/archive/v2.9.1.tar.gz
URL_HASH MD5=4980778888fed635bf191d8a86f9f89c)
ExternalProject_Add(catch2
PREFIX ${CMAKE_BINARY_DIR}/catch2-prefix
${CATCH_EXTERNAL_URL}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/catch2-prefix/src/catch2/single_include/catch2/catch.hpp
${CMAKE_BINARY_DIR}/catch2-prefix/include/catch.hpp
)
add_library(catch INTERFACE)
add_dependencies(catch catch2)
target_include_directories(catch INTERFACE ${CMAKE_BINARY_DIR}/catch2-prefix/include)