Skip to content

Commit 63e7471

Browse files
committed
Linux tests
1 parent 167731d commit 63e7471

File tree

5 files changed

+84
-3
lines changed

5 files changed

+84
-3
lines changed

.github/workflows/publish.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
permissions: write-all
1313
steps:
1414
- name: Checkout
15-
uses: actions/checkout@v3
15+
uses: actions/checkout@v4
1616

1717
- name: Get release Name
1818
shell: python

.github/workflows/test.yml

+41-2
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,51 @@ jobs:
2424

2525
steps:
2626
- name: Checkout
27-
uses: actions/checkout@v3
27+
uses: actions/checkout@v4
2828

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

3333
- name: Run tests
3434
shell: bash
35-
run: DerivedData/Build/Products/Release/test
35+
run: DerivedData/Build/Products/Release/test
36+
37+
linux:
38+
runs-on: ubuntu-latest
39+
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v4
43+
44+
- name: Prepare
45+
shell: bash
46+
run: |
47+
echo "::group::Update System"
48+
sudo apt-get install -y ninja-build
49+
echo "::endgroup::"
50+
51+
echo "::group::Clang"
52+
wget https://apt.llvm.org/llvm.sh
53+
chmod u+x llvm.sh
54+
sudo ./llvm.sh 16
55+
echo "::endgroup::"
56+
57+
echo "::group::libdispatch"
58+
git clone --depth=1 https://github.com/apple/swift-corelibs-libdispatch.git
59+
cd swift-corelibs-libdispatch
60+
cmake -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -S . -B build
61+
cmake --build build
62+
sudo cmake --install build --prefix=/usr
63+
echo "::endgroup::"
64+
65+
66+
- name: Build tests
67+
shell: bash
68+
run: |
69+
cd test
70+
CLANG=clang++-16 make
71+
72+
- name: Run tests
73+
shell: bash
74+
run: test/build/test

test/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/

test/Makefile

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
CLANG ?= clang++
3+
SOURCES:=BlockUtilTestCpp.cpp CoDispatchTestsCpp.cpp main-linux.cpp
4+
CPPFLAGS:=--std=c++20 -fblocks -I../include
5+
LDFLAGS:=--std=c++20 -fblocks -ldispatch -lBlocksRuntime
6+
7+
.DEFAULT_GOAL:=build/test
8+
9+
build:
10+
mkdir $@
11+
12+
build/main-linux.o: main-linux.cpp ../include/objc-helpers/BlockUtil.h build
13+
$(CLANG) $(CPPFLAGS) -c -o $@ $<
14+
15+
build/BlockUtilTestCpp.o: BlockUtilTestCpp.cpp ../include/objc-helpers/BlockUtil.h build
16+
$(CLANG) $(CPPFLAGS) -c -o $@ $<
17+
18+
build/CoDispatchTestsCpp.o: CoDispatchTestsCpp.cpp ../include/objc-helpers/CoDispatch.h build
19+
$(CLANG) $(CPPFLAGS) -c -o $@ $<
20+
21+
build/CoDispatchTestsNoexcept.o: CoDispatchTestsNoexcept.cpp ../include/objc-helpers/CoDispatch.h build
22+
$(CLANG) $(CPPFLAGS) -c -o $@ $<
23+
24+
build/test: build/main-linux.o \
25+
build/BlockUtilTestCpp.o \
26+
build/CoDispatchTestsCpp.o \
27+
build/CoDispatchTestsNoexcept.o
28+
$(CLANG) $(LDFLAGS) -o $@ $^

test/main-linux.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
#define DOCTEST_CONFIG_IMPLEMENT
3+
#include "doctest.h"
4+
5+
#include <dispatch/dispatch.h>
6+
7+
int main(int argc, const char * argv[]) {
8+
dispatch_async(dispatch_get_main_queue(), ^ {
9+
auto ret = doctest::Context(argc, argv).run();
10+
exit(ret);
11+
});
12+
dispatch_main();
13+
}

0 commit comments

Comments
 (0)