Browse Source

test rename: test.py -> cmdtest.py

The MMGen Project 7 months ago
parent
commit
666b27c042

+ 5 - 5
test/test_py_d/cfg.py → test/cmdtest_py_d/cfg.py

@@ -9,16 +9,16 @@
 #   https://gitlab.com/mmgen/mmgen-node-tools
 
 """
-test.test_py_d.cfg: configuration data for test.py
+test.cmdtest_py_d.cfg: configuration data for cmdtest.py
 """
 
 import os
 
 cmd_groups_dfl = {
-	'main':        ('TestSuiteMain',{}),
-	'helpscreens': ('TestSuiteHelp',{'modname':'misc','full_data':True}),
-	'scripts':     ('TestSuiteScripts',{'modname':'misc'}),
-	'regtest':     ('TestSuiteRegtest',{}),
+	'main':        ('CmdTestMain',{}),
+	'helpscreens': ('CmdTestHelp',{'modname':'misc','full_data':True}),
+	'scripts':     ('CmdTestScripts',{'modname':'misc'}),
+	'regtest':     ('CmdTestRegtest',{}),
 }
 
 cmd_groups_extra = {}

+ 3 - 3
test/test_py_d/ts_main.py → test/cmdtest_py_d/ct_main.py

@@ -9,15 +9,15 @@
 #   https://gitlab.com/mmgen/mmgen
 
 """
-test_py_d.ts_main: Basic operations tests for the test.py test suite
+cmdtest_py_d.ct_main: Basic operations tests for the cmdtest.py test suite
 """
 
 import sys,time
 
 from ..include.common import cfg
-from .ts_base import TestSuiteBase
+from .ct_base import CmdTestBase
 
-class TestSuiteMain(TestSuiteBase):
+class CmdTestMain(CmdTestBase):
 	'basic operations with fake RPC data'
 	tmpdir_nums = [3]
 	networks = ('btc',) # fake data, so test peerblocks for BTC mainnet only

+ 4 - 4
test/test_py_d/ts_misc.py → test/cmdtest_py_d/ct_misc.py

@@ -9,17 +9,17 @@
 #   https://gitlab.com/mmgen/mmgen-node-tools
 
 """
-test.test_py_d.ts_misc: Miscellaneous test groups for the test.py test suite
+test.cmdtest_py_d.ct_misc: Miscellaneous test groups for the cmdtest.py test suite
 """
 
 import os,shutil
 
 from ..include.common import cfg
-from .ts_base import TestSuiteBase
+from .ct_base import CmdTestBase
 
 refdir = os.path.join('test','ref','ticker')
 
-class TestSuiteHelp(TestSuiteBase):
+class CmdTestHelp(CmdTestBase):
 	'help, info and usage screens'
 	networks = ('btc','ltc','bch')
 	tmpdir_nums = []
@@ -52,7 +52,7 @@ class TestSuiteHelp(TestSuiteBase):
 	def longhelpscreens(self):
 		return self.helpscreens(arg='--longhelp',expect='USAGE:.*LONG OPTIONS:')
 
-class TestSuiteScripts(TestSuiteBase):
+class CmdTestScripts(CmdTestBase):
 	'scripts not requiring a coin daemon'
 	networks = ('btc',)
 	tmpdir_nums = [2]

+ 4 - 4
test/test_py_d/ts_regtest.py → test/cmdtest_py_d/ct_regtest.py

@@ -9,7 +9,7 @@
 #   https://gitlab.com/mmgen/mmgen-node-tools
 
 """
-test.test_py_d.ts_regtest: Regtest tests for the test.py test suite
+test.cmdtest_py_d.ct_regtest: Regtest tests for the cmdtest.py test suite
 """
 
 import os
@@ -19,7 +19,7 @@ from mmgen.protocol import init_proto
 from mmgen.proto.btc.regtest import MMGenRegtest
 
 from ..include.common import cfg,imsg,stop_test_daemons,joinpath
-from .ts_base import TestSuiteBase
+from .ct_base import CmdTestBase
 
 args1 = ['--bob']
 args2 = ['--bob','--rpc-backend=http']
@@ -31,7 +31,7 @@ def gen_addrs(proto,network,keys):
 	tool.addrtype = proto.mmtypes[-1]
 	return [tool.privhex2addr('{:064x}'.format(key)) for key in keys]
 
-class TestSuiteRegtest(TestSuiteBase):
+class CmdTestRegtest(CmdTestBase):
 	'various operations via regtest mode'
 	networks = ('btc','ltc','bch')
 	passthru_opts = ('coin',)
@@ -104,7 +104,7 @@ class TestSuiteRegtest(TestSuiteBase):
 	}
 
 	def __init__(self,trunner,cfgs,spawn):
-		TestSuiteBase.__init__(self,trunner,cfgs,spawn)
+		CmdTestBase.__init__(self,trunner,cfgs,spawn)
 		if trunner == None:
 			return
 		if self.proto.testnet:

+ 42 - 23
test/init.sh

@@ -45,37 +45,56 @@ build_mmgen_extmod() {
 }
 
 create_dir_links() {
-	for target in 'mmgen' 'scripts'; do
-		src="$mm_repo/$target"
-		if [ -e $target ]; then
-			[ $(realpath --relative-to=. $target) == $src ] || die "'$target' does not point to '$src'"
+	for link_name in 'mmgen' 'scripts'; do
+		target="$mm_repo/$link_name"
+		if [ -e $link_name ]; then
+			[ $(realpath --relative-to=. $link_name) == $target ] || die "'$link_name' does not point to '$target'"
 		else
-			echo "Creating symlink: $target"
-			ln -s $src
+			echo "Creating symlink: $link_name"
+			ln -s $target
 		fi
 	done
 }
 
 create_test_links() {
-	sources='
-		test/include
-		test/overlay/__init__.py
-		test/overlay/fakemods/mmgen
-		test/__init__.py
-		test/test.py
-		test/unit_tests.py
-		test/test-release.sh
-		test/test_py_d/common.py
-		test/test_py_d/ts_base.py
-		cmds/mmgen-regtest
+	paths='
+		test/include                   symbolic
+		test/overlay/__init__.py       symbolic
+		test/overlay/fakemods/mmgen    symbolic
+		test/__init__.py               symbolic
+		test/cmdtest.py                hard
+		test/unit_tests.py             hard
+		test/test-release.sh           symbolic
+		test/cmdtest_py_d/common.py    symbolic
+		test/cmdtest_py_d/ct_base.py   symbolic
+		cmds/mmgen-regtest             symbolic
 	'
-	for src in $sources; do
-		pfx=$(echo $src | sed -r 's/[^/]//g' | sed 's/\//..\//g')
-		if [ ! -e $src ]; then
-			echo "Creating symlink: $src"
-			( cd "$(dirname $src)" && ln -s "$pfx$mm_repo/$src" )
+	while read path type; do
+		[ "$path" ] || continue
+		pfx=$(echo $path | sed -r 's/[^/]//g' | sed 's/\//..\//g')
+		symlink_arg=$(if [ $type == 'symbolic' ]; then echo --symbolic; fi)
+		target="$mm_repo/$path"
+		if [ ! -e "$target" ]; then
+			echo "Target path $target is missing! Cannot proceed"
+			exit 1
 		fi
-	done
+		fs="%-8s %-16s %s -> %s\n"
+		if [ $type == 'hard' ]; then
+			if [ -L $path ]; then
+				printf "$fs" "Deleting" "symbolic link:" $path $target
+				rm -rf $path
+			elif [ -e $path ]; then
+				if [ "$(stat --printf=%i $path)" -ne "$(stat --printf=%i $target)" ]; then
+					printf "$fs" "Deleting" "stale hard link:" $path "?"
+					rm -rf $path
+				fi
+			fi
+		fi
+		if [ ! -e $path ]; then # link is either absent or a broken symlink
+			printf "$fs" "Creating" "$type link:" $path $target
+			( cd "$(dirname $path)" && ln -f $symlink_arg $pfx$target )
+		fi
+	done <<<$paths
 }
 
 set -e

+ 6 - 6
test/test-release.d/cfg.sh

@@ -41,20 +41,20 @@ init_tests() {
 	t_unit="- $unit_tests_py"
 
 	d_misc="miscellaneous features"
-	t_misc="- $test_py helpscreens"
+	t_misc="- $cmdtest_py helpscreens"
 
 	d_scripts="scripts not requiring a coin daemon"
-	t_scripts="- $test_py scripts"
+	t_scripts="- $cmdtest_py scripts"
 
 	d_btc="Bitcoin with emulated RPC data"
-	t_btc="- $test_py main"
+	t_btc="- $cmdtest_py main"
 
 	d_btc_rt="Bitcoin regtest"
-	t_btc_rt="- $test_py regtest"
+	t_btc_rt="- $cmdtest_py regtest"
 
 	d_bch_rt="Bitcoin Cash Node (BCH) regtest"
-	t_bch_rt="- $test_py --coin=bch regtest"
+	t_bch_rt="- $cmdtest_py --coin=bch regtest"
 
 	d_ltc_rt="Litecoin regtest"
-	t_ltc_rt="- $test_py --coin=ltc regtest"
+	t_ltc_rt="- $cmdtest_py --coin=ltc regtest"
 }