Exemplo n.º 1
0
	def _runPlainR(self):
		""" Runs the tester in plain R mode, where it outputs the plain R version of the tests to a special file, rather than running the tests. """
		if (len(self._testRoots)!=1):
			error("When using --plainr mode, only one root can be selected");
		root = self._testRoots[0][0]
		lastFilename = ""
		outfile = None
		fileTests = 0
		print("Creating R-compatible raw tests. The following is a list of test file entered")
		print("and number of tests generated:\n")
		for t in Test.enumerate(self._testRoots, self._recursive):
			if (t.filename() != lastFilename):
				if (outfile != None):
					print("["+str(fileTests)+"]")
					outfile.close()
					fileTests = 0
				fname = os.path.join(self._plainROutput, t.filename()[len(root)+1:])
				dirname, filename = os.path.split(fname)
				print(strFormat(fname), end="")
				os.makedirs(dirname, exist_ok = True)
				outfile = open(fname, "w")
				lastFilename = t.filename()
			for c in t.commands():
				if (c.find("#! ") == 0):
					outfile.write("#! "+t.name()+"\n")
				elif (c.find("#!g") == 0):
					pass
				else:
					outfile.write(c.replace("\\\"",'"')+"\n")
			outfile.write(t.code()+"\n\n")
			fileTests += 1
		if (outfile != None):
			print("["+str(fileTests)+"]")
			outfile.close()
Exemplo n.º 2
0
	def run(self):
		""" Runs the test suite as specified, that is runs all tests in all files under all test roots. """
		if (self._plainROutput != None):
			return self._runPlainR()
		self._print("Initializing target %s " % self._target)
		self.target = __import__(self._target).Target(self._targetPath)
		self._print("    path:         %s" % self.target.path)
		self._print("    version:      %s" % self.target.version)
		self._print("    architecture: %s" % self.target.arch)
		tests = 0
		test_fails = 0
		run_fails = 0
		skipped = 0

		for t in Test.enumerate(self._testRoots, self._recursive):
			if (not self._reportOnlyErrors):
				print(strFormat(t.name()), end="")
			result = self._runTest(t)
			if (self._reportOnlyErrors):
				if (result[0] in (TestR.RUN_FAIL, TestR.TEST_FAIL)):
					print(strFormat(t.name()), end="")
					print(result[0])
			else:
					print(result[0])
			if (result[0] in (TestR.RUN_FAIL, TestR.TEST_FAIL)):
				print("    File: {0} [line {1}]".format(t.filename(), t.line()))
				print(strLineOffset(result[1]))
				self._print("    Code:")
				self._print(strLineOffset(t.code(), 8))
			tests += 1
			if (result[0] == TestR.RUN_FAIL):
				run_fails += 1
			elif (result[0] == TestR.TEST_FAIL):
				test_fails += 1
			elif (result[0] == TestR.NOT_RUN):
				skipped += 1

		print("\n----------------------------------------------------------------------------------------------------------\n")
		print("Total tests:    {0}".format(tests))
		print("Skipped:        {0}".format(skipped))
		print("Successful:     {0} {1}".format(tests-test_fails-run_fails-skipped, "OK" if (test_fails + run_fails == 0) else "FAIL"))
		print("Failed:         {0}".format(run_fails + test_fails))
		print("    execution:  {0}".format(run_fails))
		print("    checks:     {0}".format(test_fails))