File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6363
6464 # TODO: Change the task to run all unittests once any unittest is added. Until then we check
6565 # that building the project succeeds.
66- - run : " task build:target "
66+ - run : " task build:all "
Original file line number Diff line number Diff line change @@ -11,14 +11,25 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS
1111 FORCE
1212)
1313
14+ find_package (Catch2 3.8.0 REQUIRED )
15+ if (Catch2_FOUND)
16+ message (STATUS "Found Catch2 ${Catch2_VERSION} ." )
17+ else ()
18+ message (FATAL_ERROR "Could not find libraries for Catch2." )
19+ endif ()
20+
1421# Import CMake helper functions
1522list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR } /CMake)
1623include (ystdlib-cpp-helpers )
1724
1825add_subdirectory (src/ystdlib )
1926
20- # Test dummy project
21- add_executable (dummy )
22- target_sources (dummy PRIVATE src/main.cpp )
23- target_link_libraries (dummy PRIVATE ystdlib::testlib )
24- target_compile_features (dummy PRIVATE cxx_std_20 )
27+ add_executable (unitTest )
28+ target_sources (unitTest PRIVATE src/main.cpp )
29+ target_link_libraries (
30+ unitTest
31+ PRIVATE
32+ ystdlib::testlib
33+ Catch2::Catch2WithMain
34+ )
35+ target_compile_features (unitTest PRIVATE cxx_std_20 )
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ git submodule update --init --recursive
3030## Building
3131To build all targets in ` ystdlib-cpp ` :
3232``` shell
33- task build:target
33+ task build:all
3434```
3535
3636## Linting
Original file line number Diff line number Diff line change 1+ BasedOnStyle : " InheritParentConfig"
2+
3+ IncludeCategories :
4+ # NOTE: A header is grouped by first matching regex library headers. Update when adding new
5+ # libraries.
6+ # NOTE: clang-format retains leading white-space on a line in violation of the YAML spec.
7+ - Regex : " <(ystdlib)"
8+ Priority : 3
9+ - Regex : " <(catch2)"
10+ Priority : 4
11+ # C system headers
12+ - Regex : " ^<.+\\ .h>"
13+ Priority : 1
14+ # C++ standard libraries
15+ - Regex : " ^<.+>"
16+ Priority : 2
17+ # Project headers
18+ - Regex : " ^\" .+\" "
19+ Priority : 5
Original file line number Diff line number Diff line change 11#include < concepts>
2- # include < iostream >
2+
33#include < ystdlib/testlib/hello.hpp>
44
5+ #include < catch2/catch_test_macros.hpp>
6+
57namespace {
68template <typename T>
79requires std::integral<T>
10+
811[[nodiscard]] auto square (T x) -> T {
912 return x * x;
1013}
1114}; // namespace
1215
13- [[nodiscard]] auto main () -> int {
14- std::cout << square (ystdlib::testlib::hello ().size ()) << ' \n ' ;
15- return 0 ;
16+ TEST_CASE (" dummy" ) {
17+ REQUIRE ((169 == square (ystdlib::testlib::hello ().size ())));
1618}
Original file line number Diff line number Diff line change @@ -2,32 +2,21 @@ version: "3"
22
33includes :
44 build : " ./taskfiles/build.yaml"
5+ deps : " ./taskfiles/deps.yaml"
56 lint : " ./taskfiles/lint.yaml"
6- utils : " tools/yscope-dev-utils/taskfiles/utils.yml "
7+ utils : " tools/yscope-dev-utils/taskfiles/utils.yaml "
78
89vars :
910 G_BUILD_DIR : " {{.ROOT_DIR}}/build"
10- G_CMAKE_CACHE : " {{.G_BUILD_DIR}}/CMakeCache.txt"
11- G_COMPILE_COMMANDS_DB : " {{.G_BUILD_DIR}}/compile_commands.json"
1211 G_CPP_SRC_DIR : " {{.ROOT_DIR}}/src"
12+ G_DEPS_DIR : " {{.G_BUILD_DIR}}/deps"
1313
1414tasks :
1515 clean :
1616 desc : " Removes the project build directory."
1717 cmds :
1818 - " rm -rf '{{.G_BUILD_DIR}}'"
1919
20- config-cmake-project :
21- internal : true
22- sources :
23- - " CMakeLists.txt"
24- - " {{.TASKFILE}}"
25- generates :
26- - " {{.G_CMAKE_CACHE}}"
27- - " {{.G_COMPILE_COMMANDS_DB}}"
28- cmds :
29- - " cmake -S '{{.ROOT_DIR}}' -B '{{.G_BUILD_DIR}}'"
30-
3120 init :
3221 internal : true
3322 silent : true
Original file line number Diff line number Diff line change 11version : " 3"
22
3+ vars :
4+ G_CMAKE_CACHE : " {{.G_BUILD_DIR}}/CMakeCache.txt"
5+ G_CMAKE_CONF_ARGS :
6+ - " -DCatch2_ROOT={{.G_DEPS_DIR}}/Catch2/Catch2-install"
7+ G_COMPILE_COMMANDS_DB : " {{.G_BUILD_DIR}}/compile_commands.json"
8+
39tasks :
4- target :
10+ all :
511 desc : " Builds ystdlib-cpp."
6- vars :
7- TARGETS :
8- ref : " default (list \" all\" ) .TARGETS"
912 deps :
10- - " :config-cmake-project "
13+ - " init "
1114 cmds :
12- - >-
13- cmake
14- --build "{{.G_BUILD_DIR}}"
15- --parallel {{numCPU}}
16- --target {{range .TARGETS}}{{.}} {{end}}
15+ - task : " :utils:cmake-build"
16+ vars :
17+ BUILD_DIR : " {{.G_BUILD_DIR}}"
1718
1819 clean :
1920 desc : " Removes all built artifacts."
2021 deps :
21- - " :config-cmake-project"
22+ - task : " :utils:cmake-clean"
23+ vars :
24+ BUILD_DIR : " {{.G_BUILD_DIR}}"
25+
26+ init :
27+ internal : true
28+ deps :
29+ - " :deps:install-all"
30+ run : " once"
2231 cmds :
23- - >-
24- cmake
25- --build "{{.G_BUILD_DIR}}"
26- --parallel {{numCPU}}
27- --target clean
32+ - task : " :utils:cmake-generate"
33+ vars :
34+ BUILD_DIR : " {{.G_BUILD_DIR}}"
35+ EXTRA_ARGS :
36+ ref : " .G_CMAKE_CONF_ARGS"
37+ SOURCE_DIR : " {{.ROOT_DIR}}"
Original file line number Diff line number Diff line change 1+ version : " 3"
2+
3+ tasks :
4+ install-all :
5+ desc : " Install all dependencies required by ystdlib-cpp."
6+ deps :
7+ - " install-Catch2"
8+
9+ install-Catch2 :
10+ internal : true
11+ vars :
12+ NAME : " Catch2"
13+ WORK_DIR : " {{.G_DEPS_DIR}}/{{.NAME}}"
14+ run : " once"
15+ cmds :
16+ - task : " :utils:cmake-install-remote-tar"
17+ vars :
18+ NAME : " {{.NAME}}"
19+ WORK_DIR : " {{.WORK_DIR}}"
20+ FILE_SHA256 : " 1ab2de20460d4641553addfdfe6acd4109d871d5531f8f519a52ea4926303087"
21+ URL : " https://github.com/catchorg/Catch2/archive/refs/tags/v3.8.0.tar.gz"
Original file line number Diff line number Diff line change 6565 - " {{.ROOT_DIR}}/.clang-tidy"
6666 - " {{.TASKFILE}}"
6767 deps :
68- - " :config-cmake-project "
68+ - " :build:init "
6969 - " cpp-configs"
7070 - " venv"
7171 cmds :
Original file line number Diff line number Diff line change 1818 - task : " :utils:validate-checksum"
1919 vars :
2020 CHECKSUM_FILE : " {{.CHECKSUM_FILE}}"
21- DATA_DIR : " {{.OUTPUT_DIR}}"
21+ INCLUDE_PATTERNS : [ "{{.OUTPUT_DIR}}"]
2222 cmds :
2323 - task : " :utils:create-venv"
2424 vars :
2828 # This command must be last
2929 - task : " :utils:compute-checksum"
3030 vars :
31- DATA_DIR : " {{.OUTPUT_DIR }}"
32- OUTPUT_FILE : " {{.CHECKSUM_FILE }}"
31+ CHECKSUM_FILE : " {{.CHECKSUM_FILE }}"
32+ INCLUDE_PATTERNS : [ "{{.OUTPUT_DIR }}"]
You can’t perform that action at this time.
0 commit comments