From 67b91123bbe125f0b82bf9cd17df3389dc0695c6 Mon Sep 17 00:00:00 2001 From: Mark Meredith Date: Tue, 23 Jun 2020 21:35:56 +0000 Subject: [PATCH] Run tests from Meson --- .gitlab-ci.yml | 16 +++++++++++++--- README.md | 36 +++++++++++------------------------- conanfile.py | 1 + meson.build | 4 ++-- src/csg/CMakeLists.txt | 4 ++-- src/csg/meson.build | 11 +++++------ src/csg/tests/CMakeLists.txt | 2 +- src/csg/tests/meson.build | 6 +++--- 8 files changed, 38 insertions(+), 42 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e349ab6..2cf3749 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,14 +6,24 @@ variables: ###### Test jobs ##### -test:meson: +.test:meson: &conan_def script: - python -m pip install conan - - conan create . - # - meson test -C build --print-errorlogs + - conan create . -s build_type=$BUILD_TYPE tags: - mfix-exa +test:meson:debug: + variables: + BUILD_TYPE: "Debug" + <<: *conan_def + +test:meson:release: + variables: + BUILD_TYPE: "Release" + allow_failure: true + <<: *conan_def + .test:cmake: &cmake_def script: - python -m pip install cmake ninja conan diff --git a/README.md b/README.md index 007c723..e3fab69 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # csg-eb -Library for parsing [Constructive Solid Geometry (CSG) files](https://github.com/openscad/openscad/wiki/CSG-File-Format) into an implicit function that can be used to define [Embedded Boundaries (EB)](https://amrex-codes.github.io/amrex/docs_html/EB.html). +Library for parsing [Constructive Solid Geometry (CSG) +files](https://github.com/openscad/openscad/wiki/CSG-File-Format) into an +implicit function that can be used to define [Embedded Boundaries +(EB)](https://amrex-codes.github.io/amrex/docs_html/EB.html). Uses PEGTL for parsing and Catch2 for tests. @@ -14,35 +17,18 @@ Uses PEGTL for parsing and Catch2 for tests. #### Installing conan for the first time python3 -m pip install conan - + #### Building using CMake cmake -S . -B build -DCMAKE_BUILD_TYPE=Release cmake --build build --target unit_tests_csg cd build make -j - -#### Running unit tests - - ctest - - -### Meson - -#### Installing meson and ninja the first time - - python3 -m pip install meson ninja - -#### Building using meson - - meson build - ninja -C build - #### Running unit tests - meson test -C build - + ctest + ## Using the library in other projects @@ -54,7 +40,7 @@ Uses PEGTL for parsing and Catch2 for tests. * Create a function object auto csg_if = csg::get_csgif(, is_internal_flow); - + * Above returns an implicit function which can be operated on a 3D point coordinate (x, y, z) as csg_if(x, y, z) @@ -62,11 +48,11 @@ Uses PEGTL for parsing and Catch2 for tests. * Can be passed to amrex EB2::makeShop auto gshop = EB2::makeShop(*csg_if); - + ### Note on the return value * If `internal_flow` is set to `true` - - **csg_if(x, y, z)** returns a number `less than 0`, if (x, y, z) lies `inside` the CSG object (a hollow) + - **csg_if(x, y, z)** returns a number `less than 0`, if (x, y, z) lies `inside` the CSG object (a hollow) - **csg_if(x, y, z)** returns a number `greater than 0`, if (x, y, z) lies `outside` the CSG object (a hollow) * If `internal_flow` is set to `false` - **csg_if(x, y, z)** returns a number `greater than 0`, if (x, y, z) lies `inside` the CSG object (a solid) @@ -77,7 +63,7 @@ Uses PEGTL for parsing and Catch2 for tests. * Build by adding as subdirectory in appropriate CMake file add_subdirectory() - + * Link by setting the dependency in appropriate CMake file target_link_libraries( PRIVATE csg) diff --git a/conanfile.py b/conanfile.py index 74b382e..04ac3fb 100644 --- a/conanfile.py +++ b/conanfile.py @@ -21,6 +21,7 @@ class CsgEbConan(ConanFile): meson = Meson(self) meson.configure(build_folder="build") meson.build() + meson.meson_test(args=['--verbose', '--print-errorlog']) def package(self): self.copy("*.h", dst="include", src="csg-eb") diff --git a/meson.build b/meson.build index 000b0fc..cc7f470 100644 --- a/meson.build +++ b/meson.build @@ -2,8 +2,8 @@ project( 'csg-eb', 'cpp', version : '0.1', default_options : [ - 'warning_level=3', - 'cpp_std=c++17' + 'warning_level=1', + 'cpp_std=c++2a' ] ) diff --git a/src/csg/CMakeLists.txt b/src/csg/CMakeLists.txt index 2855e95..f3d2aba 100644 --- a/src/csg/CMakeLists.txt +++ b/src/csg/CMakeLists.txt @@ -2,13 +2,13 @@ # CSG Parser ################################################################################ add_library(csg + cgal_helper_polygon.cpp + cgal_helper_polyhedron.cpp csg.cpp levelset_2d.cpp levelset_3d.cpp matrix_functions.cpp parser.cpp - cgal_helper_polyhedron.cpp - cgal_helper_polygon.cpp ) target_link_libraries(csg PRIVATE diff --git a/src/csg/meson.build b/src/csg/meson.build index 0b5b695..6d81be4 100644 --- a/src/csg/meson.build +++ b/src/csg/meson.build @@ -1,12 +1,11 @@ -lib_csg_parser = static_library( - 'csg-parser', +lib_csg_parser = static_library('csg-parser', + 'cgal_helper_polygon.cpp', + 'cgal_helper_polyhedron.cpp', 'csg.cpp', - 'levelset_3d.cpp', 'levelset_2d.cpp', - 'parser.cpp', + 'levelset_3d.cpp', 'matrix_functions.cpp', - 'cgal_helper_polyhedron.cpp', - 'cgal_helper_polygon.cpp', + 'parser.cpp', include_directories: parser_inc, dependencies: [pegtl, cgal], install : true) diff --git a/src/csg/tests/CMakeLists.txt b/src/csg/tests/CMakeLists.txt index 6679700..94b3fb7 100644 --- a/src/csg/tests/CMakeLists.txt +++ b/src/csg/tests/CMakeLists.txt @@ -5,9 +5,9 @@ add_executable(unit_tests_csg EXCLUDE_FROM_ALL levelset/boolean.t.cpp levelset/extrude.t.cpp + levelset/internal_flow.t.cpp levelset/primitives.t.cpp levelset/transform.t.cpp - levelset/internal_flow.t.cpp parser/boolean.t.cpp parser/extrude.t.cpp parser/nest.cpp diff --git a/src/csg/tests/meson.build b/src/csg/tests/meson.build index 5aac104..b2897a6 100644 --- a/src/csg/tests/meson.build +++ b/src/csg/tests/meson.build @@ -1,10 +1,9 @@ -test_csg = executable( - 'unit_tests_csg', +test_csg = executable('unit_tests_csg', 'levelset/boolean.t.cpp', 'levelset/extrude.t.cpp', + 'levelset/internal_flow.t.cpp', 'levelset/primitives.t.cpp', 'levelset/transform.t.cpp', - 'levelset/internal_flow.t.cpp', 'parser/boolean.t.cpp', 'parser/extrude.t.cpp', 'parser/nest.cpp', @@ -17,4 +16,5 @@ test_csg = executable( link_with: lib_csg_parser, override_options: 'cpp_std=c++2a', ) + test('unit_test_csg', test_csg) -- GitLab