Skip to content

Commit

Permalink
stubber: Fix: Update source path handling and enhance package creatio…
Browse files Browse the repository at this point in the history
…n tests

Fixes: #648
Signed-off-by: Jos Verlinde <Jos.Verlinde@microsoft.com>
  • Loading branch information
Josverl committed Jan 28, 2025
1 parent 21f1cd2 commit 319e3cf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
3 changes: 2 additions & 1 deletion src/stubber/publish/stubpackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,8 +856,9 @@ def update_sources(self) -> StubSources:
# use if folder exists , else use GENERIC folder
if (CONFIG.stub_path / fw_path).exists():
updated_sources.append((stub_type, fw_path))
elif fw_path.with_name("GENERIC").exists():
elif (CONFIG.stub_path / fw_path).with_name("GENERIC").exists():
updated_sources.append((stub_type, fw_path.with_name("GENERIC")))

elif stub_type == StubSource.MERGED:
# Use the default board folder instead of the GENERIC board folder (if it exists)
if self.board.upper() == GENERIC_U:
Expand Down
42 changes: 25 additions & 17 deletions tests/publish/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,25 @@ def test_package_name(family, port, board, expected):
assert x == expected


# test creating a DOC_STUBS package
# test creating a package
# @pytest.mark.parametrize(
# "version",
# [
# "v1.24.1",
# # "v1.21.0",
# # "v1.19.1",
# ],
# )
@pytest.mark.parametrize(
"version",
"version, port, board",
[
"v1.21.0",
"v1.20.0",
"v1.19.1",
],
)
@pytest.mark.parametrize(
"port, board",
[
("esp32", "GENERIC"),
("esp32", "GENERIC_S3"),
("esp32", "UM_TINYPICO"),
("stm32", "PYBV1"),
("esp32", "generic"),
("v1.24.1", "rp2", "RPI_PICO"),
("v1.24.1", "rp2", "RPI_PICOW"),
# ("esp32", "GENERIC"),
# ("esp32", "GENERIC_S3"),
# ("esp32", "UM_TINYPICO"),
# ("stm32", "PYBV1"),
# ("esp32", "generic"),
],
)
# CORE_STUBS
Expand Down Expand Up @@ -77,13 +79,12 @@ def test_create_package(
# insert test config
mocker.patch("stubber.publish.stubpackage.CONFIG", config)

mpy_version = "v1.21.0"
family = "micropython"
pkg_name = f"foobar-{port}-{board.lower()}-stubs"

package = create_package(
pkg_name,
mpy_version=mpy_version,
mpy_version=version,
family=family,
port=port,
board=board,
Expand All @@ -92,6 +93,12 @@ def test_create_package(
assert isinstance(package, StubPackage)
run_common_package_tests(package, pkg_name, publish_path=publish_path, stub_path=stub_path)

assert len(package.stub_sources) == 3, "new package must have 3 stub sources"

updated_sources = package.update_sources()
assert updated_sources
assert len(updated_sources) == 3, "new package must still have 3 stub sources"

Check failure on line 100 in tests/publish/test_package.py

View workflow job for this annotation

GitHub Actions / Python 3.12 on ubuntu-latest

test_create_package[v1.24.1-rp2-RPI_PICO] AssertionError: new package must still have 3 stub sources assert 2 == 3 + where 2 = len([(Merged stubs, PosixPath('micropython-v1_24_1-rp2-RPI_PICO-merged')), (Core stubs, PosixPath('micropython-core'))])

Check failure on line 100 in tests/publish/test_package.py

View workflow job for this annotation

GitHub Actions / Python 3.12 on ubuntu-latest

test_create_package[v1.24.1-rp2-RPI_PICOW] AssertionError: new package must still have 3 stub sources assert 2 == 3 + where 2 = len([(Merged stubs, PosixPath('micropython-v1_24_1-rp2-RPI_PICOW-merged')), (Core stubs, PosixPath('micropython-core'))])

Check failure on line 100 in tests/publish/test_package.py

View workflow job for this annotation

GitHub Actions / Python 3.8 on ubuntu-latest

test_create_package[v1.24.1-rp2-RPI_PICO] AssertionError: new package must still have 3 stub sources assert 2 == 3 + where 2 = len([(Merged stubs, PosixPath('micropython-v1_24_1-rp2-RPI_PICO-merged')), (Core stubs, PosixPath('micropython-core'))])

Check failure on line 100 in tests/publish/test_package.py

View workflow job for this annotation

GitHub Actions / Python 3.8 on ubuntu-latest

test_create_package[v1.24.1-rp2-RPI_PICOW] AssertionError: new package must still have 3 stub sources assert 2 == 3 + where 2 = len([(Merged stubs, PosixPath('micropython-v1_24_1-rp2-RPI_PICOW-merged')), (Core stubs, PosixPath('micropython-core'))])

Check failure on line 100 in tests/publish/test_package.py

View workflow job for this annotation

GitHub Actions / Python 3.10 on ubuntu-latest

test_create_package[v1.24.1-rp2-RPI_PICO] AssertionError: new package must still have 3 stub sources assert 2 == 3 + where 2 = len([(Merged stubs, PosixPath('micropython-v1_24_1-rp2-RPI_PICO-merged')), (Core stubs, PosixPath('micropython-core'))])

Check failure on line 100 in tests/publish/test_package.py

View workflow job for this annotation

GitHub Actions / Python 3.10 on ubuntu-latest

test_create_package[v1.24.1-rp2-RPI_PICOW] AssertionError: new package must still have 3 stub sources assert 2 == 3 + where 2 = len([(Merged stubs, PosixPath('micropython-v1_24_1-rp2-RPI_PICOW-merged')), (Core stubs, PosixPath('micropython-core'))])

Check failure on line 100 in tests/publish/test_package.py

View workflow job for this annotation

GitHub Actions / Python 3.9 on ubuntu-latest

test_create_package[v1.24.1-rp2-RPI_PICO] AssertionError: new package must still have 3 stub sources assert 2 == 3 + where 2 = len([(Merged stubs, PosixPath('micropython-v1_24_1-rp2-RPI_PICO-merged')), (Core stubs, PosixPath('micropython-core'))])

Check failure on line 100 in tests/publish/test_package.py

View workflow job for this annotation

GitHub Actions / Python 3.9 on ubuntu-latest

test_create_package[v1.24.1-rp2-RPI_PICOW] AssertionError: new package must still have 3 stub sources assert 2 == 3 + where 2 = len([(Merged stubs, PosixPath('micropython-v1_24_1-rp2-RPI_PICOW-merged')), (Core stubs, PosixPath('micropython-core'))])

Check failure on line 100 in tests/publish/test_package.py

View workflow job for this annotation

GitHub Actions / Python 3.11 on ubuntu-latest

test_create_package[v1.24.1-rp2-RPI_PICO] AssertionError: new package must still have 3 stub sources assert 2 == 3 + where 2 = len([(Merged stubs, PosixPath('micropython-v1_24_1-rp2-RPI_PICO-merged')), (Core stubs, PosixPath('micropython-core'))])

Check failure on line 100 in tests/publish/test_package.py

View workflow job for this annotation

GitHub Actions / Python 3.11 on ubuntu-latest

test_create_package[v1.24.1-rp2-RPI_PICOW] AssertionError: new package must still have 3 stub sources assert 2 == 3 + where 2 = len([(Merged stubs, PosixPath('micropython-v1_24_1-rp2-RPI_PICOW-merged')), (Core stubs, PosixPath('micropython-core'))])

Check failure on line 100 in tests/publish/test_package.py

View workflow job for this annotation

GitHub Actions / Python 3.8 on macos-13

test_create_package[v1.24.1-rp2-RPI_PICO] AssertionError: new package must still have 3 stub sources assert 2 == 3 + where 2 = len([(Merged stubs, PosixPath('micropython-v1_24_1-rp2-RPI_PICO-merged')), (Core stubs, PosixPath('micropython-core'))])

Check failure on line 100 in tests/publish/test_package.py

View workflow job for this annotation

GitHub Actions / Python 3.8 on macos-13

test_create_package[v1.24.1-rp2-RPI_PICOW] AssertionError: new package must still have 3 stub sources assert 2 == 3 + where 2 = len([(Merged stubs, PosixPath('micropython-v1_24_1-rp2-RPI_PICOW-merged')), (Core stubs, PosixPath('micropython-core'))])

Check failure on line 100 in tests/publish/test_package.py

View workflow job for this annotation

GitHub Actions / Python 3.12 on macos-13

test_create_package[v1.24.1-rp2-RPI_PICO] AssertionError: new package must still have 3 stub sources assert 2 == 3 + where 2 = len([(Merged stubs, PosixPath('micropython-v1_24_1-rp2-RPI_PICO-merged')), (Core stubs, PosixPath('micropython-core'))])

Check failure on line 100 in tests/publish/test_package.py

View workflow job for this annotation

GitHub Actions / Python 3.12 on macos-13

test_create_package[v1.24.1-rp2-RPI_PICOW] AssertionError: new package must still have 3 stub sources assert 2 == 3 + where 2 = len([(Merged stubs, PosixPath('micropython-v1_24_1-rp2-RPI_PICOW-merged')), (Core stubs, PosixPath('micropython-core'))])

Check failure on line 100 in tests/publish/test_package.py

View workflow job for this annotation

GitHub Actions / Python 3.9 on macos-13

test_create_package[v1.24.1-rp2-RPI_PICO] AssertionError: new package must still have 3 stub sources assert 2 == 3 + where 2 = len([(Merged stubs, PosixPath('micropython-v1_24_1-rp2-RPI_PICO-merged')), (Core stubs, PosixPath('micropython-core'))])

Check failure on line 100 in tests/publish/test_package.py

View workflow job for this annotation

GitHub Actions / Python 3.9 on macos-13

test_create_package[v1.24.1-rp2-RPI_PICOW] AssertionError: new package must still have 3 stub sources assert 2 == 3 + where 2 = len([(Merged stubs, PosixPath('micropython-v1_24_1-rp2-RPI_PICOW-merged')), (Core stubs, PosixPath('micropython-core'))])

Check failure on line 100 in tests/publish/test_package.py

View workflow job for this annotation

GitHub Actions / Python 3.10 on macos-13

test_create_package[v1.24.1-rp2-RPI_PICO] AssertionError: new package must still have 3 stub sources assert 2 == 3 + where 2 = len([(Merged stubs, PosixPath('micropython-v1_24_1-rp2-RPI_PICO-merged')), (Core stubs, PosixPath('micropython-core'))])

Check failure on line 100 in tests/publish/test_package.py

View workflow job for this annotation

GitHub Actions / Python 3.10 on macos-13

test_create_package[v1.24.1-rp2-RPI_PICOW] AssertionError: new package must still have 3 stub sources assert 2 == 3 + where 2 = len([(Merged stubs, PosixPath('micropython-v1_24_1-rp2-RPI_PICOW-merged')), (Core stubs, PosixPath('micropython-core'))])

Check failure on line 100 in tests/publish/test_package.py

View workflow job for this annotation

GitHub Actions / Python 3.11 on macos-13

test_create_package[v1.24.1-rp2-RPI_PICO] AssertionError: new package must still have 3 stub sources assert 2 == 3 + where 2 = len([(Merged stubs, PosixPath('micropython-v1_24_1-rp2-RPI_PICO-merged')), (Core stubs, PosixPath('micropython-core'))])

Check failure on line 100 in tests/publish/test_package.py

View workflow job for this annotation

GitHub Actions / Python 3.11 on macos-13

test_create_package[v1.24.1-rp2-RPI_PICOW] AssertionError: new package must still have 3 stub sources assert 2 == 3 + where 2 = len([(Merged stubs, PosixPath('micropython-v1_24_1-rp2-RPI_PICOW-merged')), (Core stubs, PosixPath('micropython-core'))])


read_db_data = [
{
Expand Down Expand Up @@ -172,6 +179,7 @@ def test_package_from_json(tmp_path, pytestconfig, mocker: MockerFixture, json):
test_build=False,
)


def run_common_package_tests(
package: StubPackage, pkg_name, publish_path: Path, stub_path: Path, test_build=True
):
Expand Down

0 comments on commit 319e3cf

Please sign in to comment.