diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2023-08-27 12:49:14 +0200 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2023-08-27 17:59:52 +0200 |
commit | e19acf196c518fd7f8fe39a7f64f3febb35b6dfb (patch) | |
tree | 99164db2ccd0648fb747f52f5b3b351b538b90e7 | |
parent | again, reorganize test targets (diff) | |
download | cimple-e19acf196c518fd7f8fe39a7f64f3febb35b6dfb.tar.gz cimple-e19acf196c518fd7f8fe39a7f64f3febb35b6dfb.zip |
test: add a target to generate an HTML report
Diffstat (limited to '')
-rw-r--r-- | .github/workflows/ci.yml | 23 | ||||
-rw-r--r-- | Makefile | 10 | ||||
-rw-r--r-- | test/CMakeLists.txt | 11 | ||||
-rw-r--r-- | test/py/requirements.txt | 1 |
4 files changed, 42 insertions, 3 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 380ef74..6ba582e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,10 +32,17 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + cache: pip + cache-dependency-path: ./test/py/requirements.txt - name: Install dependencies run: | sudo apt-get update sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends $DEPS valgrind + pip install -q -r ./test/py/requirements.txt - name: Build run: make install - name: Upload binaries @@ -45,7 +52,14 @@ jobs: path: './build/install/' if-no-files-found: error - name: Run tests - run: make test + run: make test/report + - name: Upload test report + uses: actions/upload-artifact@v3 + with: + name: 'test-report-${{ matrix.compiler }}-${{ matrix.configuration }}' + path: './build/test_report/' + if-no-files-found: error + if: always() - name: Run Valgrind tests run: make test/valgrind @@ -72,7 +86,7 @@ jobs: make coverage mkdir -p /tmp/out/ cp -r ./build/coverage/ /tmp/out/ - - name: Upload report + - name: Upload coverage report uses: actions/upload-artifact@v3 with: name: coverage @@ -96,6 +110,11 @@ jobs: name: flame_graphs path: ./build/flame_graphs/ if-no-files-found: error + - name: Download test report + uses: actions/download-artifact@v3 + with: + name: test-report-gcc-Release + path: /tmp/out/test_report/ - name: Publish to GitHub Pages uses: JamesIves/github-pages-deploy-action@v4 with: @@ -4,6 +4,7 @@ src_dir := $(abspath .) build_dir := $(src_dir)/build cmake_dir := $(build_dir)/cmake install_dir := $(build_dir)/install +test_report_dir := $(build_dir)/test_report coverage_dir := $(build_dir)/coverage flame_graphs_dir := $(build_dir)/flame_graphs @@ -41,6 +42,7 @@ build: -D 'CMAKE_INSTALL_PREFIX=$(call escape,$(INSTALL_PREFIX))' \ -D 'DEFAULT_HOST=$(call escape,$(DEFAULT_HOST))' \ -D 'DEFAULT_PORT=$(call escape,$(DEFAULT_PORT))' \ + -D 'TEST_REPORT_DIR=$(call escape,$(test_report_dir))' \ -D 'COVERAGE=$(call escape,$(COVERAGE))' \ -D 'FLAME_GRAPHS_DIR=$(call escape,$(flame_graphs_dir))' \ -S '$(call escape,$(src_dir))' \ @@ -63,6 +65,14 @@ test: ctest --test-dir '$(call escape,$(cmake_dir))' \ --verbose --tests-regex python_tests_default +.PHONY: test/report +test/report: + @echo ----------------------------------------------------------------- + @echo Running HTML test report + @echo ----------------------------------------------------------------- + ctest --test-dir '$(call escape,$(cmake_dir))' \ + --verbose --tests-regex python_tests_report + # A subset of tests, excluding long-running stress tests. .PHONY: test/sanity test/sanity: diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fa34457..df8db29 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,7 +4,7 @@ find_package(Python3 REQUIRED COMPONENTS Interpreter) set(python_test_args --no-header -v - --durations=0 --durations-min=1.0 + --durations 0 --durations-min 1.0 "${CMAKE_CURRENT_SOURCE_DIR}/py" --server "$<TARGET_FILE:server>" --worker "$<TARGET_FILE:worker>" @@ -23,6 +23,15 @@ endfunction() add_python_tests(python_tests_default Python3::Interpreter -m pytest ${python_test_args} -m "not flame_graph") +# Use pytest-html to generate an HTML report. +if(NOT DEFINED TEST_REPORT_DIR) + set(TEST_REPORT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") +endif() + +add_python_tests(python_tests_report + Python3::Interpreter -m pytest ${python_test_args} -m "not flame_graph" + --html "${TEST_REPORT_DIR}/index.html") + # A subset of tests, excluding long-running stress tests. add_python_tests(python_tests_sanity Python3::Interpreter -m pytest ${python_test_args} -m "not flame_graph and not stress") diff --git a/test/py/requirements.txt b/test/py/requirements.txt new file mode 100644 index 0000000..43300f8 --- /dev/null +++ b/test/py/requirements.txt @@ -0,0 +1 @@ +pytest-html ~= 3.0 |