diff --git a/.gitignore b/.gitignore index d6034647a557c21f67a8a128c313d80164c2f0bb..8a416e12c9c75b449f4f84a1bc2519e620935800 100644 --- a/.gitignore +++ b/.gitignore @@ -116,3 +116,4 @@ TODO.txt b_asic/_version.py docs_sphinx/_build/ docs_sphinx/examples +result_images/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 280f6064006e3d6409a16e18dbecb581b738b339..b53602d60a2560abcfc6a61ca3589af7361dc15e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,7 +23,7 @@ before_script: .run-test: stage: test script: - - pytest --cov=b_asic --cov-report=xml:cov.xml --cov-report=term --cov-branch --color=yes test --mpl --timeout=20 --durations=10 + - pytest --cov=b_asic --cov-report=xml:cov.xml --cov-report=term --cov-branch --color=yes test --timeout=20 --durations=10 # - lcov --capture --directory . --output-file coverage.info # - lcov --output-file coverage.info --extract coverage.info $PWD/src/'*' $PWD/b_asic/'*' # - lcov --list coverage.info diff --git a/README.md b/README.md index f282c0e078fb03db14c53f4780f5f97c71566118..58c7f54badbf1d4641332b568e721f2016bbd7ee 100644 --- a/README.md +++ b/README.md @@ -127,13 +127,15 @@ pytest pytest --cov=b_asic --cov-report=html test ``` -#### Test including plots +#### Generate new baseline images for the tests + +In `B-ASIC`: ``` -pytest --mpl +pytest # The image comparison tests will fail +cp -a result_images/* test/baseline_images/ ``` - ### Generating documentation ``` diff --git a/requirements_test.txt b/requirements_test.txt index bd51fe8943cd07d3c7e8f7b1cc98a0597d55fec0..0227dfd78bf4ebc0abed394895fc457fe6175bfe 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,7 +1,6 @@ pytest pytest-cov pytest-qt -pytest-mpl pytest-timeout pytest-xvfb pytest-xdist diff --git a/test/baseline/test__get_figure_no_execution_times.png b/test/baseline/test__get_figure_no_execution_times.png deleted file mode 100644 index bfe81db6ffd39001bbe01f50e4a13530bf38d16c..0000000000000000000000000000000000000000 Binary files a/test/baseline/test__get_figure_no_execution_times.png and /dev/null differ diff --git a/test/baseline/test_draw_matrix_transposer_4.png b/test/baseline/test_draw_matrix_transposer_4.png deleted file mode 100644 index 7c2c59a58eefde33df86de184688f3cdbe3a8b93..0000000000000000000000000000000000000000 Binary files a/test/baseline/test_draw_matrix_transposer_4.png and /dev/null differ diff --git a/test/baseline/test_draw_process_collection.png b/test/baseline/test_draw_process_collection.png deleted file mode 100644 index 538978b1a5702794e5fce020425b7b019c39ead3..0000000000000000000000000000000000000000 Binary files a/test/baseline/test_draw_process_collection.png and /dev/null differ diff --git a/test/baseline/test_left_edge_cell_assignment.png b/test/baseline/test_left_edge_cell_assignment.png deleted file mode 100644 index 45e5846b3da869fecc614a3009a42273dd1a9ae4..0000000000000000000000000000000000000000 Binary files a/test/baseline/test_left_edge_cell_assignment.png and /dev/null differ diff --git a/test/baseline/test_max_min_lifetime_bar_plot.png b/test/baseline/test_max_min_lifetime_bar_plot.png deleted file mode 100644 index 1c42a415a67107e00e5aa19325c24b0e8995b4de..0000000000000000000000000000000000000000 Binary files a/test/baseline/test_max_min_lifetime_bar_plot.png and /dev/null differ diff --git a/test/baseline_images/test_resources/test_draw_matrix_transposer_4.png b/test/baseline_images/test_resources/test_draw_matrix_transposer_4.png new file mode 100644 index 0000000000000000000000000000000000000000..276baf59083c347583caba6eee549ec329447856 Binary files /dev/null and b/test/baseline_images/test_resources/test_draw_matrix_transposer_4.png differ diff --git a/test/baseline_images/test_resources/test_draw_process_collection.png b/test/baseline_images/test_resources/test_draw_process_collection.png new file mode 100644 index 0000000000000000000000000000000000000000..1b8f5f082a87bf32588e81a72f3a6dfc7f1c6201 Binary files /dev/null and b/test/baseline_images/test_resources/test_draw_process_collection.png differ diff --git a/test/baseline_images/test_resources/test_left_edge_cell_assignment.png b/test/baseline_images/test_resources/test_left_edge_cell_assignment.png new file mode 100644 index 0000000000000000000000000000000000000000..c83495ddb8bfc960d2bda573dcb15ed80e4a8676 Binary files /dev/null and b/test/baseline_images/test_resources/test_left_edge_cell_assignment.png differ diff --git a/test/baseline_images/test_resources/test_max_min_lifetime_bar_plot.png b/test/baseline_images/test_resources/test_max_min_lifetime_bar_plot.png new file mode 100644 index 0000000000000000000000000000000000000000..fc8b76258ef6a279a2c8fcf8a7c82e5056fff56f Binary files /dev/null and b/test/baseline_images/test_resources/test_max_min_lifetime_bar_plot.png differ diff --git a/test/baseline_images/test_schedule/test__get_figure_no_execution_times.png b/test/baseline_images/test_schedule/test__get_figure_no_execution_times.png new file mode 100644 index 0000000000000000000000000000000000000000..afd3f789e17445d2a01e9de733112bdaf558d6d2 Binary files /dev/null and b/test/baseline_images/test_schedule/test__get_figure_no_execution_times.png differ diff --git a/test/test_resources.py b/test/test_resources.py index df034037f76af143c1dbabfbcb2002fc8bfb4144..aac845b2498102d84e200d9d4719ddb449ad0231 100644 --- a/test/test_resources.py +++ b/test/test_resources.py @@ -2,6 +2,7 @@ import re import matplotlib.pyplot as plt import pytest +import matplotlib.testing.decorators from b_asic.core_operations import ConstantMultiplication from b_asic.process import PlainMemoryVariable @@ -13,13 +14,13 @@ from b_asic.resources import ProcessCollection, _ForwardBackwardTable class TestProcessCollectionPlainMemoryVariable: - @pytest.mark.mpl_image_compare(style='mpl20') + @matplotlib.testing.decorators.image_comparison(['test_draw_process_collection.png']) def test_draw_process_collection(self, simple_collection): fig, ax = plt.subplots() simple_collection.plot(ax=ax, show_markers=False) return fig - @pytest.mark.mpl_image_compare(style='mpl20') + @matplotlib.testing.decorators.image_comparison(['test_draw_matrix_transposer_4.png']) def test_draw_matrix_transposer_4(self): fig, ax = plt.subplots() generate_matrix_transposer(4).plot(ax=ax) # type: ignore @@ -31,7 +32,7 @@ class TestProcessCollectionPlainMemoryVariable: ) assert len(collection_split) == 3 - @pytest.mark.mpl_image_compare(style='mpl20') + @matplotlib.testing.decorators.image_comparison(['test_left_edge_cell_assignment.png']) def test_left_edge_cell_assignment(self, simple_collection: ProcessCollection): fig, ax = plt.subplots(1, 2) assignment = list(simple_collection._left_edge_assignment()) @@ -157,7 +158,7 @@ class TestProcessCollectionPlainMemoryVariable: assert len(simple_collection) == 7 assert new_proc not in simple_collection - @pytest.mark.mpl_image_compare(style='mpl20') + @matplotlib.testing.decorators.image_comparison(['test_max_min_lifetime_bar_plot.png']) def test_max_min_lifetime_bar_plot(self): fig, ax = plt.subplots() collection = ProcessCollection( diff --git a/test/test_schedule.py b/test/test_schedule.py index aa9b763a0040248eb47caebdedb36612f0657247..aba52d2f1d39e52a490fb6016c8d752b2b6aad30 100644 --- a/test/test_schedule.py +++ b/test/test_schedule.py @@ -4,6 +4,7 @@ B-ASIC test suite for the schedule module and Schedule class. import re import pytest +import matplotlib.testing.decorators from b_asic.core_operations import Addition, Butterfly, ConstantMultiplication from b_asic.process import OperatorProcess @@ -681,7 +682,7 @@ class TestProcesses: class TestFigureGeneration: - @pytest.mark.mpl_image_compare(remove_text=True, style='mpl20') + @matplotlib.testing.decorators.image_comparison(['test__get_figure_no_execution_times.png'], remove_text=True) def test__get_figure_no_execution_times(self, secondorder_iir_schedule): return secondorder_iir_schedule._get_figure()