Skip to content

Commit 0926d2f

Browse files
authored
Merge pull request #70 from NuiCpp/devel
Added Tests and Example App to Actions
2 parents 7d2bbfc + 36f9f50 commit 0926d2f

File tree

31 files changed

+318
-56
lines changed

31 files changed

+318
-56
lines changed

.github/workflows/build_and_test.yml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
env:
1010
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
11-
BUILD_TYPE: Release
11+
BUILD_TYPE: Debug
1212

1313
jobs:
1414
ubuntu:
@@ -35,19 +35,16 @@ jobs:
3535
platform_version: 22.04
3636

3737
- name: Configure CMake
38-
run: cmake -B ${{github.workspace}}/build/clang_${{env.BUILD_TYPE}} -G"Ninja" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DNUI_BUILD_EXAMPLES=off -DCMAKE_CXX_EXTENSIONS=on -DCMAKE_CXX_FLAGS="-fuse-ld=lld" -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_LINKER=lld -DCMAKE_CXX_STANDARD=20
38+
run: cmake -B ${{github.workspace}}/build/clang_${{env.BUILD_TYPE}} -G"Ninja" -DNUI_ENABLE_TESTS=on -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DNUI_BUILD_EXAMPLES=on -DCMAKE_CXX_EXTENSIONS=on -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_LINKER=lld -DCMAKE_CXX_STANDARD=20
3939
env:
4040
BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}
4141

4242
- name: Build
4343
run: cmake --build ${{github.workspace}}/build/clang_${{env.BUILD_TYPE}} --config ${{env.BUILD_TYPE}}
4444

45-
# TODO:
46-
#- name: Test
47-
# working-directory: ${{github.workspace}}/build/clang_${{env.BUILD_TYPE}}
48-
# Execute tests defined by the CMake configuration.
49-
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
50-
# run: ctest -C ${{env.BUILD_TYPE}}
45+
- name: Test
46+
working-directory: ${{github.workspace}}/build/clang_${{env.BUILD_TYPE}}
47+
run: ./tests/nui-tests
5148

5249
ubuntu20:
5350
runs-on: ubuntu-20.04
@@ -76,13 +73,17 @@ jobs:
7673
platform: x64
7774

7875
- name: Configure CMake
79-
run: cmake -B ${{github.workspace}}/build/clang_${{env.BUILD_TYPE}} -G"Ninja" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DNUI_BUILD_EXAMPLES=off -DCMAKE_CXX_EXTENSIONS=on -DCMAKE_CXX_COMPILER=c++ -DCMAKE_C_COMPILER=cc -DCMAKE_CXX_STANDARD=20
76+
run: cmake -B ${{github.workspace}}/build/clang_${{env.BUILD_TYPE}} -G"Ninja" -DNUI_ENABLE_TESTS=on -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DNUI_BUILD_EXAMPLES=on -DCMAKE_CXX_EXTENSIONS=on -DCMAKE_CXX_COMPILER=c++ -DCMAKE_C_COMPILER=cc -DCMAKE_CXX_STANDARD=20
8077
env:
8178
BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}
8279

8380
- name: Build
8481
run: cmake --build ${{github.workspace}}/build/clang_${{env.BUILD_TYPE}} --config ${{env.BUILD_TYPE}}
8582

83+
- name: Test
84+
working-directory: ${{github.workspace}}/build/clang_${{env.BUILD_TYPE}}
85+
run: ./tests/nui-tests
86+
8687
windows-msys2:
8788
runs-on: windows-2022
8889
defaults:
@@ -101,7 +102,11 @@ jobs:
101102
run: echo "WSPACE=$(cygpath '${{github.workspace}}')" >> $GITHUB_ENV
102103

103104
- name: Configure CMake
104-
run: cmake -B ${{env.WSPACE}}/build/clang_${{env.BUILD_TYPE}} -G"Ninja" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DNUI_BUILD_EXAMPLES=off -DCMAKE_CXX_EXTENSIONS=on -DCMAKE_CXX_FLAGS="-fuse-ld=lld" -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_LINKER=lld -DCMAKE_CXX_STANDARD=20
105+
run: cmake -B ${{env.WSPACE}}/build/clang_${{env.BUILD_TYPE}} -G"Ninja" -DNUI_ENABLE_TESTS=on -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DNUI_BUILD_EXAMPLES=off -DCMAKE_CXX_EXTENSIONS=on -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_LINKER=lld -DCMAKE_CXX_STANDARD=20
105106

106107
- name: Build
107108
run: cmake --build ${{env.WSPACE}}/build/clang_${{env.BUILD_TYPE}} --config ${{env.BUILD_TYPE}}
109+
110+
- name: Test
111+
working-directory: ${{github.workspace}}/build/clang_${{env.BUILD_TYPE}}
112+
run: ./tests/nui-tests.exe

CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/cmake/dependencies/describe.cmake)
1515
include(${CMAKE_CURRENT_LIST_DIR}/cmake/dependencies/mp11.cmake)
1616
if (EMSCRIPTEN)
1717
include(${CMAKE_CURRENT_LIST_DIR}/cmake/dependencies/libcpppre.cmake)
18-
include(${CMAKE_CURRENT_LIST_DIR}/cmake/frontend/common.cmake)
19-
include(${CMAKE_CURRENT_LIST_DIR}/cmake/frontend/options.cmake)
2018
include(${CMAKE_CURRENT_LIST_DIR}/cmake/frontend/emscripten.cmake)
2119
else()
2220
if (${NUI_ENABLE_TESTS})
@@ -33,7 +31,6 @@ else()
3331
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/tools/parcel_adapter)
3432
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/tools/patch_emscripten_config)
3533
include(${CMAKE_CURRENT_LIST_DIR}/cmake/backend/common.cmake)
36-
include(${CMAKE_CURRENT_LIST_DIR}/cmake/backend/options.cmake)
3734
include(${CMAKE_CURRENT_LIST_DIR}/cmake/backend/emscripten.cmake)
3835
endif()
3936

@@ -43,6 +40,7 @@ endif()
4340
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/nui/src/nui)
4441

4542
if (${NUI_ENABLE_TESTS})
43+
enable_testing()
4644
include(${CMAKE_CURRENT_LIST_DIR}/cmake/dependencies/gtest.cmake)
4745
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/nui/test/nui)
4846
endif()

cmake/backend/emscripten.cmake

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
project(emscripten-git NONE)
2-
31
if(UNIX)
42
add_custom_command(
53
OUTPUT "${CMAKE_BINARY_DIR}/_deps/emscripten-src/upstream/emscripten/.emscripten"
@@ -78,8 +76,8 @@ function(nui_add_emscripten_target)
7876
SOURCE_DIR "${SOURCE_DIR}"
7977
# emscripten cmake with passed down Release/Debug build type
8078
CONFIGURE_COMMAND
81-
${EMCMAKE} cmake
82-
${NUI_ADD_EMSCRIPTEN_TARGET_ARGS_CMAKE_OPTIONS}
79+
${EMCMAKE} cmake
80+
${NUI_ADD_EMSCRIPTEN_TARGET_ARGS_CMAKE_OPTIONS}
8381
"${SOURCE_DIR}"
8482
# copy over package.json and fill parcel options that do not exist on it
8583
BUILD_COMMAND $<TARGET_FILE:parcel-adapter> "${SOURCE_DIR}/package.json" "${CMAKE_BINARY_DIR}/module_${NUI_ADD_EMSCRIPTEN_TARGET_ARGS_TARGET}/package.json" "${NUI_ADD_EMSCRIPTEN_TARGET_ARGS_TARGET}"

cmake/backend/options.cmake

Lines changed: 0 additions & 1 deletion
This file was deleted.

cmake/frontend/options.cmake

Whitespace-only changes.

examples/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory(basic)

examples/basic/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
build
2+
_build
3+
.vscode
4+
.vs
5+
.idea
6+
out
7+
CMakeSettings.json
8+
node_modules

examples/basic/.parcelrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "@parcel/config-default",
3+
"reporters": [
4+
"...",
5+
"parcel-reporter-static-files-copy"
6+
]
7+
}

examples/basic/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
cmake_minimum_required(VERSION 3.21)
2+
3+
project(nui-template VERSION 0.1.0)
4+
5+
include (${CMAKE_CURRENT_LIST_DIR}/_cmake/common_options.cmake)
6+
7+
# Add executable (sources are added later, depending on frontend/backend)
8+
add_executable(basic-example)
9+
set_common_options(basic-example)
10+
11+
set(PREJS_FILE ${CMAKE_CURRENT_LIST_DIR}/frontend/source/frontend/js/module.js)
12+
13+
if (EMSCRIPTEN)
14+
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/frontend/source/frontend)
15+
else()
16+
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/backend/source/backend)
17+
endif()

examples/basic/LICENSE

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Boost Software License - Version 1.0 - August 17th, 2003
2+
3+
Permission is hereby granted, free of charge, to any person or organization
4+
obtaining a copy of the software and accompanying documentation covered by
5+
this license (the "Software") to use, reproduce, display, distribute,
6+
execute, and transmit the Software, and to prepare derivative works of the
7+
Software, and to permit third-parties to whom the Software is furnished to
8+
do so, all subject to the following:
9+
10+
The copyright notices in the Software and this entire statement, including
11+
the above license grant, this restriction and the following disclaimer,
12+
must be included in all copies of the Software, in whole or in part, and
13+
all derivative works of the Software, unless such copies or derivative
14+
works are solely in the form of machine-executable object code generated by
15+
a source language processor.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
20+
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
21+
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
22+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23+
DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)