Skip to content

Commit

Permalink
Merge pull request #486 from zapta/develop
Browse files Browse the repository at this point in the history
Adapting to the new examples package.
  • Loading branch information
Obijuan authored Dec 5, 2024
2 parents 0c45646 + b3d851c commit 4218fe3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
6 changes: 3 additions & 3 deletions apio/managers/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import shutil
from pathlib import Path, PosixPath
from dataclasses import dataclass
from typing import Optional, Tuple, List
from typing import Optional, List
import click
from apio import util
from apio import pkg_util
Expand Down Expand Up @@ -49,7 +49,7 @@ def __init__(self, apio_ctx: ApioContext):
self.apio_ctx = apio_ctx

# -- Folder where the example packages was installed
self.examples_dir = apio_ctx.get_package_dir("examples")
self.examples_dir = apio_ctx.get_package_dir("examples") / "examples"

def get_examples_infos(self) -> Optional[List[ExampleInfo]]:
"""Scans the examples and returns a list of ExampleInfos.
Expand All @@ -66,7 +66,7 @@ def get_examples_infos(self) -> Optional[List[ExampleInfo]]:
boards_dirs.append(board_dir)

# -- Collect the examples of each boards.
examples: List[Tuple[str, PosixPath]] = []
examples: List[ExampleInfo] = []
for board_dir in boards_dirs:

# -- Iterate board's example subdirectories.
Expand Down
4 changes: 2 additions & 2 deletions apio/resources/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"examples": {
"repository": {
"name": "apio-examples",
"organization": "zapta"
"organization": "FPGAwars"
},
"release": {
"tag_name": "%V",
"compressed_name": "apio-examples-%V",
"uncompressed_name": "apio-examples-%V",
"folder_name": "examples",
"extension": "zip",
"url_version": "https://github.com/zapta/apio-examples/raw/master/VERSION"
"url_version": "https://github.com/FPGAwars/apio-examples/raw/master/VERSION"
},
"description": "Verilog examples",
"env": {}
Expand Down
21 changes: 11 additions & 10 deletions test/integration/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,21 @@ def test_examples(apio_runner: ApioRunner):
# -- Install the examples package.
result = sb.invoke_apio_cmd(apio_packages, ["--install", "examples"])
sb.assert_ok(result)
# assert "Installing package 'examples'" in result.output
# assert "Download" in result.output
assert "Package 'examples' installed successfully" in result.output
assert getsize(sb.packages_dir / "examples/alhambra-ii/ledon/ledon.v")
assert getsize(
sb.packages_dir / "examples/examples/alhambra-ii/ledon/ledon.v"
)

# -- List the examples
# -- 'apio examples --list'
result = sb.invoke_apio_cmd(
apio_examples,
["--list"],
)
sb.assert_ok(result)
assert "alhambra-ii/ledon" in result.output
assert "Hello world for the Alhambra-II board" in result.output

# -- Fetch example files to current directory
# -- 'apio examples --fetch-files alhambra-ii/ledon'
result = sb.invoke_apio_cmd(
apio_examples,
["--fetch-files", "alhambra-ii/ledon"],
Expand All @@ -54,7 +55,7 @@ def test_examples(apio_runner: ApioRunner):
assert "have been successfully created!" in result.output
assert getsize("ledon.v")

# -- Fetch example dir to current directory
# -- 'apio examples --fetch-dir alhambra-ii/ledon'
result = sb.invoke_apio_cmd(
apio_examples,
["--fetch-dir", "alhambra-ii/ledon"],
Expand All @@ -64,20 +65,20 @@ def test_examples(apio_runner: ApioRunner):
assert "has been successfully created" in result.output
assert getsize("alhambra-ii/ledon/ledon.v")

# -- Fetch example files to another project dir
# -- 'apio examples --fetch-files" alhambra-ii/ledon -p dir1'
result = sb.invoke_apio_cmd(
apio_examples,
["--fetch-files", "alhambra-ii/ledon", "--project-dir=./dir1"],
["--fetch-files", "alhambra-ii/ledon", "-p", "dir1"],
)
sb.assert_ok(result)
assert "Copying alhambra-ii/ledon example files" in result.output
assert "have been successfully created!" in result.output
assert getsize("dir1/ledon.v")

# -- Fetch example dir to another project dir
# -- 'apio examples --fetch-dir alhambra-ii/ledon -p dir2
result = sb.invoke_apio_cmd(
apio_examples,
["--fetch-dir", "alhambra-ii/ledon", "--project-dir=dir2"],
["--fetch-dir", "alhambra-ii/ledon", "-p", "dir2"],
)
sb.assert_ok(result)
assert "Creating alhambra-ii/ledon directory" in result.output
Expand Down
8 changes: 5 additions & 3 deletions test/integration/test_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_packages(apio_runner: ApioRunner):
result = sb.invoke_apio_cmd(apio_packages, ["--install", "examples"])
sb.assert_ok(result)
assert "Package 'examples' installed successfully" in result.output
assert listdir(sb.packages_dir / "examples/alhambra-ii")
assert listdir(sb.packages_dir / "examples/examples/alhambra-ii")
assert "tools-oss-cad-suite" not in listdir(sb.packages_dir)

# -- Install the reset of the packages.
Expand All @@ -55,12 +55,14 @@ def test_packages(apio_runner: ApioRunner):
assert (
"Package 'oss-cad-suite' installed successfully" in result.output
)
assert listdir(sb.packages_dir / "examples/alhambra-ii")
assert listdir(sb.packages_dir / "examples/examples/alhambra-ii")
assert listdir(sb.packages_dir / "tools-oss-cad-suite/bin")

# -- Delete a file from the examples package, we will use it as an
# -- indicator for the reinstallation of the package.
marker_file = sb.packages_dir / "examples/alhambra-ii/ledon/ledon.v"
marker_file = (
sb.packages_dir / "examples/examples/alhambra-ii/ledon/ledon.v"
)
assert marker_file.is_file()
marker_file.unlink()
assert not marker_file.exists()
Expand Down

0 comments on commit 4218fe3

Please sign in to comment.