mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-15 03:30:29 +03:00
test new common.regsub_file() method that replaces sed calls
This commit is contained in:
parent
85febd40d1
commit
64a9c93ce7
5 changed files with 815 additions and 0 deletions
65
tests/build.TestCase
Executable file
65
tests/build.TestCase
Executable file
|
|
@ -0,0 +1,65 @@
|
|||
#!/usr/bin/env python2
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# http://www.drdobbs.com/testing/unit-testing-with-python/240165163
|
||||
|
||||
import inspect
|
||||
import optparse
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
localmodule = os.path.realpath(
|
||||
os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), '..'))
|
||||
print('localmodule: ' + localmodule)
|
||||
if localmodule not in sys.path:
|
||||
sys.path.insert(0, localmodule)
|
||||
|
||||
import fdroidserver.build
|
||||
import fdroidserver.common
|
||||
|
||||
|
||||
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 _find_all(self):
|
||||
for cmd in ('aapt', 'adb', 'android', 'zipalign'):
|
||||
path = fdroidserver.common.find_sdk_tools_cmd(cmd)
|
||||
if path is not None:
|
||||
self.assertTrue(os.path.exists(path))
|
||||
self.assertTrue(os.path.isfile(path))
|
||||
|
||||
def test_adapt_gradle(self):
|
||||
teststring = 'FAKE_VERSION_FOR_TESTING'
|
||||
fdroidserver.build.config = {}
|
||||
fdroidserver.build.config['build_tools'] = teststring
|
||||
fdroidserver.build.adapt_gradle(os.path.dirname(__file__))
|
||||
filedata = open(os.path.join(os.path.dirname(__file__), 'build.gradle')).read()
|
||||
self.assertIsNotNone(re.search("\s+buildToolsVersion '%s'\s+" % teststring, filedata))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
||||
help="Spew out even more information than normal")
|
||||
(fdroidserver.common.options, args) = parser.parse_args(['--verbose'])
|
||||
|
||||
newSuite = unittest.TestSuite()
|
||||
newSuite.addTest(unittest.makeSuite(BuildTest))
|
||||
unittest.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue