This repository has been archived by the owner on Jan 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup script to apply to android plus somewhere to put it's tests
- Loading branch information
Showing
9 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
Empty file.
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,33 @@ | ||
from pathlib import Path | ||
import sys | ||
|
||
|
||
def _require_exists(a_file: Path) -> Path: | ||
if not a_file.is_file(): | ||
raise ValueError(f"{a_file} not found") | ||
return a_file | ||
|
||
|
||
def _fonts_xml(android_dir: Path) -> Path: | ||
return _require_exists(android_dir / "frameworks" / "base" / "data" / "fonts" / "fonts.xml") | ||
|
||
|
||
def _fonts_mk(android_dir: Path) -> Path: | ||
return _require_exists(android_dir / "external" / "noto-fonts" / "fonts.mk") | ||
|
||
|
||
def _validate_android_path(android_dir: Path): | ||
assert android_dir.is_dir(), f"{android_dir} should be a directory" | ||
_fonts_xml(android_dir) # just to trigger it's checks | ||
_fonts_mk(android_dir) # just to trigger it's checks | ||
|
||
|
||
def main(): | ||
if len(sys.argv) != 2: | ||
raise ValueError("Must have one arg, path to an Android checkout") | ||
android_dir = Path(sys.argv[1]) | ||
_validate_android_path(android_dir) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
File renamed without changes.
File renamed without changes.
Empty file.
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,20 @@ | ||
from android_connection import apply_to_android | ||
from pathlib import Path | ||
import pytest | ||
|
||
|
||
def _testdata_dir() -> Path: | ||
return Path(__file__).parent / "testdata" | ||
|
||
|
||
def _fake_android_dir() -> Path: | ||
return _testdata_dir() / "fake_android" | ||
|
||
|
||
def test_apply_to_bad_dir(): | ||
with pytest.raises(ValueError, match="not found"): | ||
apply_to_android._validate_android_path(_testdata_dir()) | ||
|
||
|
||
def test_apply_to_good_dir(): | ||
apply_to_android._validate_android_path(_fake_android_dir()) |
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
Empty file.
Empty file.