Skip to content

Commit

Permalink
Merge pull request #9 from stephenberry/openalgz_ut
Browse files Browse the repository at this point in the history
Using openalgz ut and more actions
  • Loading branch information
stephenberry authored May 30, 2024
2 parents aca1fd7 + e2eafbc commit 4b5401e
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 62 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/clang-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: clang-linux

on:
push:
branches:
- main
- feature/*
paths-ignore:
- '**.md'
pull_request:
branches: [main]
paths-ignore:
- '**.md'
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-24.04

strategy:
fail-fast: false
matrix:
clang: [16, 17, 18]
build_type: [Debug]
std: [20, 23]

env:
CC: clang-${{matrix.clang}}
CXX: clang++-${{matrix.clang}}

steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libc++-dev libc++abi-dev
- name: Configure CMake
run: |
cmake -B ${{github.workspace}}/build \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
-DCMAKE_C_COMPILER=${{env.CC}} \
-DCMAKE_CXX_COMPILER=${{env.CXX}} \
-DCMAKE_CXX_FLAGS="-stdlib=libc++" \
-DCMAKE_EXE_LINKER_FLAGS="-stdlib=libc++ -lc++abi"
- name: Build
run: cmake --build build -j $(nproc)

- name: Test
working-directory: build
run: ctest -j $(nproc) --output-on-failure
11 changes: 6 additions & 5 deletions .github/workflows/clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,24 @@ on:
branches: [main]
paths-ignore:
- '**.md'
workflow_dispatch:

env:
BUILD_TYPE: Release
BUILD_TYPE: Debug

jobs:
build:
runs-on: macos-12
runs-on: macos-13

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build
run: cmake --build build --config ${{env.BUILD_TYPE}} -j 2
run: cmake --build build --config ${{env.BUILD_TYPE}} -j 3

- name: Test
working-directory: build
run: ctest -C ${{env.BUILD_TYPE}} -j 2 --output-on-failure
run: ctest -C ${{env.BUILD_TYPE}} -j 3 --output-on-failure
25 changes: 15 additions & 10 deletions .github/workflows/gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,32 @@ on:
branches: [main]
paths-ignore:
- '**.md'

env:
BUILD_TYPE: Release
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

strategy:
fail-fast: false
matrix:
gcc: [12, 13, 14]
build_type: [Debug]
std: [20, 23]

env:
CC: gcc-11
CXX: g++-11
CC: gcc-${{matrix.gcc}}
CXX: g++-${{matrix.gcc}}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_CXX_STANDARD=${{matrix.std}}

- name: Build
run: cmake --build build -j 2
run: cmake --build build -j $(nproc)

- name: Test
working-directory: build
run: ctest -j 2 --output-on-failure
run: ctest -j $(nproc) --output-on-failure
40 changes: 40 additions & 0 deletions .github/workflows/msvc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: msvc

on:
push:
branches:
- main
- 'feature/*'
paths-ignore:
- '**.md'
pull_request:
branches: [main]
paths-ignore:
- '**.md'
workflow_dispatch:

env:
CTEST_OUTPUT_ON_FAILURE: 1
BUILD_TYPE: Debug

jobs:
build:
runs-on: windows-latest
timeout-minutes: 10

strategy:
matrix:
cpp_version: [20, 23]

steps:
- uses: actions/checkout@v4

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_STANDARD=${{matrix.cpp_version}}

- name: Build
run: cmake --build build --config ${{env.BUILD_TYPE}} --parallel

- name: Test
working-directory: build
run: ctest --build-config ${{env.BUILD_TYPE}}
33 changes: 0 additions & 33 deletions .github/workflows/msvc_2022.yml

This file was deleted.

6 changes: 3 additions & 3 deletions cmake/dev-mode.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ include(FetchContent)

FetchContent_Declare(
ut
GIT_REPOSITORY https://github.com/boost-ext/ut.git
GIT_TAG master
GIT_REPOSITORY https://github.com/openalgz/ut
GIT_TAG v0.0.3
GIT_SHALLOW TRUE
)

Expand All @@ -24,6 +24,6 @@ source_group(TREE "${PROJECT_SOURCE_DIR}/src" PREFIX sources FILES ${sources})

add_executable(argz_test ${sources} ${headers})

target_link_libraries(argz_test PRIVATE argz::argz ut)
target_link_libraries(argz_test PRIVATE argz::argz ut::ut)

add_test(NAME argz_test COMMAND argz_test)
21 changes: 10 additions & 11 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,10 @@ inline std::vector<std::string> string_to_vector(const std::string& str)
return ret;
}

#define BOOST_UT_DISABLE_MODULE
#include "boost/ut.hpp"
#define UT_RUNTIME_ONLY
#include "ut/ut.hpp"

using namespace boost::ut;
using namespace boost::ut::literals;
using namespace ut;

int main(int argc, char* argv[])
{
Expand Down Expand Up @@ -178,12 +177,12 @@ int main(int argc, char* argv[])
};

test("test5") = [&] {
expect(nothrow([&] {parse_string(R"(program.exe -h)"); }));
expect(not throws([&] {parse_string(R"(program.exe -h)"); }));
};

test("test6") = [&] {
boolean = false; // Reset not to be right on default
expect(nothrow([&] {parse_string(R"(program.exe -i some/path --study s --boolean -- )"); }));
expect(not throws([&] {parse_string(R"(program.exe -i some/path --study s --boolean -- )"); }));
expect(input == "some/path");
expect(study == "s");
expect(boolean == true);
Expand All @@ -196,7 +195,7 @@ int main(int argc, char* argv[])
};

test("test8") = [&] {
expect(nothrow([&] {parse_string(R"(program.exe - )"); }));
expect(not throws([&] {parse_string(R"(program.exe - )"); }));
};

test("test-dashes") = [&] {
Expand All @@ -213,7 +212,7 @@ int main(int argc, char* argv[])
parse_string(R"(program.exe)");
about.print_help_when_no_options = false;

expect(nothrow([&] {argz::parse(about, opts, buffers.size(), buffers.data()); }));
expect(not throws([&] {argz::parse(about, opts, buffers.size(), buffers.data()); }));
};

test("opt_test0") = [&] {
Expand Down Expand Up @@ -277,7 +276,7 @@ int main(int argc, char* argv[])
};

test("opt_test5") = [&] {
expect(nothrow([&] {parse_string(R"(program.exe -h)"); }));
expect(not throws([&] {parse_string(R"(program.exe -h)"); }));
};

test("opt_test6") = [&] {
Expand All @@ -286,7 +285,7 @@ int main(int argc, char* argv[])
study_opt = {};
number_opt = {};

expect(nothrow([&] {parse_string(R"(program.exe --input_opt some/path --study_opt s --boolean -- )"); }));
expect(not throws([&] {parse_string(R"(program.exe --input_opt some/path --study_opt s --boolean -- )"); }));

expect(input_opt.value() == "some/path");
expect(study_opt.value() == "s");
Expand All @@ -305,7 +304,7 @@ int main(int argc, char* argv[])
study_opt = {};
number_opt = {};

expect(nothrow([&] {parse_string(R"(program.exe - )"); }));
expect(not throws([&] {parse_string(R"(program.exe - )"); }));

expect(!input_opt.has_value());
expect(!study_opt.has_value());
Expand Down

0 comments on commit 4b5401e

Please sign in to comment.