integrated with master branch with the tests package in lbrynet
This commit is contained in:
parent
32479e70fc
commit
92410beb4f
8 changed files with 231 additions and 32 deletions
|
@ -36,7 +36,7 @@ version = 0.1
|
|||
|
||||
# (list) Application requirements
|
||||
# comma seperated e.g. requirements = sqlite3,kivy
|
||||
requirements = openssl, sqlite3, hostpython2, pycrypto==2.6.1, android, pyjnius, constantly, incremental, functools32, miniupnpc==1.9, gmpy==1.17, twisted==16.6.0, appdirs==1.4.3, argparse==1.2.1, docopt==0.6.2, base58==0.2.2, colorama==0.3.7, dnspython==1.12.0, ecdsa==0.13, envparse==0.2.0, jsonrpc==1.2, jsonrpclib==0.1.7, jsonschema==2.5.1, pbkdf2==1.3, pycrypto==2.6.1, pyyaml==3.12, qrcode==5.2.2, requests==2.9.1, txrequests==0.9.5, seccure==0.3.1.3, service_identity==16.0.0, six==1.9.0, slowaes==0.1a1, txJSON-RPC==0.5, wsgiref==0.1.2, zope.interface==4.3.3, protobuf==3.2.0, git+https://github.com/lbryio/lbryschema.git#egg=lbryschema, git+https://github.com/lbryio/lbryum.git#egg=lbryum, git+https://github.com/lbryio/lbry.git#egg=lbrynet, funcsigs, mock, pbr, unqlite, git+https://github.com/akinwale/lbry#egg=tests
|
||||
requirements = openssl, sqlite3, hostpython2, pycrypto==2.6.1, android, pyjnius, constantly, incremental, functools32, miniupnpc==1.9, gmpy==1.17, twisted==16.6.0, appdirs==1.4.3, argparse==1.2.1, docopt==0.6.2, base58==0.2.2, colorama==0.3.7, dnspython==1.12.0, ecdsa==0.13, envparse==0.2.0, jsonrpc==1.2, jsonrpclib==0.1.7, jsonschema==2.5.1, pbkdf2==1.3, pycrypto==2.6.1, pyyaml==3.12, qrcode==5.2.2, requests==2.9.1, txrequests==0.9.5, seccure==0.3.1.3, service_identity==16.0.0, six==1.9.0, slowaes==0.1a1, txJSON-RPC==0.5, wsgiref==0.1.2, zope.interface==4.3.3, protobuf==3.2.0, git+https://github.com/lbryio/lbryschema.git@v0.0.12rc1#egg=lbryschema, git+https://github.com/lbryio/lbryum.git@v3.1.9rc2#egg=lbryum, git+https://github.com/lbryio/lbry.git#egg=lbrynet, asn1crypto, cryptography==2.0.3, funcsigs, mock, pbr, unqlite
|
||||
|
||||
# (str) Custom source folders for requirements
|
||||
# Sets custom source for any requirements with recipes
|
||||
|
|
|
@ -36,7 +36,7 @@ version = 0.1
|
|||
|
||||
# (list) Application requirements
|
||||
# comma seperated e.g. requirements = sqlite3,kivy
|
||||
requirements = openssl, sqlite3, hostpython2, pycrypto==2.6.1, android, pyjnius, constantly, incremental, functools32, miniupnpc==1.9, gmpy==1.17, twisted==16.6.0, appdirs==1.4.3, argparse==1.2.1, docopt==0.6.2, base58==0.2.2, colorama==0.3.7, dnspython==1.12.0, ecdsa==0.13, envparse==0.2.0, jsonrpc==1.2, jsonrpclib==0.1.7, jsonschema==2.5.1, pbkdf2==1.3, pycrypto==2.6.1, pyyaml==3.12, qrcode==5.2.2, requests==2.9.1, txrequests==0.9.5, seccure==0.3.1.3, service_identity==16.0.0, six==1.9.0, slowaes==0.1a1, txJSON-RPC==0.5, wsgiref==0.1.2, zope.interface==4.3.3, protobuf==3.2.0, git+https://github.com/lbryio/lbryschema.git#egg=lbryschema, git+https://github.com/lbryio/lbryum.git#egg=lbryum, git+https://github.com/lbryio/lbry.git#egg=lbrynet, funcsigs, mock, pbr, unqlite, git+https://github.com/akinwale/lbry#egg=tests
|
||||
requirements = openssl, sqlite3, hostpython2, pycrypto==2.6.1, android, pyjnius, constantly, incremental, functools32, miniupnpc==1.9, gmpy==1.17, twisted==16.6.0, appdirs==1.4.3, argparse==1.2.1, docopt==0.6.2, base58==0.2.2, colorama==0.3.7, dnspython==1.12.0, ecdsa==0.13, envparse==0.2.0, jsonrpc==1.2, jsonrpclib==0.1.7, jsonschema==2.5.1, pbkdf2==1.3, pycrypto==2.6.1, pyyaml==3.12, qrcode==5.2.2, requests==2.9.1, txrequests==0.9.5, seccure==0.3.1.3, service_identity==16.0.0, six==1.9.0, slowaes==0.1a1, txJSON-RPC==0.5, wsgiref==0.1.2, zope.interface==4.3.3, protobuf==3.2.0, git+https://github.com/lbryio/lbryschema.git@v0.0.12rc1#egg=lbryschema, git+https://github.com/lbryio/lbryum.git@v3.1.9rc2#egg=lbryum, git+https://github.com/lbryio/lbry.git#egg=lbrynet, asn1crypto, cryptography==2.0.3, funcsigs, mock, pbr, unqlite
|
||||
|
||||
# (str) Custom source folders for requirements
|
||||
# Sets custom source for any requirements with recipes
|
||||
|
|
36
recipes/cffi/__init__.py
Normal file
36
recipes/cffi/__init__.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
from pythonforandroid.recipe import CompiledComponentsPythonRecipe, Recipe
|
||||
from os.path import join
|
||||
|
||||
|
||||
class CffiRecipe(CompiledComponentsPythonRecipe):
|
||||
name = 'cffi'
|
||||
version = '1.11.0'
|
||||
#url = 'https://pypi.python.org/packages/source/c/cffi/cffi-{version}.tar.gz'
|
||||
url = 'https://pypi.python.org/packages/4e/32/4070bdf32812c89eb635c80880a5caa2e0189aa7999994c265577e5154f3/cffi-{version}.tar.gz'
|
||||
|
||||
depends = [('python2', 'python3crystax'), 'setuptools', 'pycparser', 'libffi']
|
||||
|
||||
patches = ['disable-pkg-config.patch']
|
||||
|
||||
# call_hostpython_via_targetpython = False
|
||||
install_in_hostpython = True
|
||||
|
||||
def get_recipe_env(self, arch=None):
|
||||
env = super(CffiRecipe, self).get_recipe_env(arch)
|
||||
libffi = self.get_recipe('libffi', self.ctx)
|
||||
includes = libffi.get_include_dirs(arch)
|
||||
env['CFLAGS'] = ' -I'.join([env.get('CFLAGS', '')] + includes)
|
||||
env['LDFLAGS'] = (env.get('CFLAGS', '') + ' -L' +
|
||||
self.ctx.get_libs_dir(arch.arch))
|
||||
env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
|
||||
env['PYTHONPATH'] = ':'.join([self.ctx.get_site_packages_dir(), env['BUILDLIB_PATH']])
|
||||
|
||||
target_python = Recipe.get_recipe('python2', self.ctx).get_build_dir(arch.arch)
|
||||
env['PYTHON_ROOT'] = join(target_python, 'python-install')
|
||||
env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python2.7'
|
||||
env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + ' -lpython2.7'
|
||||
|
||||
return env
|
||||
|
||||
|
||||
recipe = CffiRecipe()
|
29
recipes/cffi/disable-pkg-config.patch
Normal file
29
recipes/cffi/disable-pkg-config.patch
Normal file
|
@ -0,0 +1,29 @@
|
|||
diff -Naur cffi-1.4.2/setup.py b/setup.py
|
||||
--- cffi-1.4.2/setup.py 2015-12-21 12:09:47.000000000 -0600
|
||||
+++ b/setup.py 2015-12-23 10:20:40.590622524 -0600
|
||||
@@ -5,8 +5,7 @@
|
||||
|
||||
sources = ['c/_cffi_backend.c']
|
||||
libraries = ['ffi']
|
||||
-include_dirs = ['/usr/include/ffi',
|
||||
- '/usr/include/libffi'] # may be changed by pkg-config
|
||||
+include_dirs = []
|
||||
define_macros = []
|
||||
library_dirs = []
|
||||
extra_compile_args = []
|
||||
@@ -67,14 +66,7 @@
|
||||
sys.stderr.write("The above error message can be safely ignored\n")
|
||||
|
||||
def use_pkg_config():
|
||||
- if sys.platform == 'darwin' and os.path.exists('/usr/local/bin/brew'):
|
||||
- use_homebrew_for_libffi()
|
||||
-
|
||||
- _ask_pkg_config(include_dirs, '--cflags-only-I', '-I', sysroot=True)
|
||||
- _ask_pkg_config(extra_compile_args, '--cflags-only-other')
|
||||
- _ask_pkg_config(library_dirs, '--libs-only-L', '-L', sysroot=True)
|
||||
- _ask_pkg_config(extra_link_args, '--libs-only-other')
|
||||
- _ask_pkg_config(libraries, '--libs-only-l', '-l')
|
||||
+ pass
|
||||
|
||||
def use_homebrew_for_libffi():
|
||||
# We can build by setting:
|
30
recipes/cryptography/__init__.py
Normal file
30
recipes/cryptography/__init__.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
from pythonforandroid.recipe import CompiledComponentsPythonRecipe, Recipe
|
||||
from os.path import dirname, join
|
||||
|
||||
class CryptographyRecipe(CompiledComponentsPythonRecipe):
|
||||
name = 'cryptography'
|
||||
version = '2.0.3'
|
||||
url = 'https://github.com/pyca/cryptography/archive/{version}.tar.gz'
|
||||
depends = [('python2', 'python3crystax'), 'openssl', 'idna', 'pyasn1', 'six', 'setuptools', 'enum34', 'ipaddress', 'cffi']
|
||||
call_hostpython_via_targetpython = False
|
||||
|
||||
def get_recipe_env(self, arch):
|
||||
env = super(CryptographyRecipe, self).get_recipe_env(arch)
|
||||
r = self.get_recipe('openssl', self.ctx)
|
||||
openssl_dir = r.get_build_dir(arch.arch)
|
||||
target_python = Recipe.get_recipe('python2', self.ctx).get_build_dir(arch.arch)
|
||||
env['PYTHON_ROOT'] = self.ctx.get_python_install_dir()
|
||||
env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python2.7' + \
|
||||
' -I' + join(openssl_dir, 'include') + \
|
||||
' -I' + join(target_python, 'Modules/_ctypes/libffi_arm_wince')
|
||||
# Set linker to use the correct gcc
|
||||
env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
|
||||
env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + \
|
||||
' -L' + openssl_dir + \
|
||||
' -lpython2.7' + \
|
||||
' -lssl' + r.version + \
|
||||
' -lcrypto' + r.version
|
||||
|
||||
return env
|
||||
|
||||
recipe = CryptographyRecipe()
|
14
recipes/ipaddress/__init__.py
Normal file
14
recipes/ipaddress/__init__.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
from pythonforandroid.recipe import PythonRecipe
|
||||
|
||||
|
||||
class IpaddressRecipe(PythonRecipe):
|
||||
name = 'ipaddress'
|
||||
version = '1.0.16'
|
||||
url = 'https://pypi.python.org/packages/source/i/ipaddress/ipaddress-{version}.tar.gz'
|
||||
|
||||
depends = ['python2']
|
||||
|
||||
call_hostpython_via_targetpython = False
|
||||
|
||||
|
||||
recipe = IpaddressRecipe()
|
11
recipes/pyasn1/__init__.py
Normal file
11
recipes/pyasn1/__init__.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
from pythonforandroid.toolchain import PythonRecipe
|
||||
|
||||
|
||||
class PyASN1Recipe(PythonRecipe):
|
||||
version = '0.1.8'
|
||||
url = 'https://pypi.python.org/packages/source/p/pyasn1/pyasn1-{version}.tar.gz'
|
||||
depends = ['python2']
|
||||
call_hostpython_via_targetpython = False
|
||||
|
||||
recipe = PyASN1Recipe()
|
|
@ -5,10 +5,11 @@ from twisted.trial.runner import (
|
|||
TestLoader,
|
||||
TrialRunner
|
||||
)
|
||||
from twisted.trial.reporter import VerboseTextReporter
|
||||
from twisted.trial.reporter import TreeReporter
|
||||
from twisted.plugin import getPlugins, IPlugin
|
||||
from jnius import autoclass
|
||||
import tests
|
||||
import lbrynet.tests
|
||||
from os import listdir
|
||||
|
||||
str_stream = StringIO.StringIO()
|
||||
|
||||
|
@ -19,46 +20,124 @@ def update_output_in_activity(str):
|
|||
if service is not None:
|
||||
service.broadcastTestRunnerOutput(str)
|
||||
|
||||
class AndroidTestReporter(VerboseTextReporter):
|
||||
def startTest(self, tm):
|
||||
self._write('%s ... ', tm.id())
|
||||
super(AndroidTestReporter, self).startTest(tm)
|
||||
update_output_in_activity(self._stream.getvalue())
|
||||
|
||||
class AndroidTestReporter(TreeReporter):
|
||||
def addSuccess(self, test):
|
||||
super(AndroidTestReporter, self).addSuccess(test)
|
||||
update_output_in_activity(self._stream.getvalue())
|
||||
|
||||
super(TreeReporter, self).addSuccess(test)
|
||||
self.endLine('[OK]', self.SUCCESS)
|
||||
update_output_in_activity(str_to_basic_html(self._stream.getvalue()))
|
||||
|
||||
def addError(self, *args):
|
||||
super(AndroidTestReporter, self).addError(*args)
|
||||
update_output_in_activity(self._stream.getvalue())
|
||||
super(TreeReporter, self).addError(*args)
|
||||
self.endLine('[ERROR]', self.ERROR)
|
||||
update_output_in_activity(str_to_basic_html(self._stream.getvalue()))
|
||||
|
||||
def addFailure(self, *args):
|
||||
super(AndroidTestReporter, self).addFailure(*args)
|
||||
update_output_in_activity(self._stream.getvalue())
|
||||
|
||||
super(TreeReporter, self).addFailure(*args)
|
||||
self.endLine('[FAIL]', self.FAILURE)
|
||||
update_output_in_activity(str_to_basic_html(self._stream.getvalue()))
|
||||
|
||||
def addSkip(self, *args):
|
||||
super(VerboseTextReporter, self).addSkip(*args)
|
||||
update_output_in_activity(self._stream.getvalue())
|
||||
|
||||
super(TreeReporter, self).addSkip(*args)
|
||||
self.endLine('[SKIPPED]', self.SKIP)
|
||||
update_output_in_activity(str_to_basic_html(self._stream.getvalue()))
|
||||
|
||||
def addExpectedFailure(self, *args):
|
||||
super(AndroidTestReporter, self).addExpectedFailure(*args)
|
||||
update_output_in_activity(self._stream.getvalue())
|
||||
|
||||
super(TreeReporter, self).addExpectedFailure(*args)
|
||||
self.endLine('[TODO]', self.TODO)
|
||||
update_output_in_activity(str_to_basic_html(self._stream.getvalue()))
|
||||
|
||||
def addUnexpectedSuccess(self, *args):
|
||||
super(AndroidTestReporter, self).addUnexpectedSuccess(*args)
|
||||
update_output_in_activity(self._stream.getvalue())
|
||||
super(TreeReporter, self).addUnexpectedSuccess(*args)
|
||||
self.endLine('[SUCCESS!?!]', self.TODONE)
|
||||
update_output_in_activity(str_to_basic_html(self._stream.getvalue()))
|
||||
|
||||
def stopTest(self, test):
|
||||
super(AndroidTestReporter, self).stopTest(test)
|
||||
# TODO: Use appendLine here
|
||||
self._write("<br>"); # html output
|
||||
update_output_in_activity(self._stream.getvalue())
|
||||
def startTest(self, test):
|
||||
super(AndroidTestReporter, self).startTest(test)
|
||||
update_output_in_activity(str_to_basic_html(self._stream.getvalue()))
|
||||
|
||||
def endLine(self, message, color):
|
||||
super(AndroidTestReporter, self).endLine(message, color)
|
||||
update_output_in_activity(str_to_basic_html(self._stream.getvalue()))
|
||||
|
||||
def str_to_basic_html(value):
|
||||
return value.replace("\n", "<br>").replace(" ", ' ')
|
||||
|
||||
def _parseLocalVariables(line):
|
||||
"""
|
||||
Accepts a single line in Emacs local variable declaration format and
|
||||
returns a dict of all the variables {name: value}.
|
||||
Raises ValueError if 'line' is in the wrong format.
|
||||
See http://www.gnu.org/software/emacs/manual/html_node/File-Variables.html
|
||||
"""
|
||||
paren = '-*-'
|
||||
start = line.find(paren) + len(paren)
|
||||
end = line.rfind(paren)
|
||||
if start == -1 or end == -1:
|
||||
raise ValueError("%r not a valid local variable declaration" % (line,))
|
||||
items = line[start:end].split(';')
|
||||
localVars = {}
|
||||
for item in items:
|
||||
if len(item.strip()) == 0:
|
||||
continue
|
||||
split = item.split(':')
|
||||
if len(split) != 2:
|
||||
raise ValueError("%r contains invalid declaration %r"
|
||||
% (line, item))
|
||||
localVars[split[0].strip()] = split[1].strip()
|
||||
return localVars
|
||||
|
||||
def isTestFile(filename):
|
||||
"""
|
||||
Returns true if 'filename' looks like a file containing unit tests.
|
||||
False otherwise. Doesn't care whether filename exists.
|
||||
"""
|
||||
basename = os.path.basename(filename)
|
||||
return (basename.startswith('test_')
|
||||
and os.path.splitext(basename)[1] == ('.py'))
|
||||
|
||||
def loadLocalVariables(filename):
|
||||
"""
|
||||
Accepts a filename and attempts to load the Emacs variable declarations
|
||||
from that file, simulating what Emacs does.
|
||||
See http://www.gnu.org/software/emacs/manual/html_node/File-Variables.html
|
||||
"""
|
||||
with open(filename, "r") as f:
|
||||
lines = [f.readline(), f.readline()]
|
||||
for line in lines:
|
||||
try:
|
||||
return _parseLocalVariables(line)
|
||||
except ValueError:
|
||||
pass
|
||||
return {}
|
||||
|
||||
def getTestModules(filename):
|
||||
testCaseVar = loadLocalVariables(filename).get('test-case-name', None)
|
||||
if testCaseVar is None:
|
||||
return []
|
||||
return testCaseVar.split(',')
|
||||
|
||||
def run():
|
||||
loader = TestLoader();
|
||||
suite = loader.loadPackage(tests, True)
|
||||
suite = loader.loadPackage(lbrynet.tests, True)
|
||||
|
||||
|
||||
filename = '/data/user/0/io.lbry.lbrynet/files/app/lib/python2.7/site-packages/lbrynet/tests'
|
||||
filelist = listdir(filename)
|
||||
print filelist
|
||||
'''
|
||||
tests = []
|
||||
if not os.path.isfile(filename):
|
||||
sys.stderr.write("File %r doesn't exist\n" % (filename,))
|
||||
return
|
||||
|
||||
filename = os.path.abspath(filename)
|
||||
if isTestFile(filename):
|
||||
tests.append(filename)
|
||||
else:
|
||||
tests.extend(getTestModules(filename))
|
||||
|
||||
suite = loader.loadByNames(tests, True)
|
||||
'''
|
||||
runner = TrialRunner(AndroidTestReporter)
|
||||
runner.stream = str_stream
|
||||
passFail = not runner.run(suite).wasSuccessful()
|
||||
|
|
Loading…
Add table
Reference in a new issue