Skip to content

Commit 4a98e1a

Browse files
committed
Add a simple test
this is extensible so if we find problems we can copy a minimimzed version of the affected file in and ensure the problem's fixed
1 parent ce6de42 commit 4a98e1a

File tree

6 files changed

+93
-1
lines changed

6 files changed

+93
-1
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ jobs:
4848
git clone --recurse-submodules https://github.com/adafruit/CircuitPython_Community_Bundle.git
4949
cd CircuitPython_Community_Bundle
5050
circuitpython-build-bundles --filename_prefix test-bundle --library_location libraries --library_depth 2
51+
- name: Munge tests
52+
run: pytest
5153
- name: Build Python package
5254
run: |
5355
pip install --upgrade setuptools wheel twine readme_renderer testresources

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ version.py
1010
.env/*
1111
.DS_Store
1212
.idea/*
13+
testcases/*.out

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Click
2+
pytest
23
requests
34
semver
4-
wheel
55
tomli; python_version < "3.11"
6+
wheel

testcases/test1.exp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
3+
4+
5+
if 1:
6+
pass
7+
8+
9+
10+
if 1:
11+
pass
12+
13+
14+
15+
16+
if 1:
17+
pass
18+
19+
20+
21+
if 1:
22+
pass
23+
24+
__version__ = "1.2.3"
25+
26+
if 1:
27+
print("is circuitpython")
28+
29+
if 0:
30+
print("not circuitpython (1)")
31+
32+
if 0:
33+
print("not circuitpython (2)")

testcases/test1.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from __future__ import annotation
2+
3+
try:
4+
from typing import TYPE_CHECKING
5+
except ImportError:
6+
pass
7+
8+
try:
9+
from typing import TYPE_CHECKING as T
10+
except ImportError:
11+
pass
12+
13+
14+
try:
15+
import typing
16+
except:
17+
pass
18+
19+
try:
20+
import typing as T
21+
except:
22+
pass
23+
24+
__version__ = "0.0.0-auto"
25+
26+
if sys.implementation.name == "circuitpython":
27+
print("is circuitpython")
28+
29+
if sys.implementation.name != "circuitpython":
30+
print("not circuitpython (1)")
31+
32+
if not sys.implementation.name == "circuitpython":
33+
print("not circuitpython (2)")

tests/test_munge.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import sys, pathlib
2+
import pytest
3+
4+
top = pathlib.Path(__file__).parent.parent
5+
sys.path.insert(0, str(top))
6+
7+
from circuitpython_build_tools.munge import munge
8+
9+
@pytest.mark.parametrize("test_path", top.glob("testcases/*.py"))
10+
def test_munge(test_path):
11+
result_path = test_path.with_suffix(".out")
12+
result_path.unlink(missing_ok = True)
13+
14+
result_content = munge(test_path, "1.2.3")
15+
result_path.write_text(result_content, encoding="utf-8")
16+
17+
expected = test_path.with_suffix(".exp")
18+
expected_content = expected.read_text(encoding="utf-8")
19+
20+
assert result == expected
21+
22+
result_path.unlink()

0 commit comments

Comments
 (0)