Skip to content

Commit

Permalink
Linux tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gershnik committed Aug 8, 2024
1 parent 167731d commit 63e7471
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
permissions: write-all
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Get release Name
shell: python
Expand Down
43 changes: 41 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,51 @@ jobs:

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

- name: Build tests
shell: bash
run: xcodebuild build -project test/test.xcodeproj -scheme test -config Release -derivedDataPath DerivedData

- name: Run tests
shell: bash
run: DerivedData/Build/Products/Release/test
run: DerivedData/Build/Products/Release/test

linux:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Prepare
shell: bash
run: |
echo "::group::Update System"
sudo apt-get install -y ninja-build
echo "::endgroup::"
echo "::group::Clang"
wget https://apt.llvm.org/llvm.sh
chmod u+x llvm.sh
sudo ./llvm.sh 16
echo "::endgroup::"
echo "::group::libdispatch"
git clone --depth=1 https://github.com/apple/swift-corelibs-libdispatch.git
cd swift-corelibs-libdispatch
cmake -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -S . -B build
cmake --build build
sudo cmake --install build --prefix=/usr
echo "::endgroup::"
- name: Build tests
shell: bash
run: |
cd test
CLANG=clang++-16 make
- name: Run tests
shell: bash
run: test/build/test
1 change: 1 addition & 0 deletions test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
28 changes: 28 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

CLANG ?= clang++
SOURCES:=BlockUtilTestCpp.cpp CoDispatchTestsCpp.cpp main-linux.cpp
CPPFLAGS:=--std=c++20 -fblocks -I../include
LDFLAGS:=--std=c++20 -fblocks -ldispatch -lBlocksRuntime

.DEFAULT_GOAL:=build/test

build:
mkdir $@

build/main-linux.o: main-linux.cpp ../include/objc-helpers/BlockUtil.h build
$(CLANG) $(CPPFLAGS) -c -o $@ $<

build/BlockUtilTestCpp.o: BlockUtilTestCpp.cpp ../include/objc-helpers/BlockUtil.h build
$(CLANG) $(CPPFLAGS) -c -o $@ $<

build/CoDispatchTestsCpp.o: CoDispatchTestsCpp.cpp ../include/objc-helpers/CoDispatch.h build
$(CLANG) $(CPPFLAGS) -c -o $@ $<

build/CoDispatchTestsNoexcept.o: CoDispatchTestsNoexcept.cpp ../include/objc-helpers/CoDispatch.h build
$(CLANG) $(CPPFLAGS) -c -o $@ $<

build/test: build/main-linux.o \
build/BlockUtilTestCpp.o \
build/CoDispatchTestsCpp.o \
build/CoDispatchTestsNoexcept.o
$(CLANG) $(LDFLAGS) -o $@ $^
13 changes: 13 additions & 0 deletions test/main-linux.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

#define DOCTEST_CONFIG_IMPLEMENT
#include "doctest.h"

#include <dispatch/dispatch.h>

int main(int argc, const char * argv[]) {
dispatch_async(dispatch_get_main_queue(), ^ {
auto ret = doctest::Context(argc, argv).run();
exit(ret);
});
dispatch_main();
}

0 comments on commit 63e7471

Please sign in to comment.