From 974ac028eb2c4bd99ac9dad54e15d604dbb27906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ko=CC=88hler?= Date: Thu, 5 Dec 2024 18:49:35 +0100 Subject: [PATCH 1/4] Poetry: add coverage dep --- poetry.lock | 2 +- pyproject.toml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/poetry.lock b/poetry.lock index 64039295..4bd81499 100644 --- a/poetry.lock +++ b/poetry.lock @@ -770,4 +770,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "5a41028a2c142304569a38871947299dbbc88620051201dd804792da22638fa9" +content-hash = "f7c434545c054dc9a2abdaaf8eb0b8a38b0ece4c7076af496739bc00d1d1fe22" diff --git a/pyproject.toml b/pyproject.toml index 2806276c..c0935551 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,6 +54,7 @@ pytest-cov = "^6.0.0" pytest-html = "^4.1.1" allure-pytest = "^2.13.5" csv-diff = "^1.2" +coverage = "^7.6.8" [tool.poetry.group.dev.dependencies] pylint = "^3.3.1" From 1ea79a795a3358e85567a844f2356188fe83a388 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ko=CC=88hler?= Date: Thu, 5 Dec 2024 18:49:55 +0100 Subject: [PATCH 2/4] pyproject.toml: add pytest options --- pyproject.toml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index c0935551..f51ceabb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,3 +64,11 @@ licenseheaders = "^0.8.8" [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" + +[tool.pytest.ini_options] +markers = [ + "slow: marks tests as slow (deselect with '-m \"not slow\"')", + "serial", + "wip: mark tests as work-in-progress (delect with '-m \"not wip\"')", +] + From 67ddc6295a4e43510619cd9819340f6efc66f853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ko=CC=88hler?= Date: Thu, 5 Dec 2024 18:50:25 +0100 Subject: [PATCH 3/4] rc25_test: add pytest slow marker to test functions --- tests/rcx25/rcx25_test.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/rcx25/rcx25_test.py b/tests/rcx25/rcx25_test.py index aba703b7..bf7a0f52 100644 --- a/tests/rcx25/rcx25_test.py +++ b/tests/rcx25/rcx25_test.py @@ -30,8 +30,8 @@ import allure import csv_diff import os +import pytest from typing import * -import unittest import klayout.db as kdb import klayout.lay as klay @@ -129,6 +129,7 @@ def assert_expected_matches_obtained(*path_components, @allure.parent_suite(parent_suite) @allure.tag(*tags) +@pytest.mark.slow def test_single_plate_100um_x_100um_li1_over_substrate(): # MAGIC GIVES (8.3 revision 485): #_______________________________ NOTE: with halo=8µm __________________________________ @@ -142,6 +143,8 @@ def test_single_plate_100um_x_100um_li1_over_substrate(): @allure.parent_suite(parent_suite) @allure.tag(*tags) +@pytest.mark.slow +@pytest.mark.wip def test_overlap_plates_100um_x_100um_li1_m1(): # MAGIC GIVES (8.3 revision 485): #_______________________________ NOTE: with halo=8µm __________________________________ @@ -164,6 +167,8 @@ def test_overlap_plates_100um_x_100um_li1_m1(): @allure.parent_suite(parent_suite) @allure.tag(*tags) +@pytest.mark.slow +@pytest.mark.wip def test_overlap_plates_100um_x_100um_li1_m1_m2_m3(): # MAGIC GIVES (8.3 revision 485): (sorting changed to match order) #_______________________________ NOTE: with halo=8µm __________________________________ @@ -203,6 +208,8 @@ def test_overlap_plates_100um_x_100um_li1_m1_m2_m3(): @allure.parent_suite(parent_suite) @allure.tag(*tags) +@pytest.mark.slow +@pytest.mark.wip def test_sidewall_100um_x_100um_distance_200nm_li1(): # MAGIC GIVES (8.3 revision 485): (sorting changed to match order) # _______________________________ NOTE: with halo=8µm __________________________________ @@ -227,6 +234,8 @@ def test_sidewall_100um_x_100um_distance_200nm_li1(): @allure.parent_suite(parent_suite) @allure.tag(*tags) +@pytest.mark.slow +@pytest.mark.wip def test_sidewall_net_uturn_l1_redux(): # MAGIC GIVES (8.3 revision 485): (sorting changed to match order) # _______________________________ NOTE: with halo=8µm __________________________________ @@ -247,6 +256,8 @@ def test_sidewall_net_uturn_l1_redux(): @allure.parent_suite(parent_suite) @allure.tag(*tags) +@pytest.mark.slow +@pytest.mark.wip def test_sidewall_cap_vpp_04p4x04p6_l1_redux(): # MAGIC GIVES (8.3 revision 485): (sorting changed to match order) # _______________________________ NOTE: with halo=8µm __________________________________ @@ -267,6 +278,8 @@ def test_sidewall_cap_vpp_04p4x04p6_l1_redux(): @allure.parent_suite(parent_suite) @allure.tag(*tags) +@pytest.mark.slow +@pytest.mark.wip def test_near_body_shield_li1_m1(): # MAGIC GIVES (8.3 revision 485): (sorting changed to match order) #_______________________________ NOTE: with halo=8µm __________________________________ @@ -292,6 +305,8 @@ def test_near_body_shield_li1_m1(): @allure.parent_suite(parent_suite) @allure.tag(*tags) +@pytest.mark.slow +@pytest.mark.wip def test_sideoverlap_simple_plates_li1_m1(): # MAGIC GIVES (8.3 revision 485): (sorting changed to match order) # _______________________________ NOTE: with halo=8µm __________________________________ From adfa6280a2f79056502fe7275fd569111be5cc3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ko=CC=88hler?= Date: Thu, 5 Dec 2024 18:50:37 +0100 Subject: [PATCH 4/4] run_tests.sh: fixed coverage handling --- run_tests.sh | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/run_tests.sh b/run_tests.sh index 902bfbdc..9a2ab2a5 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -25,27 +25,35 @@ DIR=$(dirname -- $(realpath ${BASH_SOURCE})) -export PYTHONPATH=$DIR/:$DIR/build/python:${PYTHONPATH} +## export PYTHONPATH=$DIR/:$DIR/build/python:${PYTHONPATH} -mkdir -p $DIR/build +mkdir -p "$DIR"/build -ALLURE_RESULTS_PATH=$DIR/build/allure-results -ALLURE_REPORT_PATH=$DIR/build/allure-report -COVERAGE_PATH=$DIR/build/coverage-results +ALLURE_RESULTS_PATH="$DIR/build/allure-results" +ALLURE_REPORT_PATH="$DIR/build/allure-report" +COVERAGE_PATH="$DIR/build/coverage-results" -poetry run pytest \ - --alluredir $ALLURE_RESULTS_PATH \ - --color no \ - --cov=$COVERAGE_PATH \ - --cov-report=html +set -x +set -e + +rm -rf "$ALLURE_RESULTS_PATH" +rm -rf "$ALLURE_REPORT_PATH" +rm -rf "$COVERAGE_PATH" + +poetry run coverage run -m pytest -m "not slow" \ + --alluredir "$ALLURE_RESULTS_PATH" \ + --color no + +poetry run coverage html --directory "$COVERAGE_PATH" allure generate \ - --single-file $ALLURE_RESULTS_PATH \ - --output $ALLURE_REPORT_PATH \ + --single-file "$ALLURE_RESULTS_PATH" \ + --output "$ALLURE_REPORT_PATH" \ --clean if [[ -z "$RUNNER_OS" ]] && [[ -d "/Applications/Safari.app" ]] then - open -a Safari $ALLURE_REPORT_PATH/index.html + open -a Safari "$ALLURE_REPORT_PATH"/index.html + open -a Safari "$COVERAGE_PATH"/index.html fi