Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ name: build

on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:

permissions:
Expand All @@ -22,12 +26,26 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Cache test assets
uses: actions/cache@v4
with:
path: build/teaklite2_tests_result.bin
enableCrossOsArchive: true
key: 'baffcd4f805a7480d969401792443a34aa39f813b4f0ae49c6365f1d1f3ce120'

- name: Download test assets
if: "!hashFiles('build/teaklite2_tests_result.bin')"
run: |
git lfs pull --exclude='' --include='*'
mkdir -p build
mv src/test_verifier/data/teaklite2_tests_result.bin build/teaklite2_tests_result.bin

- name: Configure
run: cmake -B build
run: cmake -B build -DCMAKE_BUILD_TYPE=Debug -DTEAKRA_RUN_TESTS=ON -DTEAKRA_TEST_ASSETS_DIR="$PWD/build"

- name: Build
run: cmake --build build --parallel
run: cmake --build build --config Debug --parallel

- name: Test
working-directory: build
run: ctest --verbose
run: ctest --build-config Debug --verbose
2 changes: 2 additions & 0 deletions .lfsconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[lfs]
fetchexclude = *
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

if (NOT TEAKRA_TEST_ASSETS_DIR)
set(TEAKRA_TEST_ASSETS_DIR "${CMAKE_CURRENT_BINARY_DIR}")
set(TEAKRA_TEST_ASSETS_DIR "${PROJECT_SOURCE_DIR}/src/test_verifier/data")
endif()

# External libraries
Expand Down
23 changes: 6 additions & 17 deletions src/test_verifier/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,13 @@ target_compile_options(test_verifier PRIVATE ${TEAKRA_CXX_FLAGS})
set(ASSET_SHA256SUM "baffcd4f805a7480d969401792443a34aa39f813b4f0ae49c6365f1d1f3ce120")
if(TEAKRA_RUN_TESTS)
message(STATUS "Will run Teakra accuracy tests")
# download fixtures if there is none
if(NOT EXISTS "${TEAKRA_TEST_ASSETS_DIR}/teaklite2_tests_result")
message(STATUS "Downloading required samples...")
file(DOWNLOAD
"https://liushuyu.b-cdn.net/teaklite2_tests_result_20181208"
"${TEAKRA_TEST_ASSETS_DIR}/teaklite2_tests_result"
EXPECTED_HASH SHA256=${ASSET_SHA256SUM}
SHOW_PROGRESS
)
# check if provided fixtures are good
file(SHA256 "${TEAKRA_TEST_ASSETS_DIR}/teaklite2_tests_result.bin" ASSET_CHECKSUM)
if(ASSET_SHA256SUM STREQUAL ASSET_CHECKSUM)
message(STATUS "Unit test sample looks good.")
else()
# check if provided fixtures are good
file(SHA256 "${TEAKRA_TEST_ASSETS_DIR}/teaklite2_tests_result" ASSET_CHECKSUM)
if(ASSET_SHA256SUM STREQUAL ASSET_CHECKSUM)
message(STATUS "Unit test sample looks good.")
else()
message(FATAL_ERROR "Unit test sample broken. Please remove the file and re-run CMake.")
endif()
message(FATAL_ERROR "Unit test sample broken. Please download the file using: git lfs pull --exclude='' --include='*'")
endif()

add_test(NAME tests COMMAND test_verifier "${TEAKRA_TEST_ASSETS_DIR}/teaklite2_tests_result")
add_test(NAME tests COMMAND test_verifier "${TEAKRA_TEST_ASSETS_DIR}/teaklite2_tests_result.bin")
endif(TEAKRA_RUN_TESTS)
Loading