Merge branch 'build_tools_tests' into 'master'
Build tools tests See merge request fdroid/fdroidserver!834
This commit is contained in:
commit
2a265cbc0b
|
@ -31,9 +31,6 @@
|
|||
# java_paths:
|
||||
# 8: /usr/lib/jvm/java-8-openjdk
|
||||
|
||||
# Build tools version to be used
|
||||
# build_tools: 28.0.3
|
||||
|
||||
# Command or path to binary for running Ant
|
||||
# ant: ant
|
||||
|
||||
|
|
|
@ -115,7 +115,6 @@ default_config = {
|
|||
'r16b': None,
|
||||
},
|
||||
'cachedir': os.path.join(os.getenv('HOME'), '.cache', 'fdroidserver'),
|
||||
'build_tools': MINIMUM_APKSIGNER_BUILD_TOOLS_VERSION,
|
||||
'java_paths': None,
|
||||
'scan_binary': False,
|
||||
'ant': "ant",
|
||||
|
@ -501,18 +500,11 @@ def find_sdk_tools_cmd(cmd):
|
|||
tooldirs = []
|
||||
if config is not None and 'sdk_path' in config and os.path.exists(config['sdk_path']):
|
||||
# try to find a working path to this command, in all the recent possible paths
|
||||
if 'build_tools' in config:
|
||||
build_tools = os.path.join(config['sdk_path'], 'build-tools')
|
||||
# if 'build_tools' was manually set and exists, check only that one
|
||||
configed_build_tools = os.path.join(build_tools, config['build_tools'])
|
||||
if os.path.exists(configed_build_tools):
|
||||
tooldirs.append(configed_build_tools)
|
||||
else:
|
||||
# no configed version, so hunt known paths for it
|
||||
for f in sorted(os.listdir(build_tools), reverse=True):
|
||||
if os.path.isdir(os.path.join(build_tools, f)):
|
||||
tooldirs.append(os.path.join(build_tools, f))
|
||||
tooldirs.append(build_tools)
|
||||
build_tools = os.path.join(config['sdk_path'], 'build-tools')
|
||||
if os.path.isdir(build_tools):
|
||||
for f in sorted(os.listdir(build_tools), reverse=True):
|
||||
if os.path.isdir(os.path.join(build_tools, f)):
|
||||
tooldirs.append(os.path.join(build_tools, f))
|
||||
sdk_tools = os.path.join(config['sdk_path'], 'tools')
|
||||
if os.path.exists(sdk_tools):
|
||||
tooldirs.append(sdk_tools)
|
||||
|
@ -528,7 +520,8 @@ def find_sdk_tools_cmd(cmd):
|
|||
test_aapt_version(path)
|
||||
return path
|
||||
# did not find the command, exit with error message
|
||||
ensure_build_tools_exists(config)
|
||||
if not test_sdk_exists(config):
|
||||
raise FDroidException(_("Android SDK not found!"))
|
||||
|
||||
|
||||
def test_aapt_version(aapt):
|
||||
|
@ -581,17 +574,6 @@ def test_sdk_exists(thisconfig):
|
|||
return True
|
||||
|
||||
|
||||
def ensure_build_tools_exists(thisconfig):
|
||||
if not test_sdk_exists(thisconfig):
|
||||
raise FDroidException(_("Android SDK not found!"))
|
||||
build_tools = os.path.join(thisconfig['sdk_path'], 'build-tools')
|
||||
versioned_build_tools = os.path.join(build_tools, thisconfig['build_tools'])
|
||||
if not os.path.isdir(versioned_build_tools):
|
||||
raise FDroidException(
|
||||
_("Android build-tools path '{path}' does not exist!")
|
||||
.format(path=versioned_build_tools))
|
||||
|
||||
|
||||
def get_local_metadata_files():
|
||||
'''get any metadata files local to an app's source repo
|
||||
|
||||
|
|
|
@ -28,23 +28,10 @@ import fdroidserver.scanner
|
|||
class BuildTest(unittest.TestCase):
|
||||
'''fdroidserver/build.py'''
|
||||
|
||||
def _set_build_tools(self):
|
||||
build_tools = os.path.join(fdroidserver.common.config['sdk_path'], 'build-tools')
|
||||
if os.path.exists(build_tools):
|
||||
fdroidserver.common.config['build_tools'] = ''
|
||||
for f in sorted(os.listdir(build_tools), reverse=True):
|
||||
versioned = os.path.join(build_tools, f)
|
||||
if os.path.isdir(versioned) \
|
||||
and os.path.isfile(os.path.join(versioned, 'aapt')):
|
||||
fdroidserver.common.config['build_tools'] = versioned
|
||||
break
|
||||
return True
|
||||
else:
|
||||
print('no build-tools found: ' + build_tools)
|
||||
return False
|
||||
|
||||
def setUp(self):
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
logger = logging.getLogger('androguard.axml')
|
||||
logger.setLevel(logging.INFO) # tame the axml debug messages
|
||||
self.basedir = os.path.join(localmodule, 'tests')
|
||||
self.tmpdir = os.path.abspath(os.path.join(self.basedir, '..', '.testfiles'))
|
||||
if not os.path.exists(self.tmpdir):
|
||||
|
@ -56,7 +43,6 @@ class BuildTest(unittest.TestCase):
|
|||
fdroidserver.common.fill_config_defaults(config)
|
||||
fdroidserver.common.config = config
|
||||
fdroidserver.build.config = config
|
||||
self._set_build_tools()
|
||||
try:
|
||||
config['aapt'] = fdroidserver.common.find_sdk_tools_cmd('aapt')
|
||||
except fdroidserver.exception.FDroidException:
|
||||
|
@ -183,7 +169,6 @@ class BuildTest(unittest.TestCase):
|
|||
config = dict()
|
||||
config['sdk_path'] = os.getenv('ANDROID_HOME')
|
||||
config['ndk_paths'] = {'r10d': os.getenv('ANDROID_NDK_HOME')}
|
||||
config['build_tools'] = 'FAKE_BUILD_TOOLS_VERSION'
|
||||
fdroidserver.common.config = config
|
||||
app = fdroidserver.metadata.App()
|
||||
app.id = 'com.gpl.rpg.AndorsTrail'
|
||||
|
|
|
@ -42,6 +42,8 @@ class CommonTest(unittest.TestCase):
|
|||
|
||||
def setUp(self):
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
logger = logging.getLogger('androguard.axml')
|
||||
logger.setLevel(logging.INFO) # tame the axml debug messages
|
||||
self.basedir = os.path.join(localmodule, 'tests')
|
||||
self.tmpdir = os.path.abspath(os.path.join(self.basedir, '..', '.testfiles'))
|
||||
if not os.path.exists(self.tmpdir):
|
||||
|
@ -75,12 +77,10 @@ class CommonTest(unittest.TestCase):
|
|||
def _set_build_tools(self):
|
||||
build_tools = os.path.join(fdroidserver.common.config['sdk_path'], 'build-tools')
|
||||
if os.path.exists(build_tools):
|
||||
fdroidserver.common.config['build_tools'] = ''
|
||||
for f in sorted(os.listdir(build_tools), reverse=True):
|
||||
versioned = os.path.join(build_tools, f)
|
||||
if os.path.isdir(versioned) \
|
||||
and os.path.isfile(os.path.join(versioned, 'apksigner')):
|
||||
fdroidserver.common.config['build_tools'] = versioned
|
||||
break
|
||||
return True
|
||||
else:
|
||||
|
@ -235,7 +235,6 @@ class CommonTest(unittest.TestCase):
|
|||
config = dict()
|
||||
config['sdk_path'] = os.getenv('ANDROID_HOME')
|
||||
config['ndk_paths'] = {'r10d': os.getenv('ANDROID_NDK_HOME')}
|
||||
config['build_tools'] = 'FAKE_BUILD_TOOLS_VERSION'
|
||||
fdroidserver.common.config = config
|
||||
app = fdroidserver.metadata.App()
|
||||
app.id = 'org.fdroid.froid'
|
||||
|
@ -715,9 +714,10 @@ class CommonTest(unittest.TestCase):
|
|||
fdroidserver.common.fill_config_defaults(config)
|
||||
fdroidserver.common.config = config
|
||||
self._set_build_tools()
|
||||
aapt = fdroidserver.common.find_sdk_tools_cmd('aapt')
|
||||
if aapt:
|
||||
try:
|
||||
config['aapt'] = fdroidserver.common.find_sdk_tools_cmd('aapt')
|
||||
except fdroidserver.exception.FDroidException:
|
||||
pass # aapt is not required if androguard is present
|
||||
|
||||
testcases = [
|
||||
('repo/obb.main.twoversions_1101613.apk', 'obb.main.twoversions', '1101613', '0.1'),
|
||||
|
|
|
@ -59,7 +59,6 @@ class VCSTest(unittest.TestCase):
|
|||
os.mkdir("build")
|
||||
config['sdk_path'] = 'MOCKPATH'
|
||||
config['ndk_paths'] = {'r10d': os.getenv('ANDROID_NDK_HOME')}
|
||||
config['build_tools'] = 'FAKE_BUILD_TOOLS_VERSION'
|
||||
config['java_paths'] = {'fake': 'fake'}
|
||||
fdroidserver.common.config = config
|
||||
app = fdroidserver.metadata.App()
|
||||
|
|
Loading…
Reference in New Issue