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

+46-1
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

+1-1
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

+9-3
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

+30
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

+6
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

+4
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

+4
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

+48
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

+36
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:

tests/cpp/gen/ft/static_only.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
3+
classes:
4+
StaticOnly:
5+
nodelete: true
6+
methods:
7+
callme:

tests/cpp/gen/ft/tbase.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
classes:
3+
TBase:
4+
shared_ptr: true
5+
methods:
6+
get:
7+
baseFn:

tests/cpp/gen/ft/tbasic.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
classes:
3+
TBasic:
4+
shared_ptr: true
5+
template_params:
6+
- T
7+
attributes:
8+
t:
9+
10+
templates:
11+
TBasicString:
12+
qualname: TBasic
13+
params:
14+
- std::string

tests/cpp/gen/ft/tconcrete.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
classes:
2+
TConcrete:
3+
shared_ptr: true
4+
methods:
5+
concrete:
6+
7+
templates:
8+
TcrtpFwdConcrete:
9+
qualname: TCrtpFwd
10+
params:
11+
- TConcrete
12+
13+
TcrtpConcrete:
14+
qualname: TCrtp
15+
params:
16+
- TConcrete

tests/cpp/gen/ft/tcrtp.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
classes:
2+
TCrtp:
3+
shared_ptr: true
4+
force_no_default_constructor: true
5+
template_params:
6+
- T
7+
methods:
8+
get:

tests/cpp/gen/ft/tcrtpfwd.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
classes:
2+
TCrtpFwd:
3+
shared_ptr: true
4+
force_no_default_constructor: true
5+
template_params:
6+
- T
7+
methods:
8+
get:

tests/cpp/gen/ft/tfn.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
3+
classes:
4+
TClassWithFn:
5+
shared_ptr: true
6+
methods:
7+
getT:
8+
template_impls:
9+
# ordering matters here!
10+
- ["bool"]
11+
- ["int"]

tests/cpp/gen/ft/tnested.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
3+
classes:
4+
Outer:
5+
shared_ptr: true
6+
template_params:
7+
- T
8+
9+
Outer::Inner:
10+
shared_ptr: true
11+
attributes:
12+
t:
13+
14+
templates:
15+
TOuter:
16+
qualname: Outer
17+
params:
18+
- int

tests/cpp/gen/ft/tnumeric.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
classes:
3+
TBaseGetN:
4+
shared_ptr: true
5+
template_params:
6+
- int N
7+
methods:
8+
getIt:
9+
10+
TChildGetN4:
11+
shared_ptr: true
12+
13+
TChildGetN:
14+
shared_ptr: true
15+
template_params:
16+
- int N
17+
18+
templates:
19+
TBaseGetN4:
20+
qualname: TBaseGetN
21+
params:
22+
- 4
23+
24+
TBaseGetN6:
25+
qualname: TBaseGetN
26+
params:
27+
- 6
28+
29+
TChildGetN6:
30+
qualname: TChildGetN
31+
params:
32+
- 6

0 commit comments

Comments
 (0)