Build tests into the windows bundle if DEBUG=True is set in pyinstaller spec

This commit is contained in:
Lee Miller 2022-07-28 01:35:48 +03:00
parent 6310fc8919
commit 78e16e61a0
Signed by untrusted user: lee.miller
GPG Key ID: 4F97A5EA88F4AB63
5 changed files with 49 additions and 6 deletions

View File

@ -7,6 +7,7 @@ import time
from PyInstaller.utils.hooks import copy_metadata
DEBUG = False
site_root = os.path.abspath(HOMEPATH)
spec_root = os.path.abspath(SPECPATH)
arch = 32 if ctypes.sizeof(ctypes.c_voidp) == 4 else 64
@ -25,6 +26,10 @@ snapshot = False
hookspath = os.path.join(spec_root, 'hooks')
excludes = ['bsddb', 'bz2', 'tcl', 'tk', 'Tkinter', 'tests']
if not DEBUG:
excludes += ['pybitmessage.tests', 'pyelliptic.tests']
a = Analysis(
[os.path.join(srcPath, 'bitmessagemain.py')],
datas=[
@ -39,7 +44,7 @@ a = Analysis(
'plugins.menu_qrcode', 'plugins.proxyconfig_stem'
],
runtime_hooks=[os.path.join(hookspath, 'pyinstaller_rthook_plugins.py')],
excludes=['bsddb', 'bz2', 'tcl', 'tk', 'Tkinter', 'tests']
excludes=excludes
)
@ -122,10 +127,10 @@ exe = EXE(
a.zipfiles,
a.datas,
name=fname,
debug=False,
debug=DEBUG,
strip=None,
upx=False,
console=False, icon=os.path.join(srcPath, 'images', 'can-icon.ico')
console=DEBUG, icon=os.path.join(srcPath, 'images', 'can-icon.ico')
)
coll = COLLECT(

View File

@ -312,6 +312,9 @@ class Main(object):
try:
# pylint: disable=relative-import
from tests import core as test_core
except ImportError:
try:
from pybitmessage.tests import core as test_core
except ImportError:
self.stop()
return

View File

@ -0,0 +1,8 @@
import sys
if getattr(sys, 'frozen', None):
from test_arithmetic import TestArithmetic
from test_blindsig import TestBlindSig
from test_openssl import TestOpenSSL
__all__ = ["TestArithmetic", "TestBlindSig", "TestOpenSSL"]

View File

@ -0,0 +1,13 @@
import sys
if getattr(sys, 'frozen', None):
from test_addresses import TestAddresses
from test_crypto import TestHighlevelcrypto
from test_l10n import TestL10n
from test_packets import TestSerialize
from test_protocol import TestProtocol
__all__ = [
"TestAddresses", "TestHighlevelcrypto", "TestL10n",
"TestProtocol", "TestSerialize"
]

View File

@ -40,6 +40,7 @@ try:
except (OSError, socket.error):
tor_port_free = False
frozen = getattr(sys, 'frozen', None)
knownnodes_file = os.path.join(state.appdata, 'knownnodes.dat')
@ -298,6 +299,7 @@ class TestCore(unittest.TestCase):
return
self.fail('Failed to find at least 3 nodes to connect within 360 sec')
@unittest.skipIf(frozen, 'skip fragile test')
def test_udp(self):
"""check default udp setting and presence of Announcer thread"""
self.assertTrue(
@ -370,6 +372,7 @@ class TestCore(unittest.TestCase):
'''select typeof(msgid) from sent where ackdata=?''', result)
self.assertEqual(column_type[0][0] if column_type else '', 'text')
@unittest.skipIf(frozen, 'not packed test_pattern into the bundle')
def test_old_knownnodes_pickle(self):
"""Testing old (v0.6.2) version knownnodes.dat file"""
try:
@ -411,10 +414,21 @@ class TestCore(unittest.TestCase):
def run():
"""Starts all tests defined in this module"""
"""Starts all tests intended for core run"""
loader = unittest.defaultTestLoader
loader.sortTestMethodsUsing = None
suite = loader.loadTestsFromTestCase(TestCore)
if frozen:
try:
from pybitmessage import tests
suite.addTests(loader.loadTestsFromModule(tests))
except ImportError:
pass
try:
from pyelliptic import tests
suite.addTests(loader.loadTestsFromModule(tests))
except ImportError:
pass
try:
import bitmessageqt.tests
from xvfbwrapper import Xvfb