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

Using openalgz ut and more actions #9

Merged
merged 1 commit into from
May 30, 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
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