Skip to content

Commit 7c107c2

Browse files
committed
Move CI native tests code to separate scripts
1 parent 8fc2296 commit 7c107c2

File tree

5 files changed

+88
-64
lines changed

5 files changed

+88
-64
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -241,28 +241,9 @@ jobs:
241241
- name: Restore cargo caches
242242
uses: Swatinem/rust-cache@v2
243243
- name: Build example
244-
run: |
245-
cargo build --example native_linux --features native,libsystemd,source-location --verbose
246-
mv ./target/debug/examples/native_linux ./target/debug/examples/native_linux_srcloc
247-
cargo build --example native_linux --features native,libsystemd --verbose
244+
run: bash ./spdlog/tests/native/linux.sh build
248245
- name: Run and test
249-
run: |
250-
set -x
251-
./target/debug/examples/native_linux
252-
./target/debug/examples/native_linux_srcloc
253-
254-
journalctl --no-pager -o verbose -t native_linux
255-
journalctl --no-pager -o verbose -t native_linux_srcloc
256-
257-
journalctl --no-pager -o json -t native_linux | jq -e -s $'.[0].MESSAGE == "[demo] [info] info message from spdlog-rs\'s JournaldSink\n"'
258-
journalctl --no-pager -o json -t native_linux | jq -e -s $'.[0].PRIORITY == "6" and .[0].CODE_FILE == null and .[0].CODE_LINE == null and .[0].TID != null'
259-
journalctl --no-pager -o json -t native_linux | jq -e -s $'.[1].MESSAGE == "[demo] [error] error message from spdlog-rs\'s JournaldSink { error_code=114514 }\n"'
260-
journalctl --no-pager -o json -t native_linux | jq -e -s $'.[1].PRIORITY == "3" and .[1].CODE_FILE == null and .[1].CODE_LINE == null and .[1].TID != null'
261-
262-
journalctl --no-pager -o json -t native_linux_srcloc | jq -e -s $'.[0].MESSAGE == "[demo] [info] info message from spdlog-rs\'s JournaldSink\n"'
263-
journalctl --no-pager -o json -t native_linux_srcloc | jq -e -s $'.[0].PRIORITY == "6" and .[0].CODE_FILE == "linux.rs" and .[0].CODE_LINE != null and .[0].TID != null'
264-
journalctl --no-pager -o json -t native_linux_srcloc | jq -e -s $'.[1].MESSAGE == "[demo] [error] error message from spdlog-rs\'s JournaldSink { error_code=114514 }\n"'
265-
journalctl --no-pager -o json -t native_linux_srcloc | jq -e -s $'.[1].PRIORITY == "3" and .[1].CODE_FILE == "linux.rs" and .[1].CODE_LINE != null and .[1].TID != null'
246+
run: bash ./spdlog/tests/native/linux.sh run
266247

267248
test-native-windows:
268249
strategy:
@@ -278,32 +259,9 @@ jobs:
278259
- name: Restore cargo caches
279260
uses: Swatinem/rust-cache@v2
280261
- name: Build example
281-
run: |
282-
cargo build --example native_windows --features native,source-location --verbose
283-
mv ./target/debug/examples/native_windows ./target/debug/examples/native_windows_srcloc
284-
cargo build --example native_windows --features native --verbose
262+
run: bash ./spdlog/tests/native/windows.sh build
285263
- name: Run and test
286-
run: |
287-
set -x
288-
289-
# Microsoft styled CLI options start with `/` and need to be doubled to escape in bash.
290-
dbgview //l ./dbgview.log
291-
# Wait for dbgview to start up and create the log file
292-
while [ ! -f ./dbgview.log ]; do sleep 1; done
293-
294-
./target/debug/examples/native_windows
295-
./target/debug/examples/native_windows_srcloc
296-
297-
# Wait for dbgview to flush the log file
298-
while [ ! -s ./dbgview.log ]; do sleep 1; done
299-
sleep 3
300-
dbgview //q
301-
302-
cat ./dbgview.log
303-
cat ./dbgview.log | grep "\[demo] \[info] info message from spdlog-rs's WinDebugSink"
304-
cat ./dbgview.log | grep "\[demo] \[error] error message from spdlog-rs's WinDebugSink { error_code=114514 }"
305-
cat ./dbgview.log | grep -E "\[demo] \[info] \[native_windows, .+.rs:[0-9]+] info message from spdlog-rs's WinDebugSink"
306-
cat ./dbgview.log | grep -E "\[demo] \[error] \[native_windows, .+.rs:[0-9]+] error message from spdlog-rs's WinDebugSink { error_code=114514 }"
264+
run: bash ./spdlog/tests/native/windows.sh run
307265

308266
test-native-android:
309267
strategy:
@@ -319,10 +277,7 @@ jobs:
319277
- name: Install cross
320278
run: cargo install cross --git https://github.com/cross-rs/cross --verbose
321279
- name: Build example
322-
run: |
323-
cross build --target x86_64-linux-android --example native_android --features native,android-ndk,source-location --verbose
324-
mv ./target/x86_64-linux-android/debug/examples/native_android ./target/x86_64-linux-android/debug/examples/native_android_srcloc
325-
cross build --target x86_64-linux-android --example native_android --features native,android-ndk --verbose
280+
run: bash ./spdlog/tests/native/android.sh build
326281
- name: Enable KVM
327282
run: |
328283
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
@@ -333,20 +288,7 @@ jobs:
333288
with:
334289
api-level: 29
335290
arch: x86_64
336-
script: |
337-
adb root
338-
adb push ./target/x86_64-linux-android/debug/examples/native_android /data
339-
adb push ./target/x86_64-linux-android/debug/examples/native_android_srcloc /data
340-
341-
adb logcat -b all -c
342-
adb shell /data/native_android
343-
adb shell /data/native_android_srcloc
344-
adb logcat -s "spdlog-rs-example" -d > ./logcat.log
345-
cat ./logcat.log
346-
cat ./logcat.log | grep "I spdlog-rs-example: \[demo] info message from spdlog-rs's AndroidSink"
347-
cat ./logcat.log | grep "E spdlog-rs-example: \[demo] error message from spdlog-rs's AndroidSink { error_code=114514 }"
348-
cat ./logcat.log | grep -E "I spdlog-rs-example: \[demo] \[native_android, .+.rs:[0-9]+] info message from spdlog-rs's AndroidSink"
349-
cat ./logcat.log | grep -E "E spdlog-rs-example: \[demo] \[native_android, .+.rs:[0-9]+] error message from spdlog-rs's AndroidSink { error_code=114514 }"
291+
script: bash ./spdlog/tests/native/android.sh run
350292

351293
bench:
352294
needs: [test, check]

spdlog/tests/native/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# spdlog-rs native tests
2+
3+
This directory contains scripts used in CI to run functional tests natively.

spdlog/tests/native/android.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
build() {
2+
cross build --target x86_64-linux-android --example native_android --features native,android-ndk,source-location --verbose
3+
mv ./target/x86_64-linux-android/debug/examples/native_android ./target/x86_64-linux-android/debug/examples/native_android_srcloc
4+
cross build --target x86_64-linux-android --example native_android --features native,android-ndk --verbose
5+
}
6+
7+
run() {
8+
adb root
9+
adb push ./target/x86_64-linux-android/debug/examples/native_android /data
10+
adb push ./target/x86_64-linux-android/debug/examples/native_android_srcloc /data
11+
12+
adb logcat -b all -c
13+
adb shell /data/native_android
14+
adb shell /data/native_android_srcloc
15+
adb logcat -s "spdlog-rs-example" -d > ./logcat.log
16+
cat ./logcat.log
17+
cat ./logcat.log | grep "I spdlog-rs-example: \[demo] info message from spdlog-rs's AndroidSink"
18+
cat ./logcat.log | grep "E spdlog-rs-example: \[demo] error message from spdlog-rs's AndroidSink { error_code=114514 }"
19+
cat ./logcat.log | grep -E "I spdlog-rs-example: \[demo] \[native_android, .+.rs:[0-9]+] info message from spdlog-rs's AndroidSink"
20+
cat ./logcat.log | grep -E "E spdlog-rs-example: \[demo] \[native_android, .+.rs:[0-9]+] error message from spdlog-rs's AndroidSink { error_code=114514 }"
21+
}
22+
23+
$1

spdlog/tests/native/linux.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
build() {
2+
cargo build --example native_linux --features native,libsystemd,source-location --verbose
3+
mv ./target/debug/examples/native_linux ./target/debug/examples/native_linux_srcloc
4+
cargo build --example native_linux --features native,libsystemd --verbose
5+
}
6+
7+
run() {
8+
set -x
9+
./target/debug/examples/native_linux
10+
./target/debug/examples/native_linux_srcloc
11+
12+
journalctl --no-pager -o verbose -t native_linux
13+
journalctl --no-pager -o verbose -t native_linux_srcloc
14+
15+
journalctl --no-pager -o json -t native_linux | jq -e -s $'.[0].MESSAGE == "[demo] [info] info message from spdlog-rs\'s JournaldSink\n"'
16+
journalctl --no-pager -o json -t native_linux | jq -e -s $'.[0].PRIORITY == "6" and .[0].CODE_FILE == null and .[0].CODE_LINE == null and .[0].TID != null'
17+
journalctl --no-pager -o json -t native_linux | jq -e -s $'.[1].MESSAGE == "[demo] [error] error message from spdlog-rs\'s JournaldSink { error_code=114514 }\n"'
18+
journalctl --no-pager -o json -t native_linux | jq -e -s $'.[1].PRIORITY == "3" and .[1].CODE_FILE == null and .[1].CODE_LINE == null and .[1].TID != null'
19+
20+
journalctl --no-pager -o json -t native_linux_srcloc | jq -e -s $'.[0].MESSAGE == "[demo] [info] info message from spdlog-rs\'s JournaldSink\n"'
21+
journalctl --no-pager -o json -t native_linux_srcloc | jq -e -s $'.[0].PRIORITY == "6" and .[0].CODE_FILE == "linux.rs" and .[0].CODE_LINE != null and .[0].TID != null'
22+
journalctl --no-pager -o json -t native_linux_srcloc | jq -e -s $'.[1].MESSAGE == "[demo] [error] error message from spdlog-rs\'s JournaldSink { error_code=114514 }\n"'
23+
journalctl --no-pager -o json -t native_linux_srcloc | jq -e -s $'.[1].PRIORITY == "3" and .[1].CODE_FILE == "linux.rs" and .[1].CODE_LINE != null and .[1].TID != null'
24+
}
25+
26+
$1

spdlog/tests/native/windows.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
build() {
2+
cargo build --example native_windows --features native,source-location --verbose
3+
mv ./target/debug/examples/native_windows ./target/debug/examples/native_windows_srcloc
4+
cargo build --example native_windows --features native --verbose
5+
}
6+
7+
run() {
8+
set -x
9+
10+
# Microsoft styled CLI options start with `/` and need to be doubled to escape in bash.
11+
dbgview //l ./dbgview.log
12+
# Wait for dbgview to start up and create the log file
13+
while [ ! -f ./dbgview.log ]; do sleep 1; done
14+
15+
./target/debug/examples/native_windows
16+
./target/debug/examples/native_windows_srcloc
17+
18+
# Wait for dbgview to flush the log file
19+
while [ ! -s ./dbgview.log ]; do sleep 1; done
20+
sleep 3
21+
dbgview //q
22+
23+
cat ./dbgview.log
24+
cat ./dbgview.log | grep "\[demo] \[info] info message from spdlog-rs's WinDebugSink"
25+
cat ./dbgview.log | grep "\[demo] \[error] error message from spdlog-rs's WinDebugSink { error_code=114514 }"
26+
cat ./dbgview.log | grep -E "\[demo] \[info] \[native_windows, .+.rs:[0-9]+] info message from spdlog-rs's WinDebugSink"
27+
cat ./dbgview.log | grep -E "\[demo] \[error] \[native_windows, .+.rs:[0-9]+] error message from spdlog-rs's WinDebugSink { error_code=114514 }"
28+
}
29+
30+
$1

0 commit comments

Comments
 (0)