-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing test files + add the workflow for Github Actions (#4)
- Loading branch information
Showing
8 changed files
with
255 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Tests | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout angle-builder | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
|
||
- name: Install angle-builder | ||
run: pip install ".[dev]" | ||
|
||
- name: Run PEP8 check | ||
run: | | ||
pip install flake8 | ||
flake8 src tests | ||
- name: Run tests | ||
run: python -m pytest tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
""" | ||
Dummy conftest.py for angle_builder. | ||
Read more about conftest.py under: | ||
- https://docs.pytest.org/en/stable/fixture.html | ||
- https://docs.pytest.org/en/stable/writing_plugins.html | ||
""" | ||
|
||
# import pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import os | ||
import tempfile | ||
import shutil | ||
|
||
import pytest | ||
|
||
from angle_builder.angle import ANGLE | ||
from angle_builder.storage import StorageFolderManager | ||
from angle_builder.depot_tools import DepotTools | ||
|
||
|
||
@pytest.fixture | ||
def angle(request): | ||
_tmpdir = tempfile.mkdtemp() | ||
_storage_manager = StorageFolderManager( | ||
user_path=os.path.join(_tmpdir, "storage") | ||
) | ||
|
||
_depot_tools = DepotTools(storage_manager=_storage_manager) | ||
_depot_tools.ensure_depot_tools() | ||
_angle = ANGLE( | ||
branch="chromium/6045", | ||
storage_manager=_storage_manager, | ||
) | ||
|
||
def finalizer(): | ||
shutil.rmtree(_tmpdir) | ||
|
||
request.addfinalizer(finalizer) | ||
|
||
return _angle | ||
|
||
|
||
def test_underlined_branch_name(angle): | ||
assert angle.underlined_branch == "chromium__6045" | ||
|
||
|
||
def test_angle_path(angle): | ||
assert angle.angle_path == os.path.join( | ||
angle.storage_manager.folder_path, f"angle-{angle.underlined_branch}" | ||
) | ||
|
||
|
||
def test_generate_build_targets_mac_universal(angle): | ||
|
||
_x64_macos = angle._generate_build_targets("macos-x64") | ||
_arm64_macos = angle._generate_build_targets("macos-arm64") | ||
|
||
assert len(_x64_macos) == 1 | ||
assert len(_arm64_macos) == 1 | ||
|
||
_universal_macos = angle._generate_build_targets("macos-universal") | ||
|
||
assert len(_universal_macos) == 2 | ||
assert _x64_macos[0] in _universal_macos | ||
assert _arm64_macos[0] in _universal_macos | ||
|
||
|
||
def test_generate_build_targets_ios_universal(angle): | ||
|
||
x64_iphonesimulator = angle._generate_build_targets("iphonesimulator-x64") | ||
arm64_iphonesimulator = angle._generate_build_targets("iphonesimulator-arm64") | ||
arm64_iphoneos = angle._generate_build_targets("iphoneos-arm64") | ||
|
||
assert len(x64_iphonesimulator) == 1 | ||
assert len(arm64_iphonesimulator) == 1 | ||
assert len(arm64_iphoneos) == 1 | ||
|
||
universal_all_iphone = angle._generate_build_targets("iphone*-universal") | ||
|
||
assert len(universal_all_iphone) == 3 | ||
assert x64_iphonesimulator[0] in universal_all_iphone | ||
assert arm64_iphonesimulator[0] in universal_all_iphone | ||
assert arm64_iphoneos[0] in universal_all_iphone |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import os | ||
import tempfile | ||
import shutil | ||
from unittest import mock | ||
|
||
import pytest | ||
|
||
from angle_builder.depot_tools import DepotTools | ||
from angle_builder.storage import StorageFolderManager | ||
|
||
|
||
@pytest.fixture | ||
def depot_tools(request): | ||
_tmpdir = tempfile.mkdtemp() | ||
_storage_manager = StorageFolderManager( | ||
user_path=os.path.join(_tmpdir, "storage") | ||
) | ||
_depot_tools = DepotTools(storage_manager=_storage_manager) | ||
|
||
def finalizer(): | ||
shutil.rmtree(_tmpdir) | ||
|
||
request.addfinalizer(finalizer) | ||
|
||
return _depot_tools | ||
|
||
|
||
def test_depot_tools_path(depot_tools): | ||
expected_path = os.path.join( | ||
depot_tools.storage_manager.folder_path, "depot_tools" | ||
) | ||
assert depot_tools.depot_tools_path == expected_path | ||
|
||
|
||
def test_ensure_depot_tools_cloned(depot_tools): | ||
# Just check that the folder exists | ||
with mock.patch( | ||
"angle_builder.depot_tools.DepotTools._clone_darwin_linux" | ||
) as _m__clone_darwin_linux: | ||
depot_tools.ensure_depot_tools() | ||
_m__clone_darwin_linux.assert_called_once() | ||
|
||
|
||
def test_ensure_depot_tools_is_in_path(depot_tools): | ||
with mock.patch( | ||
"angle_builder.depot_tools.DepotTools._clone_darwin_linux" | ||
) as _m__clone_darwin_linux: | ||
depot_tools.ensure_depot_tools() | ||
_m__clone_darwin_linux.assert_called_once() | ||
_path_content = os.environ["PATH"].split(os.pathsep) | ||
assert depot_tools.depot_tools_path in _path_content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import os | ||
import tempfile | ||
import shutil | ||
|
||
import pytest | ||
|
||
from angle_builder.storage import StorageFolderManager | ||
|
||
|
||
@pytest.fixture | ||
def storage_manager(request): | ||
_tmpdir = tempfile.mkdtemp() | ||
_storage_manager = StorageFolderManager( | ||
user_path=os.path.join(_tmpdir, "storage") | ||
) | ||
|
||
def finalizer(): | ||
shutil.rmtree(_tmpdir) | ||
|
||
request.addfinalizer(finalizer) | ||
|
||
return _storage_manager | ||
|
||
|
||
def test_ensure_folder_not_exists(storage_manager): | ||
""" | ||
Ensure that the storage folder is created if it does not exist. | ||
""" | ||
assert os.path.exists(storage_manager.folder_path) is False | ||
storage_manager.ensure_folder() | ||
assert os.path.exists(storage_manager.folder_path) is True | ||
|
||
|
||
def test_ensure_folder_exists(storage_manager): | ||
""" | ||
Ensure that the storage folder is kept if it exists. | ||
""" | ||
assert os.path.exists(storage_manager.folder_path) is False | ||
storage_manager.ensure_folder() | ||
assert os.path.exists(storage_manager.folder_path) is True | ||
storage_manager.ensure_folder() | ||
assert os.path.exists(storage_manager.folder_path) is True | ||
|
||
|
||
def test_delete_folder(storage_manager): | ||
""" | ||
Ensure that the storage folder is deleted. | ||
""" | ||
assert os.path.exists(storage_manager.folder_path) is False | ||
storage_manager.ensure_folder() | ||
assert os.path.exists(storage_manager.folder_path) is True | ||
storage_manager.delete_folder() | ||
assert os.path.exists(storage_manager.folder_path) is False | ||
|
||
|
||
def test_delete_not_existing_folder(storage_manager): | ||
""" | ||
Ensure that the storage folder is not deleted if it does not exist. | ||
""" | ||
assert os.path.exists(storage_manager.folder_path) is False | ||
storage_manager.delete_folder() | ||
assert os.path.exists(storage_manager.folder_path) is False |