Skip to content

Commit f423a3e

Browse files
authored
Merge pull request intel#108 from elbeno/remove-pytest-forked
Remove `pytest-forked`; provide `requirements.txt`
2 parents 02b28c1 + 5b01e22 commit f423a3e

File tree

7 files changed

+52
-16
lines changed

7 files changed

+52
-16
lines changed

.github/workflows/test.yml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,6 @@ jobs:
4848
sudo apt install -y asciidoctor
4949
sudo gem install asciidoctor asciidoctor-diagram rouge
5050
51-
- name: Install cmake-format
52-
run: |
53-
pipx install cmakelang
54-
pipx inject cmakelang pyyaml
55-
56-
- name: Install python quality tools
57-
run: |
58-
pipx install pytest
59-
pipx inject pytest pytest-forked
60-
pipx inject pytest hypothesis
61-
pipx install mypy
62-
pipx install black
63-
echo "/opt/pipx_bin" >> $GITHUB_PATH
64-
6551
- name: Checkout target branch
6652
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
6753
with:
@@ -74,6 +60,21 @@ jobs:
7460
- name: Checkout PR branch
7561
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
7662

63+
- name: Install python test requirements
64+
run: |
65+
python3 -m venv ${{github.workspace}}/test_venv
66+
source ${{github.workspace}}/test_venv/bin/activate
67+
pip install -r ${{github.workspace}}/requirements.txt
68+
echo "${{github.workspace}}/test_venv/bin" >> $GITHUB_PATH
69+
70+
- name: Install cmake-format
71+
run: |
72+
pip install cmakelang pyyaml
73+
74+
- name: Install python quality tools
75+
run: |
76+
pip install mypy black
77+
7778
- name: Restore CPM cache
7879
env:
7980
cache-name: cpm-cache-0

cmake/main.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ option(INFRA_PROVIDE_CLANG_TIDY "Provide .clang-tidy file" ON)
2626
option(INFRA_PROVIDE_CMAKE_FORMAT "Provide .cmake-format.yaml file" ON)
2727
option(INFRA_PROVIDE_PRESETS "Provide cmake presets and toolchains" ON)
2828
option(INFRA_PROVIDE_MULL "Provide mull.yml file" ON)
29+
option(INFRA_PROVIDE_PYTEST_REQS
30+
"Provide pip requirements.txt for python tests" ON)
2931
option(INFRA_PROVIDE_GITIGNORE "Add provided things to .gitignore" ON)
3032
option(INFRA_USE_SYMLINKS "Use symlinks to provide common files" ON)
3133

cmake/setup.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ function(make_gitignore)
4141
list(APPEND GITIGNORE_CONTENTS "mull.yml")
4242
endif()
4343
endif()
44+
if(INFRA_PROVIDE_PYTEST_REQS)
45+
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/requirements.txt")
46+
list(APPEND GITIGNORE_CONTENTS "requirements.txt")
47+
endif()
48+
endif()
4449
endif()
4550

4651
string(REPLACE ";" "\n" GITIGNORE_CONTENTS "${GITIGNORE_CONTENTS}")
@@ -112,6 +117,9 @@ if(PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
112117
if(INFRA_PROVIDE_MULL)
113118
put_in_project_dir("mull.yml")
114119
endif()
120+
if(INFRA_PROVIDE_PYTEST_REQS)
121+
put_in_project_dir("requirements.txt")
122+
endif()
115123

116124
if(INFRA_PROVIDE_GITHUB_WORKFLOWS)
117125
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory

cmake/test.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ function(add_python_test_target name)
245245
set(include_dirs_arg --include_dirs ${include_dirs})
246246
endif()
247247
set(target_test_command
248-
env "PYTHONPYCACHEPREFIX=${CMAKE_BINARY_DIR}/__pycache__" pytest
249-
--forked -o "cache_dir=${CMAKE_BINARY_DIR}/.pytest_cache"
248+
env "PYTHONPYCACHEPREFIX=${CMAKE_BINARY_DIR}/__pycache__" pytest -n
249+
auto -o "cache_dir=${CMAKE_BINARY_DIR}/.pytest_cache"
250250
--rootdir=${CMAKE_SOURCE_DIR} -s ${UNIT_FILES} ${include_files_arg}
251251
${include_dirs_arg} ${UNIT_EXTRA_ARGS})
252252

docs/options.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ level, and a `toolchains` directory.
3030

3131
When `ON`, this repository provides a `mull.yml` file at the root level.
3232

33+
*`INFRA_PROVIDE_PYTEST_REQS`*
34+
35+
When `ON`, this repository provides a `requirements.txt` file at the root level.
36+
When used with `pip install -r requirements.txt` this provides the packages
37+
sufficient to run python tests.
38+
3339
*`INFRA_PROVIDE_GITIGNORE`*
3440

3541
When `ON`, this repository provides a `.gitignore` file at the root level. It

docs/testing.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ dependencies that are not part of the CMake dependency tree. A `conftest.py`
6868
file in the same directory as any of the `FILE`​s is automatically discovered as
6969
such a dependency.
7070

71+
NOTE: Python tests use several testing packages; these can be installed using
72+
`requirements.txt` which is provided through the `INFRA_PROVIDE_PYTEST_REQS`
73+
option.
74+
7175
=== Fuzz tests
7276

7377
[source,cmake]

requirements.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# The contents of this file can be generated at latest versions available by running:
2+
#
3+
# $ python3 -m venv ./test_venv
4+
# $ source ./test_venv/bin/activate
5+
# $ pip install pytest pytest-xdist hypothesis | tail -n1 | cut -d' ' -f 3- | tr ' ' '\n' | sed 's/\(.*\)-\(.*\)/\1==\2/'
6+
#
7+
attrs==24.2.0
8+
execnet==2.1.1
9+
hypothesis==6.115.3
10+
iniconfig==2.0.0
11+
packaging==24.1
12+
pluggy==1.5.0
13+
pytest==8.3.3
14+
pytest-xdist==3.6.1
15+
sortedcontainers==2.4.0

0 commit comments

Comments
 (0)