Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integration tests #1

Merged
merged 3 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: IntegrationTests

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

jobs:
core:
runs-on: windows-2022
steps:
- uses: actions/checkout@4

- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.26.1'

- name: Configure
working-directory: ${{github.workspace}}/integration_test
run: |
mkdir _build
cd _build
cmake ..
shell: cmd

- name: Build
working-directory: ${{github.workspace}}/integration_test/_build
run: |
cmake --build . --config Debug
shell: cmd

fetch:
runs-on: windows-2022
steps:
- uses: actions/checkout@4

- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.26.1'

- name: Configure
working-directory: ${{github.workspace}}/fetch_test
run: |
mkdir _build
cd _build
cmake ..
shell: cmd
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
integration_test/_build
fetch_test/_build
2 changes: 1 addition & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cpp-init v0.2 changelog:
* Added enable_autoformatter which autocopies and link .clang-format
* Removed bootstrap_clang_format
* Added enable_linter which autocopies and enables .clang-format
* But don't use it, C++23 is not compatible with that MSVC ships
* But don't use it, C++23 is not compatible with what MSVC ships
* fetch_prebuilt_dependency now uses FetchContent_MakeAvailable which replaces FetchContent_Populate

cpp-init v0.1 changelog:
Expand Down
4 changes: 3 additions & 1 deletion cmake/get_cpp_init.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ function ( fetch_cpp_init )
return( PROPAGATE CPPINIT_FOLDER )
endfunction()

fetch_cpp_init ( SCRIPT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake" )
# set ( CPP_INIT_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake" )

fetch_cpp_init ( SCRIPT_DIR "${CPP_INIT_ROOT_DIR}" )

include ( "${CPPINIT_FOLDER}/cpp.cmake" )
include ( "${CPPINIT_FOLDER}/bootstrap.cmake" )
Expand Down
15 changes: 15 additions & 0 deletions fetch_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required ( VERSION 3.26 )

include ( "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/get_cpp_init.cmake" )

fetch_headeronly_dependency (
JSON
URL "https://github.com/nlohmann/json/releases/download/v3.11.3/json.hpp"
)

fetch_prebuilt_dependency (
DGM
URL "https://github.com/nerudaj/fsm-lib/releases/download/v2.1.0/fsm-lib-v2.1.0-Windows-MSVC-x64.zipXX"
)

project ( demo LANGUAGES CXX )
12 changes: 12 additions & 0 deletions integration_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cmake_minimum_required ( VERSION 3.26 )

include ( "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/get_cpp_init.cmake" )

bootstrap_cpm ()

project ( TEST )

enable_testing()

add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/lib" )
add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/bin" )
12 changes: 12 additions & 0 deletions integration_test/bin/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Checks: >
-*,
misc-const-correctness,
cppcoreguidelines-avoid-non-const-global-variables,
clang-diagnostic-unused-variable,
bugprone-assignment-in-if-condition,
bugprone-optional-value-conversion,
bugprone-use-after-move
WarningsAsErrors: '*'
HeaderFilterRegex: '.*'
AnalyzeTemporaryDtors: false
FormatStyle: none
10 changes: 10 additions & 0 deletions integration_test/bin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required ( VERSION 3.26 )

set ( TARGET mybin )

make_executable ( ${TARGET} DEPS mylib )

add_test (
NAME ${TARGET}
COMMAND ${TARGET}
)
4 changes: 4 additions & 0 deletions integration_test/bin/src/Main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "Lib.hpp"
#include <print>

int main() { std::println("Gimme {}", gimmeFive()); }
12 changes: 12 additions & 0 deletions integration_test/lib/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Checks: >
-*,
misc-const-correctness,
cppcoreguidelines-avoid-non-const-global-variables,
clang-diagnostic-unused-variable,
bugprone-assignment-in-if-condition,
bugprone-optional-value-conversion,
bugprone-use-after-move
WarningsAsErrors: '*'
HeaderFilterRegex: '.*'
AnalyzeTemporaryDtors: false
FormatStyle: none
7 changes: 7 additions & 0 deletions integration_test/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required ( VERSION 3.26 )

CPMAddPackage( "gh:nlohmann/[email protected]" )

set ( TARGET mylib )

make_static_library ( ${TARGET} DEPS nlohmann::json )
3 changes: 3 additions & 0 deletions integration_test/lib/include/Lib.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

int gimmeFive();
13 changes: 13 additions & 0 deletions integration_test/lib/src/Lib.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "Lib.hpp"
#include <nlohmann/json.hpp>

struct S {
int val;
};

NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(S, val);

int gimmeFive() {
S s = nlohmann::json::parse("{val: 5}");
return s.val;
}
Loading