Browse Source

MSWin/MSYS2 testing fixes

The MMGen Project 1 year ago
parent
commit
f97869702d

+ 1 - 1
mmgen/data/version

@@ -1 +1 @@
-13.3.dev55
+13.3.dev56

+ 6 - 1
mmgen/term.py

@@ -272,7 +272,12 @@ class MMGenTermMSWinStub(MMGenTermMSWin):
 		Use stdin to allow UTF-8 and emulate the one-character behavior of MMGenTermMSWin
 		"""
 		msg_r(prompt)
-		return sys.stdin.read(1)
+		while True:
+			try:
+				return sys.stdin.read(1)
+			except:
+				msg('[read error, trying again]')
+				time.sleep(0.5)
 
 	get_char_raw = get_char
 

+ 3 - 1
mmgen/tw/json.py

@@ -54,7 +54,9 @@ class TwJSON:
 				from ..addrlist import AddrIdxList
 				prune_id = AddrIdxList(idx_list=self.pruned).id_str
 				fn = get_fn(prune_id)
-				if len(fn) > os.statvfs(self.cfg.outdir or os.curdir).f_namemax:
+				from ..cfg import gc
+				mf = 255 if gc.platform == 'win' else os.statvfs(self.cfg.outdir or os.curdir).f_namemax
+				if len(fn) > mf:
 					fn = get_fn(f'idhash={make_chksum_8(prune_id.encode()).lower()}')
 			else:
 				fn = get_fn(None)

+ 1 - 1
mmgen/xmrwallet.py

@@ -22,7 +22,7 @@ xmrwallet.py - MoneroWalletOps class
 
 import re,time,json,atexit
 from collections import namedtuple
-from pathlib import PosixPath as Path
+from pathlib import Path
 
 from .objmethods import MMGenObject,Hilite,InitErrors
 from .obj import CoinTxID,Int

+ 4 - 0
test/test.py

@@ -672,6 +672,10 @@ class TestSuiteRunner(object):
 
 		ts_cls = CmdGroupMgr().load_mod(gname)
 
+		if gc.platform == 'win' and ts_cls.win_skip:
+			omsg(f'Skipping test {gname!r} for Windows platform')
+			return False
+
 		for k in ('segwit','segwit_random','bech32'):
 			if getattr(cfg,k):
 				segwit_opt = k

+ 2 - 1
test/test_py_d/common.py

@@ -116,7 +116,8 @@ def get_file_with_ext(tdir,ext,delete=True,no_dot=False,return_list=False,delete
 			or fn.endswith( dot + ext )
 			or (substr and ext in fn) )
 
-	flist = [f.path for f in os.scandir(tdir) if have_match(f.name)]
+	# Don’t use os.scandir here - it returns broken paths under Windows/MSYS2
+	flist = [os.path.join(tdir,name) for name in os.listdir(tdir) if have_match(name)]
 
 	if not flist:
 		return False

+ 1 - 3
test/test_py_d/ts_autosign.py

@@ -81,6 +81,7 @@ class TestSuiteAutosignBase(TestSuiteBase):
 	color        = True
 	mountpoint_basename = 'mmgen_autosign'
 	no_insert_check = True
+	win_skip = True
 
 	def __init__(self,trunner,cfgs,spawn):
 
@@ -89,9 +90,6 @@ class TestSuiteAutosignBase(TestSuiteBase):
 		if trunner == None:
 			return
 
-		if gc.platform == 'win':
-			die(1,f'Test {self.name} not supported for Windows platform')
-
 		self.network_ids = [c+'_tn' for c in self.daemon_coins] + self.daemon_coins
 
 		if not self.live:

+ 1 - 0
test/test_py_d/ts_base.py

@@ -34,6 +34,7 @@ class TestSuiteBase:
 	segwit_opts_ok = False
 	color = False
 	need_daemon = False
+	win_skip = False
 
 	def __init__(self,trunner,cfgs,spawn):
 		if hasattr(self,'tr'): # init will be called multiple times for classes with multiple inheritance

+ 3 - 0
test/test_py_d/ts_misc.py

@@ -182,6 +182,9 @@ class TestSuiteHelp(TestSuiteBase):
 		if self.proto.coin not in ('BTC','XMR') and 'xmrwallet' in scripts:
 			scripts.remove('xmrwallet')
 
+		if gc.platform == 'win' and 'autosign' in scripts:
+			scripts.remove('autosign')
+
 		for s in sorted(scripts):
 			t = self.spawn(f'mmgen-{s}',[arg],extra_desc=f'(mmgen-{s})')
 			t.expect(expect,regex=True)

+ 1 - 0
test/test_py_d/ts_xmr_autosign.py

@@ -47,6 +47,7 @@ class TestSuiteXMRAutosign(TestSuiteXMRWallet,TestSuiteAutosignBase):
 	bad_tx_count = 0
 	tx_relay_user = 'miner'
 	no_insert_check = False
+	win_skip = True
 
 	cmd_group = (
 		('daemon_version',           'checking daemon version'),

+ 6 - 3
test/test_py_d/ts_xmrwallet.py

@@ -60,10 +60,11 @@ class TestSuiteXMRWallet(TestSuiteBase):
 	dfl_random_txs = 3
 	color = True
 	socks_port = 49237
+	# Bob’s daemon is stopped via process kill, not RPC, so put Bob last in list:
 	user_data = (
 		('miner', '98831F3A', False, 130, '1-2', []),
-		('bob',   '1378FC64', False, 140, None,  ['--restricted-rpc']),
 		('alice', 'FE3C6545', False, 150, '1-4', []),
+		('bob',   '1378FC64', False, 140, None,  ['--restricted-rpc']),
 	)
 	tx_relay_user = 'bob'
 	datadir_base = os.path.join('test','daemons','xmrtest')
@@ -814,9 +815,11 @@ class TestSuiteXMRWallet(TestSuiteBase):
 		h = await self._get_height()
 		imsg_r(f'Chain height: {h} ')
 
-		for count in range(50):
+		max_iterations,height_threshold = (300,80) if gc.platform == 'win' else (50,300)
+
+		for count in range(max_iterations):
 			bal_info = await get_balance(dest,count)
-			if h > 300 and (dest.test(bal_info) is True or ( chk_bal_chg and bal_info.ub != bal_info_start.ub )):
+			if h > height_threshold and (dest.test(bal_info) is True or ( chk_bal_chg and bal_info.ub != bal_info_start.ub )):
 				imsg('')
 				oqmsg_r('+')
 				print_balance(dest,bal_info)

+ 7 - 4
test/unit_tests_d/ut_rpc.py

@@ -211,14 +211,17 @@ class unit_tests:
 					filename = fn,
 					password = 'foo',
 					seed     = xmrseed().fromhex('beadface'*8,tostr=True) )
+
+				if gc.platform == 'win':
+					wd.stop()
+					wd.start()
+
 				qmsg(f'Opening {wd.network} wallet')
 				c.call( 'open_wallet', filename=fn, password='foo' )
 
-			for md,wd in daemons:
-				wd.wait = False
-				await wd.rpc.stop_daemon()
+				await c.stop_daemon()
+
 				if not cfg.no_daemon_stop:
-					md.wait = False
 					await md.rpc.stop_daemon()
 
 			gmsg('OK')