Skip to content

Resolve absolute path to local recipes #2640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pythonforandroid/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ def add_parser(subparsers, *args, **kwargs):

self._archs = args.arch

self.ctx.local_recipes = args.local_recipes
self.ctx.local_recipes = realpath(args.local_recipes)
self.ctx.copy_libs = args.copy_libs

self.ctx.activity_class_name = args.activity_class_name
Expand Down
32 changes: 32 additions & 0 deletions tests/test_toolchain.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import io
import os
import sys
import pytest
from unittest import mock
Expand Down Expand Up @@ -136,3 +137,34 @@ def test_recipes(self):
assert expected_string in m_stdout.getvalue()
# deletes static attribute to not mess with other tests
del Recipe.recipes

def test_local_recipes_dir(self):
"""
Checks the `local_recipes` attribute in the Context is absolute.
"""
cwd = os.path.realpath(os.getcwd())
common_args = [
'toolchain.py',
'recommendations',
]

# Check the default ./p4a-recipes becomes absolute.
argv = common_args
with patch_sys_argv(argv):
toolchain = ToolchainCL()
expected_local_recipes = os.path.join(cwd, 'p4a-recipes')
assert toolchain.ctx.local_recipes == expected_local_recipes

# Check a supplied relative directory becomes absolute.
argv = common_args + ['--local-recipes=foo']
with patch_sys_argv(argv):
toolchain = ToolchainCL()
expected_local_recipes = os.path.join(cwd, 'foo')
assert toolchain.ctx.local_recipes == expected_local_recipes

# An absolute directory should remain unchanged.
local_recipes = os.path.join(cwd, 'foo')
argv = common_args + ['--local-recipes={}'.format(local_recipes)]
with patch_sys_argv(argv):
toolchain = ToolchainCL()
assert toolchain.ctx.local_recipes == local_recipes