Skip to content

Commit 3ed773e

Browse files
authored
Merge pull request #76 from robotpy/add-tests
WIP: Add initial integration tests for robotpy-build
2 parents b4146ef + b4ac5eb commit 3ed773e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1468
-6
lines changed

.github/workflows/dist.yml

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,55 @@ jobs:
1616
run: |
1717
pip install black
1818
black --check --diff .
19+
20+
test:
21+
runs-on: ${{ matrix.os }}
22+
strategy:
23+
matrix:
24+
os: [windows-latest, macos-latest, ubuntu-18.04]
25+
python_version: [3.6, 3.7, 3.8]
26+
architecture: [x86, x64]
27+
exclude:
28+
- os: macos-latest
29+
architecture: x86
30+
- os: ubuntu-18.04
31+
architecture: x86
32+
33+
steps:
34+
- uses: actions/checkout@v2
35+
- name: Checkout submodules
36+
shell: bash
37+
run: |
38+
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
39+
git submodule sync --recursive
40+
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
41+
42+
- uses: actions/setup-python@v1
43+
with:
44+
python-version: ${{ matrix.python_version }}
45+
architecture: ${{ matrix.architecture }}
46+
47+
- name: Install build dependencies
48+
run: pip install wheel
49+
50+
- name: Build wheel
51+
run: python setup.py bdist_wheel
52+
53+
- name: Test wheel
54+
shell: bash
55+
env:
56+
RPYBUILD_PARALLEL: 1
57+
RPYBUILD_STRIP_LIBPYTHON: 1
58+
run: |
59+
cd dist
60+
python -m pip install *.whl
61+
cd ../tests
62+
python -m pip install -r requirements.txt
63+
python run_tests.py
1964
2065
publish:
2166
runs-on: ubuntu-latest
22-
needs: [check]
67+
needs: [check, test]
2368
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
2469

2570
steps:

robotpy_build/templates/cls.cpp.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void init_{{ mod_fn }}(py::module &m) {
6060
{% endfor %}
6161

6262
{# define global enums in case they are used as default args #}
63-
{% for enum in header.enums %}
63+
{% for enum in header.enums if not enum.data.ignore %}
6464
{{ pybind11.genenum(enum.x_module_var, enum) }}
6565
{% endfor %}
6666

robotpy_build/templates/pybind11.cpp.j2

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ py::enum_<{{ enum.x_namespace }}{{ enum.name }}>({{ scope }}, "{{ enum.x_name }}
251251
{%- if cls.x_inherits -%}
252252
, {{ cls.x_inherits | join(', ', attribute='class') }}
253253
{%- endif -%}
254-
254+
255255
>
256256
{{ varname }}(
257257

@@ -260,12 +260,18 @@ py::enum_<{{ enum.x_namespace }}{{ enum.name }}>({{ scope }}, "{{ enum.x_name }}
260260
{%- else -%}
261261
{{ cls.x_module_var }}
262262
{%- endif -%}
263-
, {{ name }});
263+
, {{ name }}
264+
265+
{%- if cls.final -%}
266+
, py::is_final()
267+
{%- endif -%}
268+
269+
);
264270

265271
{{ doc(cls, varname + '.doc() =', ';') }}
266272

267273
{# define class enums in case they are used as default args #}
268-
{% for enum in cls.enums.public %}
274+
{% for enum in cls.enums.public if not enum.data.ignore %}
269275
{{ genenum(cls.x_varname, enum) }}
270276
{% endfor %}
271277

tests/cpp/.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
*.pyc
3+
4+
*.so
5+
*.dll
6+
*.pyd
7+
*.dylib
8+
9+
/build
10+
/dist
11+
/pip-wheel-metadata
12+
13+
# autogenerated from template
14+
/pyproject.toml
15+
16+
/rpytest/version.py
17+
18+
/rpytest/dl/_init_rpytest_dl.py
19+
/rpytest/dl/pkgcfg.py
20+
/rpytest/dl/include
21+
/rpytest/dl/rpy-include
22+
23+
/rpytest/ft/_init_rpytest_ft.py
24+
/rpytest/ft/pkgcfg.py
25+
/rpytest/ft/rpy-include
26+
27+
/rpytest/srconly/_init_rpytest_srconly.py
28+
/rpytest/srconly/pkgcfg.py
29+
/rpytest/srconly/include
30+
/rpytest/srconly/rpy-include

tests/cpp/dl/downloaded.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
#include "downloaded.h"
3+
4+
int downloaded_fn(int val) {
5+
return 0x42 + val;
6+
}

tests/cpp/dl/downloaded.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
#pragma once
3+
4+
int downloaded_fn(int val);

tests/cpp/gen/dl/downloaded.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
3+
functions:
4+
downloaded_fn:

tests/cpp/gen/ft/ignore.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
enums:
3+
IgnoredEnum:
4+
ignore: true
5+
EnumWithIgnored:
6+
values:
7+
Ignored:
8+
ignore: true
9+
functions:
10+
fnIgnore:
11+
ignore: true
12+
fnIgnoredParam:
13+
param_override:
14+
x:
15+
ignore: true
16+
# ignoring the param requires inline cpp
17+
cpp_code: |
18+
[]() {
19+
return fnIgnoredParam(3);
20+
}
21+
22+
classes:
23+
IgnoredClass:
24+
ignore: true
25+
ClassWithIgnored:
26+
shared_ptr: true
27+
attributes:
28+
ignoredProp:
29+
ignore: true
30+
enums:
31+
IgnoredInnerEnum:
32+
ignore: true
33+
InnerEnumWithIgnored:
34+
values:
35+
Param1:
36+
ignore: true
37+
methods:
38+
fnIgnore:
39+
ignore: true
40+
fnIgnoredParam:
41+
param_override:
42+
x:
43+
ignore: true
44+
# ignoring the param requires inline cpp
45+
cpp_code: |
46+
[](ClassWithIgnored * self, int y) {
47+
return self->fnIgnoredParam(42, y);
48+
}

tests/cpp/gen/ft/rename.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
enums:
3+
OriginalEnum:
4+
rename: RenamedEnum
5+
values:
6+
Original1:
7+
rename: Renamed1
8+
9+
functions:
10+
fnOriginal:
11+
rename: fnRenamed
12+
fnRenamedParam:
13+
param_override:
14+
x:
15+
name: y
16+
classes:
17+
OriginalClass:
18+
shared_ptr: true
19+
rename: RenamedClass
20+
attributes:
21+
originalProp:
22+
rename: renamedProp
23+
enums:
24+
ClassOriginalEnum:
25+
rename: ClassRenamedEnum
26+
values:
27+
Param1:
28+
rename: P1
29+
methods:
30+
fnOriginal:
31+
rename: fnRenamed
32+
fnRenamedParam:
33+
param_override:
34+
x:
35+
name: y
36+
setProp:

0 commit comments

Comments
 (0)