Exemplo n.º 1
0
	def __read_control_params(self, fname, section):
		# fname:	Control parameter file name.
		# section:	Control parameter section name.
		cwd = self.dir['solution'].split(os.sep)
		top = len(cwd)
		for n in range(len(cwd)):
			if cwd[n] in ['tests', 'Samples']:
				top = n
		for n in range(top, len(cwd)):
			up = len(cwd) - n - 1
			prefix = ''
			for n in range(up):
				prefix += '..' + os.sep
			if os.path.exists(prefix + fname):
				kvf = KvFile(prefix + fname)
				section = self.ctlfile['section']
				if kvf.read() > 0:
					self.__set_control_values(kvf)
		if self.verbose > 1:
			cs_control_str = ['AUTO', 'USE', 'UNUSE']
			print('\ncontrol_params:')
			print('  Exclude        %s' % self.control['exclude'])
			print('  SolutionAlias  %s' % self.solution)
			print('  OutputDir      %s' % self.dir['output'])
			print('  UseClosedSrc   %s' % self.control['use_closed_src'])
			print('  CS control     %s' %
					cs_control_str[self.control['cs_control']])
			print('  CppMacro       %s' % self.control['cppmacro'])
			print('  Build          %s' % self.control['exe'][self.BLD])
			print('  Run            %s' % self.control['exe'][self.RUN])
			print('  Timeout        %s' % self.control['timeout'])
			print('  ExpectedStatus %s' % self.control['expected'])
			print('  NeedIntervene  %s' % self.control['needintervention'])
			print('  KillProcess    %s' % self.control['killprocess'])
Exemplo n.º 2
0
    def __read_control_file(self, fname, section):
        # arguments:
        #   fname:	Control file name.
        #   section:	Control section name.

        cwd = os.getcwd().split(os.sep)
        siz = len(cwd)
        top = siz
        for n in range(siz):
            if cwd[n] in ['core']:
                top = n + 1
        for n in range(top, siz):
            prefix = '../' * (siz - n - 1)
            if os.path.exists(prefix + fname):
                path = Util.upath(os.path.abspath(prefix + fname))
                if self.verbose:
                    print('read: %s' % path)
                kvf = KvFile(path, verbose=0)
                num_sections = kvf.read(self.control)
                self.__set_control_values(kvf, section)
                """
Exemplo n.º 3
0
#  Find base directory's absolute path.
#
dirlist = os.getcwd().split(os.sep)
found = False
for n in range(len(dirlist)):
	if dirlist[n] == srctop:
		found = True
		break
if not found:
	error.print('no such directory "%s"' % srctop)
topdir = os.sep.join(dirlist[0:n]) if found else None

# ----------------------------------------------------------------------
#  Read name definitions.
#
kvf = KvFile(inifile, sep='=')
count = kvf.read(dic={'TOPDIR': topdir})
if count < 0:
	error.print(kvf.error())
keys = sorted(kvf.keys())

if verbose:
	def fixed(name, width):
		name += ':'
		if len(name) < width-1:
			name += ' ' * (width-len(name))
		return name

	print('names defined (%d):' % count)
	for key in keys:
		value = util.pathconv(kvf.get(key), 'unix')
Exemplo n.º 4
0
    print('%s: Version %s' % (prog, version))
    sys.exit(0)
#
if len(args) != 0:
    parser.error("incorrect number of arguments")

# Scene name
if options.verbose:
    print('  inifile:\t%s' % (options.inifile))

# ----------------------------------------------------------------------
#  Read init file
#
mandatory_keys = ['UnityTestScript', 'Python', 'Springhead2', 'SceneList']

kvf = KvFile(options.inifile)
if (kvf.read() < 0):
    sys.exit(-1)
if kvf.check(mandatory_keys) != 0:
    sys.exit(-1)

# set defaults
defaults = {}
spr2root = kvf.get('Springhead2')
defaults['UnityProject'] = spr2root + '/src/Unity'
defaults['TestRoot'] = spr2root + '/src/UnityTest'
defaults['IniFile'] = defaults['TestRoot'] + '/UnityTest.ini'
defaults['ScenesDir'] = 'Assets/Scenes'
defaults['TestMainLogFile'] = defaults['TestRoot'] + '/log/TestMain.log'
for key in defaults.keys():
    if kvf.get(key) is None:
Exemplo n.º 5
0
# Scene name
scene = args[0]
if scene[-6:] != '.unity':
    scene += '.unity'

if options.verbose:
    print('  inifile:\t%s' % (options.inifile))
    print('  scene:\t%s' % (scene))

# ----------------------------------------------------------------------
#  Read init file
#
mandatory_keys = ['Unity', 'Python', 'Springhead2', 'DllPath']

kvf = KvFile(options.inifile)
if (kvf.read() < 0):
    sys.exit(-1)
if kvf.check(mandatory_keys) != 0:
    sys.exit(-1)

# set defaults
defaults = {}
spr2root = kvf.get('Springhead2')
defaults['UnityProject'] = spr2root + '/src/Unity'
defaults['ScenesDir'] = 'Assets/Scenes'
defaults['TestRoot'] = spr2root + '/scr/UnityTest'
defaults['OutFile'] = defaults['TestRoot'] + '/bin/player.exe'
defaults['LogFile'] = defaults['TestRoot'] + '/log/build.log'
for key in defaults.keys():
    if kvf.get(key) is None:
Exemplo n.º 6
0
    print('  scene:\t%s' % (scene))

# ----------------------------------------------------------------------
#  Globals
#
error = Error(prog)
util = Util()
proc = Proc(verbose=options.exec_trace)
f_op = FileOp(verbose=options.verbose)

# ----------------------------------------------------------------------
#  Read init file
#
mandatory_keys = ['Unity', 'Springhead', 'UnityProject', 'DllPath']

kvf = KvFile(options.inifile)
if (kvf.read() < 0):
    error.print(kvf.error())
if kvf.check(mandatory_keys) != 0:
    error.print(kvf.error())

# set defaults
defaults = {}
spr_root = kvf.get('Springhead')
defaults['ScenesDir'] = 'Assets/Springhead/Samples'
defaults['TestRoot'] = spr_root + '/core/test/UnityTest'
defaults['OutFile'] = defaults['TestRoot'] + '/bin/player.exe'
defaults['LogFile'] = defaults['TestRoot'] + '/log/build.log'
for key in defaults.keys():
    if kvf.get(key) is None:
        kvf.set(key, defaults[key])
Exemplo n.º 7
0
#
dirlist = os.getcwd().split(os.sep)
found = False
for n in range(len(dirlist)):
    if dirlist[n] == srctop:
        found = True
        break
if not found:
    Error(prog).put('no such directory "%s"' % srctop)
##  Absolute path of base directory.
topdir = os.sep.join(dirlist[0:n]) if found else None

# ----------------------------------------------------------------------
#  Read name definitions.
#
kvf = KvFile(inifile, sep='=')
count = kvf.read(dic={'TOPDIR': topdir})
if count < 0:
    Error(prog).put(kvf.error())
##  List of keys in the inifile.
keys = sorted(kvf.keys())

if verbose:
    ##  Make fixed length string.
    #   @param name		Any string.
    #   @param width	Field width (int).
    #   @returns		Fixed width string.
    def fixed(name, width):
        name += ':'
        if len(name) < width - 1:
            name += ' ' * (width - len(name))
Exemplo n.º 8
0
    def __read_file(self):
        # initialize
        self.path_list = {}
        self.prog_list = {}
        self.data_list = {}

        # read file
        kvf = KvFile(self.path)
        if kvf.read() <= 0:
            print('%s: can\'t open file "%s"' % (self.clsname, self.path))
            return -1
        self.kvf = kvf

        # prog list
        keys = kvf.change_section(self.PROG)
        keys = kvf.keys()
        for key in keys:
            self.prog_list[key] = kvf.get(key)

        # path list
        keys = kvf.change_section(self.PATH)
        keys = kvf.keys()
        for key in keys:
            self.path_list[key] = kvf.get(key)

        # data list
        keys = kvf.change_section(self.DATA)
        keys = kvf.keys()
        for key in keys:
            self.data_list[key] = kvf.get(key)

        if self.verbose > 1:
            for key in self.prog_list.keys():
                print('prog: %s = %s' % (key, self.prog_list[key]))
            for key in self.path_list.keys():
                print('path: %s = %s' % (key, self.path_list[key]))
            for key in self.data_list.keys():
                print('data: %s = %s' % (key, self.data_list[key]))

        self.file_read = True
        return 0
Exemplo n.º 9
0
# ----------------------------------------------------------------------
def Print(msg, indent=2):
    print('%s%s' % (' ' * indent, msg))


def defined_sections(count, kvf):
    if count == 0:
        msg = 'no section defined'
    else:
        sections = kvf.sections()
        msg = '%d section(s) defined: %s' % (count, sections)
    return msg


# ----------------------------------------------------------------------
K = KvFile('')
print('Test program for class: %s, Ver %s\n' % (K.clsname, K.version))

##
fname = 'test/KvFileTest.ini'
print('-- %s --' % fname)
kvf = KvFile(fname, verbose=verbose)
count = kvf.read()
if count < 0:
    Print(kvf.error())
    sys.exit(-1)
Print('file: "%s"' % fname)
Print(defined_sections(count, kvf))
Print('----')
kvf.show(2)
print()