diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0bf8312..627e856 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6f4dc2b..3ebdb38 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,7 +24,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Build tests shell: bash @@ -32,4 +32,43 @@ jobs: - name: Run tests shell: bash - run: DerivedData/Build/Products/Release/test \ No newline at end of file + 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 diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 0000000..d163863 --- /dev/null +++ b/test/.gitignore @@ -0,0 +1 @@ +build/ \ No newline at end of file diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..c767cff --- /dev/null +++ b/test/Makefile @@ -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 $@ $^ diff --git a/test/main-linux.cpp b/test/main-linux.cpp new file mode 100644 index 0000000..a6fe4e3 --- /dev/null +++ b/test/main-linux.cpp @@ -0,0 +1,13 @@ + +#define DOCTEST_CONFIG_IMPLEMENT +#include "doctest.h" + +#include + +int main(int argc, const char * argv[]) { + dispatch_async(dispatch_get_main_queue(), ^ { + auto ret = doctest::Context(argc, argv).run(); + exit(ret); + }); + dispatch_main(); +}