Skip to content

Commit

Permalink
added mac suppot and trying to integrate integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Владимир Чиж authored and Владимир Чиж committed Feb 29, 2024
1 parent 17217c7 commit e2c5515
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 24 deletions.
45 changes: 35 additions & 10 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: CMake on multiple platforms

on:
push:
branches: [ "master" ]
branches: [ "master", "clang_support"]
pull_request:
branches: [ "master" ]

Expand All @@ -26,7 +26,7 @@ jobs:
#
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest, windows-latest, macos-14]
build_type: [Release, Debug]
c_compiler: [gcc, cl, clang-15]
include:
Expand All @@ -36,7 +36,7 @@ jobs:
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-latest
- os: macos-14
c_compiler: clang-15
cpp_compiler: clang++-15
exclude:
Expand All @@ -46,17 +46,16 @@ jobs:
c_compiler: clang-15
- os: ubuntu-latest
c_compiler: cl
- os: ubuntu-latest
c_compiler: clang-15
- os: macos-14
c_compiler: cl
- os: macos-14
c_compiler: gcc

steps:
- uses: actions/checkout@v4

- name: Install clang
if: matrix.os=='ubuntu-latest' && matrix.c_compiler=='clang-15'
run: |
sudo apt -y install clang-15
sudo apt -y install libc++-15-dev libc++abi-15-dev

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
Expand Down Expand Up @@ -85,6 +84,13 @@ jobs:
working-directory: ${{ steps.strings.outputs.build-output-dir }}/testbpatch/
run: ./testbpatch

- name: Unit Tests on Mac
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
if: matrix.os=='macos-14'
working-directory: ${{ steps.strings.outputs.build-output-dir }}/testbpatch/
run: ./testbpatch

- name: Unit Tests on Windows
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
Expand All @@ -93,3 +99,22 @@ jobs:
shell: cmd
run: .\testbpatch.exe

- name: Integration Tests on Ubuntu
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
if: matrix.os=='ubuntu-latest'
run: ./IntegrationTests/in_tests.sh ${{ steps.strings.outputs.build-output-dir }}/bpatch

- name: Integration Tests on Mac
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
if: matrix.os=='macos-14'
run: ./IntegrationTests/in_tests.sh ${{ steps.strings.outputs.build-output-dir }}/bpatch

- name: Integration Tests on Windows
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
if: matrix.os=='windows-latest'
shell: cmd
run: ./IntegrationTests/in_tests.sh ${{ steps.strings.outputs.build-output-dir }}/testbpatch/${{ matrix.build_type }}/bpatch.exe

9 changes: 5 additions & 4 deletions rebuild.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ divisor() {

# Establish the mode, defaulting to Release if no argument is given
MODE=Release
SYSTEM=$(uname)
if [ "$1" != "" ]; then
MODE=$1
fi
Expand Down Expand Up @@ -44,14 +45,14 @@ PROJECTDIR=${SCRIPT_PATH}

# rebuilding initiation
cd $PROJECTDIR
rm -rf "buildLinux$MODE"
mkdir "buildLinux$MODE" && cd "buildLinux$MODE"
rm -rf "build$SYSTEM$MODE"
mkdir "build$SYSTEM$MODE" && cd "build$SYSTEM$MODE"
cmake -DCMAKE_BUILD_TYPE=$MODE ..
cmake --build . --config $MODE

divisor

FILENAME="$PROJECTDIR/buildLinux$MODE/bpatch"
FILENAME="$PROJECTDIR/build$SYSTEM$MODE/bpatch"

if [ -e "$FILENAME" ]; then
echo "bpatch built for $MODE mode is here:"
Expand All @@ -61,7 +62,7 @@ else
echo "$FILENAME"
fi

FILENAME="$PROJECTDIR/buildLinux$MODE/testbpatch/testbpatch"
FILENAME="$PROJECTDIR/build$SYSTEM$MODE/testbpatch/testbpatch"

if [ -e "$FILENAME" ]; then
echo "Unit tests for bpatch are here:"
Expand Down
4 changes: 2 additions & 2 deletions srcbpatch/fileprocessing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ using namespace std::filesystem;
FileProcessing::FileProcessing(const char* fname, const char* mode)
{
#if !defined(__linux__) && !(defined(__APPLE__) && defined(__MACH__))
#pragma warning(disable: 4996) // I would like to use fopen instead of fopen_s, because
#pragma warning(disable: 4996) // I would like to use fopen instead of fopen_s, because
// 1. I would like to write fast code
// 2. MSVS compiler does not respect C++ standard and __STDC_LIB_EXT1__ define
#endif
if (stream_ = fopen(fname, mode); nullptr == stream_)
#if !defined(__linux__) && !(defined(__APPLE__) && defined(__MACH__))
#pragma warning(default: 4996)
#pragma warning(default: 4996)
#endif
{
throw filesystem_error(fio_errors[0], filesystem::path(fname), error_code());
Expand Down
4 changes: 2 additions & 2 deletions testbpatch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ project(test${pname})
include(FetchContent)
FetchContent_Declare(
googletest
# Specify the commit you depend on and update it regularly.
URL https://github.com/google/googletest/archive/5376968f6948923e2411081fd9372e71a59d8e77.zip
GIT_REPOSITORY https://github.com/google/googletest
GIT_TAG release-1.12.1
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
Expand Down
12 changes: 6 additions & 6 deletions testbpatch/test.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "pch.h"
#include <gtest/gtest.h>

#ifdef __linux__
#if defined(__linux__) || ((defined(__APPLE__) && defined(__MACH__)))
#include <unistd.h>
#else
#include <tchar.h>
Expand Down Expand Up @@ -29,7 +29,7 @@ TEST(WildCharacters, ProcessingValidTrue)
}
okMask[] =
{
#ifdef __linux__
#if defined(__linux__) || (defined(__APPLE__) && defined(__MACH__))
{R"(/Users/Bobby/kon?e?.txt)", R"(./kon?e?.txt)"}
, {R"(../Bobby/kon*e*.*)", R"(../kon*e*.*)"}
, {R"(kon*e*.*)", R"(./kon*e*.*)"}
Expand Down Expand Up @@ -77,7 +77,7 @@ TEST(WildCharacters, ProcessingValidFalse)
}
okMask[] =
{
#ifdef __linux__
#if defined(__linux__) || (defined(__APPLE__) && defined(__MACH__))
{R"(/Users/Bobby/kon?e?.txt)", R"(/Users/Bobby/kon?e?.txt)"}
, {R"(./../*.???)", R"(./../*.???)"}
, {R"(*.*)", R"(*.*)"}
Expand Down Expand Up @@ -111,7 +111,7 @@ TEST(WildCharacters, ProcessingInvalid)
}
badMask[] =
{
#ifdef __linux__
#if defined(__linux__) || (defined(__APPLE__) && defined(__MACH__))
{R"(/Users/Bo?by/kon?e?.txt)", emptySV}
, {R"(../Bo*by/kon*e*.*)", emptySV}
, {R"(*/kon*e*.*)", emptySV}
Expand Down Expand Up @@ -158,7 +158,7 @@ TEST(WildCharacters, ProcessingInvalid)
TEST(WildCharacters, SearchingTests)
{
// get full path for executable
#ifdef __linux__
#if defined(__linux__) || (defined(__APPLE__) && defined(__MACH__))
char pathBuffer[PATH_MAX] = {0};
[[maybe_unused]] auto result = readlink(R"(/proc/self/exe)", pathBuffer, PATH_MAX);
#else
Expand All @@ -172,7 +172,7 @@ TEST(WildCharacters, SearchingTests)
filesystem::path pathTestFolder(pathBuffer);
pathTestFolder = pathTestFolder.parent_path();

#ifdef __linux__
#if defined(__linux__) || (defined(__APPLE__) && defined(__MACH__))
#else
pathTestFolder /= ".."; // creation of Debug or Release subfolder is Window's 'EVERYTHING'
#endif
Expand Down

0 comments on commit e2c5515

Please sign in to comment.