Skip to content

Commit a98633a

Browse files
authored
Improve random_test output. (#25)
2 parents e03138a + 4201114 commit a98633a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1839
-547
lines changed

.clang-tidy

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,32 @@
11
---
2-
Checks: 'abseil-*,altera-*,bugprone-*,concurrency-*,cppcoreguidelines-*,darwin-*,fuchsia-*,readability-*,performance-*,portability-*,zircon-*,hicpp-*,google-*,cert-*,clang-diagnostic-*,clang-analyzer-*,modernize-*,-*'
2+
Checks: ['bugprone-*',
3+
'cert-*',
4+
'clang-analyzer-*',
5+
'clang-diagnostic-*',
6+
'concurrency-*',
7+
'cppcoreguidelines-*',
8+
'darwin-*',
9+
'modernize-*',
10+
'performance-*',
11+
'portability-*',
12+
'readability-*',
13+
'zircon-*',
14+
# Remove the following:
15+
'-bugprone-easily-swappable-parameters',
16+
'-bugprone-suspicious-semicolon',
17+
'-cert-dcl37-c',
18+
'-cert-dcl50-cpp',
19+
'-cert-dcl51-cpp',
20+
'-cppcoreguidelines-avoid-magic-numbers',
21+
'-cppcoreguidelines-pro-bounds-array-to-pointer-decay',
22+
'-cppcoreguidelines-pro-type-vararg',
23+
'-modernize-use-trailing-return-type',
24+
'-readability-braces-around-statements',
25+
'-readability-identifier-length',
26+
'-readability-magic-numbers',
27+
]
328
WarningsAsErrors: ''
429
HeaderFilterRegex: ''
5-
AnalyzeTemporaryDtors: false
630
FormatStyle: Microsoft
731
User: coder
832
CheckOptions:
@@ -24,5 +48,7 @@ CheckOptions:
2448
modernize-loop-convert.NamingStyle: CamelCase
2549
llvm-else-after-return.WarnOnUnfixable: 'false'
2650
google-readability-function-size.StatementThreshold: '800'
51+
bugprone-reserved-identifier.AllowedIdentifiers: '__internals'
52+
readability-function-cognitive-complexity.Threshold: 40
2753
...
2854

.clangd

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,39 @@ CompileFlags:
22
Add: -std=c++20
33
Diagnostics:
44
ClangTidy:
5-
Add: modernize*
6-
Remove: modernize-use-trailing-return-type
5+
Add: ['bugprone-*',
6+
'concurrency-*',
7+
'cppcoreguidelines-*',
8+
'darwin-*',
9+
'readability-*',
10+
'performance-*',
11+
'portability-*',
12+
'zircon-*',
13+
'cert-*',
14+
'clang-diagnostic-*',
15+
'clang-analyzer-*',
16+
'modernize-*']
17+
CheckOptions:
18+
'bugprone-reserved-identifier.AllowedIdentifiers': '__internals'
19+
'readability-function-cognitive-complexity.Threshold': 40
20+
21+
Remove: [
22+
'modernize-use-trailing-return-type',
23+
'cppcoreguidelines-avoid-magic-numbers',
24+
'readability-magic-numbers',
25+
'bugprone-easily-swappable-parameters',
26+
'cert-dcl50-cpp',
27+
'cert-dcl37-c',
28+
'cert-dcl51-cpp',
29+
'cppcoreguidelines-pro-type-vararg',
30+
'readability-braces-around-statements',
31+
'readability-identifier-length'
32+
]
33+
34+
---
35+
# Disable include-what-you-use for test files
36+
If:
37+
PathMatch: test.*\.cpp
38+
39+
Diagnostics:
40+
UnusedIncludes: None

.cmake-format

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ with section("format"): # pyright: ignore
211211

212212
# If a statement is wrapped to more than one line, than dangle the closing
213213
# parenthesis on its own line.
214-
dangle_parens = False
214+
dangle_parens = True
215215

216216
# If the trailing parenthesis must be 'dangled' on its on line, then align it
217217
# to this reference: `prefix`: the start of the statement, `prefix-indent`:
@@ -236,7 +236,7 @@ with section("format"): # pyright: ignore
236236
line_ending = "unix"
237237

238238
# Format command names consistently as 'lower' or 'upper' case
239-
command_case = "lower"
239+
command_case = "upper"
240240

241241
# Format keywords consistently as 'lower' or 'upper' case
242242
keyword_case = "upper"
@@ -275,7 +275,7 @@ with section("markup"): # pyright: ignore
275275
# If comment markup is enabled, don't reflow the first comment block in each
276276
# listfile. Use this to preserve formatting of your copyright/license
277277
# statements.
278-
first_comment_is_literal = False
278+
first_comment_is_literal = True
279279

280280
# If comment markup is enabled, don't reflow any comment block which matches
281281
# this (regex) pattern. Default is `None` (disabled).

.github/workflows/cmake-multi-platform.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: CMake on multiple platforms
44

55
on:
66
push:
7-
branches: [ "main", "develop" ]
7+
branches: [ "develop" ]
88
pull_request:
99
branches: [ "main" ]
1010

.github/workflows/lint.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage.
2+
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
3+
name: Lint
4+
5+
on:
6+
push:
7+
branches: [ "develop" ]
8+
pull_request:
9+
branches: [ "main" ]
10+
11+
env:
12+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
13+
BUILD_TYPE: Release
14+
15+
jobs:
16+
build:
17+
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
18+
# You can convert this to a matrix build if you need cross-platform coverage.
19+
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
20+
runs-on: macos-latest
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Set up Homebrew
26+
id: set-up-homebrew
27+
uses: Homebrew/actions/setup-homebrew@master
28+
29+
- name: Install LLVM
30+
run: |
31+
brew install llvm
32+
echo "/opt/homebrew/opt/llvm/bin:$GITHUB_PATH" > $GITHUB_PATH
33+
34+
- name: Setup Python
35+
uses: actions/[email protected]
36+
with:
37+
# Version range or exact version of Python or PyPy to use, using SemVer's version range syntax. Reads from .python-version if unset.
38+
python-version: '3.12'
39+
40+
- name: Install packages
41+
run: pip install -r ${{github.workspace}}/requirements.txt
42+
43+
- name: Configure CMake
44+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
45+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
46+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
47+
48+
- name: Lint
49+
run: python3 tools/run_clang_tidy.py -source-filter='.*lib.*' -p build

CMakeLists.txt

Lines changed: 108 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -20,93 +20,117 @@
2020
# SOFTWARE. #
2121
#####################################################################################################
2222

23-
cmake_minimum_required(VERSION 3.20)
24-
project(Steppable)
23+
CMAKE_MINIMUM_REQUIRED(VERSION 3.20)
24+
PROJECT(Steppable)
2525

2626
# Ensure that Python is available to run the development scripts, and build with bindings.
27-
find_package(Python COMPONENTS Interpreter Development REQUIRED)
28-
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
29-
30-
set(CMAKE_CXX_STANDARD 20)
31-
set(CMAKE_CXX_EXTENSIONS OFF)
32-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
33-
34-
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
35-
36-
set(STP_BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} CACHE STRING "The source directory of Steppable")
37-
38-
39-
execute_process(COMMAND uname -o COMMAND tr -d '\n' OUTPUT_VARIABLE OPERATING_SYSTEM)
40-
if (${OPERATING_SYSTEM} MATCHES "Android")
41-
set(ANDROID 1)
42-
message(STATUS "Building for Android.")
43-
set(LINUX CACHE INTERNAL "Is Linux or Android" 1)
44-
endif ()
45-
46-
if (WIN32)
47-
add_compile_definitions(WINDOWS)
48-
if (MSVC) # MSVC Has no UTF-8 support by default
49-
add_compile_options(/utf-8)
50-
endif ()
51-
set(WINDOWS TRUE)
52-
elseif (APPLE)
53-
add_compile_definitions(MACOSX)
54-
elseif (LINUX)
55-
add_compile_definitions(LINUX)
56-
else ()
57-
message(ERROR "Platform not defined")
58-
endif ()
59-
60-
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
61-
add_compile_definitions(DEBUG)
62-
set(DEBUG TRUE)
63-
endif ()
64-
65-
function(capitalize IN OUT)
66-
string(SUBSTRING ${IN} 0 1 FIRST_LETTER)
67-
string(SUBSTRING ${IN} 1 -1 THE_REST)
68-
string(TOUPPER ${FIRST_LETTER} FIRST_LETTER)
69-
string(CONCAT CAPITALIZED ${FIRST_LETTER} ${THE_REST})
70-
set(${OUT}
71-
${CAPITALIZED}
72-
PARENT_SCOPE)
73-
endfunction()
74-
75-
set(COMPONENTS abs add baseConvert subtract multiply decimalConvert comparison power division root)
76-
# NEW_COMPONENT: PATCH
77-
# Do NOT remove the previous comment.
78-
79-
set(TARGETS ${COMPONENTS} util)
80-
set(TEST_TARGETS_TEMP util fraction number ${COMPONENTS})
81-
82-
foreach (TEST_TARGET IN LISTS TEST_TARGETS_TEMP)
83-
set(TARGET_NAME "test")
84-
capitalize(${TEST_TARGET} FILE_NAME)
85-
string(CONCAT TARGET_NAME ${TARGET_NAME} ${FILE_NAME})
86-
list(APPEND TEST_TARGETS ${TARGET_NAME})
87-
endforeach ()
88-
89-
add_subdirectory(src/)
90-
add_subdirectory(lib/)
91-
add_subdirectory(tests/)
92-
add_subdirectory(include/) # The CMakeLists file there adds the include/ directory to everything
93-
94-
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
95-
96-
97-
if (DEBUG)
27+
FIND_PACKAGE(
28+
Python
29+
COMPONENTS Interpreter Development
30+
REQUIRED
31+
)
32+
FIND_PACKAGE(
33+
Python3
34+
COMPONENTS Interpreter Development
35+
REQUIRED
36+
)
37+
38+
SET(CMAKE_CXX_STANDARD 20)
39+
SET(CMAKE_CXX_EXTENSIONS OFF)
40+
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
41+
42+
SET(CMAKE_EXPORT_COMPILE_COMMANDS ON)
43+
44+
SET(STP_BASE_DIRECTORY
45+
${CMAKE_CURRENT_SOURCE_DIR}
46+
CACHE STRING "The source directory of Steppable"
47+
)
48+
49+
EXECUTE_PROCESS(
50+
COMMAND uname -o
51+
COMMAND tr -d '\n'
52+
OUTPUT_VARIABLE OPERATING_SYSTEM
53+
)
54+
IF(${OPERATING_SYSTEM} MATCHES "Android")
55+
SET(ANDROID 1)
56+
MESSAGE(STATUS "Building for Android.")
57+
SET(LINUX CACHE INTERNAL "Is Linux or Android" 1)
58+
ENDIF()
59+
60+
IF(WIN32)
61+
ADD_COMPILE_DEFINITIONS(WINDOWS)
62+
IF(MSVC) # MSVC Has no UTF-8 support by default
63+
ADD_COMPILE_OPTIONS(/utf-8)
64+
ENDIF()
65+
SET(WINDOWS TRUE)
66+
ELSEIF(APPLE)
67+
ADD_COMPILE_DEFINITIONS(MACOSX)
68+
ELSEIF(LINUX)
69+
ADD_COMPILE_DEFINITIONS(LINUX)
70+
ELSE()
71+
MESSAGE(ERROR "Platform not defined")
72+
ENDIF()
73+
74+
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
75+
ADD_COMPILE_DEFINITIONS(DEBUG)
76+
SET(DEBUG TRUE)
77+
ENDIF()
78+
79+
FUNCTION(capitalize IN OUT)
80+
STRING(SUBSTRING ${IN} 0 1 FIRST_LETTER)
81+
STRING(SUBSTRING ${IN} 1 -1 THE_REST)
82+
STRING(TOUPPER ${FIRST_LETTER} FIRST_LETTER)
83+
STRING(CONCAT CAPITALIZED ${FIRST_LETTER} ${THE_REST})
84+
SET(${OUT}
85+
${CAPITALIZED}
86+
PARENT_SCOPE
87+
)
88+
ENDFUNCTION()
89+
90+
SET(COMPONENTS
91+
abs
92+
add
93+
baseConvert
94+
subtract
95+
multiply
96+
decimalConvert
97+
comparison
98+
power
99+
division
100+
root
101+
)
102+
# NEW_COMPONENT: PATCH Do NOT remove the previous comment.
103+
104+
SET(TARGETS ${COMPONENTS} util)
105+
SET(TEST_TARGETS_TEMP util fraction number factors ${COMPONENTS})
106+
107+
FOREACH(TEST_TARGET IN LISTS TEST_TARGETS_TEMP)
108+
SET(TARGET_NAME "test")
109+
CAPITALIZE(${TEST_TARGET} FILE_NAME)
110+
STRING(CONCAT TARGET_NAME ${TARGET_NAME} ${FILE_NAME})
111+
LIST(APPEND TEST_TARGETS ${TARGET_NAME})
112+
ENDFOREACH()
113+
114+
ADD_SUBDIRECTORY(src/)
115+
ADD_SUBDIRECTORY(lib/)
116+
ADD_SUBDIRECTORY(tests/)
117+
ADD_SUBDIRECTORY(include/) # The CMakeLists file there adds the include/ directory to everything
118+
119+
FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
120+
121+
IF(DEBUG)
98122
# Patch the compile_commands.json using the Python script
99-
add_custom_target(
100-
fix_ccjson ALL
101-
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/patch_compile_commands.py
102-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
103-
COMMENT "Patching compile_commands.json"
123+
ADD_CUSTOM_TARGET(
124+
fix_ccjson ALL
125+
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/patch_compile_commands.py
126+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
127+
COMMENT "Patching compile_commands.json"
104128
)
105129

106-
add_custom_target(
107-
add_header_comments ALL
108-
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/add_copyright_header.py
109-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
110-
COMMENT "Adding header comments"
130+
ADD_CUSTOM_TARGET(
131+
add_header_comments ALL
132+
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/add_copyright_header.py
133+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
134+
COMMENT "Adding header comments"
111135
)
112-
endif ()
136+
ENDIF()

include/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
#####################################################################################################
2222

2323
# Add include directory to all targets
24-
foreach (TARGET IN LISTS TEST_TARGETS)
25-
target_include_directories(${TARGET} PUBLIC ${STP_BASE_DIRECTORY}/include/)
26-
endforeach (TARGET)
24+
FOREACH(TARGET IN LISTS TEST_TARGETS)
25+
TARGET_INCLUDE_DIRECTORIES(${TARGET} PUBLIC ${STP_BASE_DIRECTORY}/include/)
26+
ENDFOREACH(TARGET)

include/argParse.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ namespace steppable::__internals::utils
5454

5555
/// @brief This is the correct format of a keyword argument.
5656
// language=RegExp
57-
[[maybe_unused]] static const std::regex KEYWORD_ARG_REGEX(R"(^-([a-zA-Z]*):(-?[0-9]+)$)");
57+
[[maybe_unused]] const std::regex KEYWORD_ARG_REGEX(R"(^-([a-zA-Z]*):(-?[0-9]+)$)");
5858

5959
/// @brief This is the correct format of a switch.
6060
// language=RegExp
61-
[[maybe_unused]] static const std::regex SWITCH_REGEX(R"(^([-+])([a-zA-Z]*)$)");
61+
[[maybe_unused]] const std::regex SWITCH_REGEX(R"(^([-+])([a-zA-Z]*)$)");
6262

6363
/**
6464
* @class ProgramArgs

0 commit comments

Comments
 (0)