def _runit(self, cmdl, actstrl, _in=None, indata=None, nl=False):
		try:
			procs = []
			if isinstance(cmdl[0], (type(b''), type(u''))):
				proc = self.call_one(cmdl, actstrl, _in=_in, out=PIPE,
						universal_newlines=nl)
				procs = [proc]
			elif len(cmdl) == 2:
				procs = self.call_two(cmdl[0], cmdl[1], actstrl[0], actstrl[1],
						_in=_in, out=PIPE, universal_newlines=nl)
			else:
				procs = self.call_many(cmdl, actstrl, _in=_in, out=PIPE,
						universal_newlines=nl)
			if indata: # only for small amounts of data
				procs[0].stdin.write(indata)
				procs[0].stdin.close()
				res = procs[-1].stdout.read()
			else:
				res, eres = procs[-1].communicate()
				if eres: print('Errors', eres) # XXX
		except Error as e:
			raise
			self.fail('%s [%s]' % (str(e), self.qjoin(cmdl)))
		finally:
			for proc in procs:
				proc.wait()
		if nl: return filter(None, lcompare.split_rad(res))
		return res
Пример #2
0
	def test_genbeads(self):
		cmdl = 'genbeads mymat myname 0 0 0 1 1 1 2 0 0 0 2 0 .1 .4'.split()
		try:
			proc = self.call_one(cmdl, 'call genbeads', out=PIPE,
				universal_newlines=True)
			raw = proc.stdout.read()
		except Error as e:
			self.fail('%s [%s]' % (str(e), self.qjoin(cmdl)))
		finally:
			proc.wait()
		result = lcompare.split_rad(raw)
		expect = [['mymat', 'sphere', 'myname.0'], [0], [0],
		[4, 0, 0, 0, 0.1],
		['mymat', 'sphere', 'myname.1'], [0], [0],
		[4, 0.36, 0.04, 0.104, 0.1],
		['mymat', 'sphere', 'myname.2'], [0], [0],
		[4, 0.651440715413, 0.167781092737, 0.365893348046, 0.1],
		['mymat', 'sphere', 'myname.3'], [0], [0],
		[4, 0.844350245496, 0.366600314978, 0.655866088042, 0.1],
		['mymat', 'sphere', 'myname.4'], [0], [0],
		[4, 0.960791445178, 0.643185551339, 0.897901825177, 0.1],
		]
		try: lcompare.llcompare(result, expect, ignore_empty=True)
		except lcompare.error as e:
			self.fail('%s [%s]' % (str(e), self.qjoin(cmdl)))
Пример #3
0
 def test_phisto(self):
     if os.name == 'nt': phisto = 'phisto'
     else: phisto = 'phisto'
     hgradpic = ts.datafile('gradients', 'h_gradient.hdr')
     vgradpic = ts.datafile('gradients', 'v_gradient.hdr')
     datafn = ts.datafile('gradients', 'gradient.histo')
     with open(datafn, 'r') as df:
         dtxt = df.read()
     expect = lcompare.split_rad(dtxt)
     for picfn in (hgradpic, vgradpic):
         hcmd = [phisto, picfn]
         err_msg = None
         try:
             result = self._runit(hcmd)
             lcompare.llcompare(result, expect)
         except AssertionError as e:
             with open(picfn, 'rb') as picf:
                 hcmd = [phisto]
                 result = self._runit(hcmd, _in=picf)
                 try:
                     lcompare.llcompare(result, expect)
                     err_msg = 'Phisto fails with spaces in file name paths.'
                 except Exception as e:
                     err_msg = str(e)
         except Exception as e:
             err_msg = str(e)
         if err_msg:
             self.fail(err_msg)
Пример #4
0
	def _runit(self, cmd):
		try:
			proc = self.call_one(cmd, 'call rlam', out=PIPE,
					universal_newlines=True)
			raw = proc.stdout.read()
		except Error as e:
			self.fail('%s [%s]' % (str(e), self.qjoin(cmd)))
		finally:
			proc.wait()
		return lcompare.split_rad(raw)
Пример #5
0
 def _runit(self, cmd, data):
     failmsg = None
     try:
         proc = self.call_one(cmd,
                              'test rlux',
                              _in=PIPE,
                              out=PIPE,
                              universal_newlines=True)
         raw, err = proc.communicate(data)
     except Error as e:
         failmsg = str(e)
     if failmsg:
         self.fail(failmsg)
     return lcompare.split_rad(raw)
Пример #6
0
	def test_lc_split_rad(self):
		df = ts.datafile('window_src.rad')
		exp = ([['#'],
				['#', 'A', 'plain', 'old', 'glass', 'window'],
				['#'],
				[], ['void', 'light', 'window_light'],
				[0], [0], [3, 1, 1, 1],
				[], ['window_light', 'polygon', 'window'],
				[0], [0], [12], [23.5, 43, 30], [23.5, 26, 30],
				[-23.5, 26, 30], [-23.5, 43, 30], []])
		with open(df) as f:
			res = f.read()
		resl = lcompare.split_rad(res)
		try: lcompare.lcompare(resl, exp)
		except lcompare.error as e:
			print(resl, exp)
			self.fail(('call_one_text n=%d -- ' % n) +str(e))
Пример #7
0
 def _runit(self, cmd, _in=None):
     failmsg = None
     proc = None
     try:
         proc = self.call_one(cmd,
                              'test phisto',
                              _in=_in,
                              out=PIPE,
                              universal_newlines=True)
         raw = proc.stdout.read()
     except Error as e:
         #self.fail(failmsg)
         failmsg = str(e)
     finally:
         if proc:
             res = proc.wait()
             if res != 0:
                 failmsg = 'Non-zero (%d) exit from %s' % (res, str(cmd))
     if failmsg:
         self.fail(failmsg)
     return lcompare.split_rad(raw)
Пример #8
0
 def _runit(self, cmdl, actstrl, _in=None, indata=None, nl=False):
     try:
         procs = []
         if isinstance(cmdl[0], (type(b''), type(u''))):
             proc = self.call_one(cmdl,
                                  actstrl,
                                  _in=_in,
                                  out=PIPE,
                                  universal_newlines=nl)
             procs = [proc]
         elif len(cmdl) == 2:
             procs = self.call_two(cmdl[0],
                                   cmdl[1],
                                   actstrl[0],
                                   actstrl[1],
                                   _in=_in,
                                   out=PIPE,
                                   universal_newlines=nl)
         else:
             procs = self.call_many(cmdl,
                                    actstrl,
                                    _in=_in,
                                    out=PIPE,
                                    universal_newlines=nl)
         if indata:  # only for small amounts of data
             procs[0].stdin.write(indata)
             procs[0].stdin.close()
             res = procs[-1].stdout.read()
         else:
             res, eres = procs[-1].communicate()
             if eres: print('Errors', eres)  # XXX
     except Error as e:
         raise
         self.fail('%s [%s]' % (str(e), self.qjoin(cmdl)))
     finally:
         for proc in procs:
             proc.wait()
     if nl: return filter(None, lcompare.split_rad(res))
     return res