示例#1
0
def run(command):
    print ansiColor.add_green_color(':: %s' % command)
    errorCode = os.system(command)
    if errorCode:
        print "\n\nThe following command failed:"
        print ansiColor.add_red_color(command)
        sys.exit()
    return not errorCode
示例#2
0
def run(command) :
	print ansiColor.add_green_color(':: %s' % command)
	errorCode = os.system(command)
	if errorCode :
		print "\n\nThe following command failed:"
		print ansiColor.add_red_color(command)
		sys.exit()
	return not errorCode
示例#3
0
def passB2BTests(datapath, back2BackCases, testSuiteName, dry_run, extra_args_for_diff) :
	failedCases = []	
	
	testsuite = TestSuite(testSuiteName)
		

	if dry_run : 
		print "# DATAPATH=%s" % datapath
	for test in back2BackCases : 
		extra_args_for_diff_case = extra_args_for_diff.copy()
		arguments = len(test) 
		if arguments == 3 :
			case, command, outputs = test
		elif arguments == 4 : 
			case, command, outputs, optional_arguments = test
			extra_args_for_diff_case.update(optional_arguments)
			# specific platform arguments (_linux, _mac, _win suffixes)
			platformSuffix = { 'Linux' : '_linux', 'Darwin' : '_mac', 'Windows' : '_win' }[platform.system()]
			extra_args_for_diff_case.update(dict([(item[0][:-len(platformSuffix)], item[1]) for item in optional_arguments.items() if item[0][-len(platformSuffix):] == platformSuffix]))
		else : 
			print "WARNING: skipping bad test %s" % test
			continue
		command = os.path.normcase(command)
		if dry_run : 
			print "\nTest %s :" % case 
			print "\t%s\n" % command
		else :
			testsuite.appendTestCase(passB2BTest(datapath, failedCases, case, command, outputs, extra_args_for_diff_case))

	junitDoc = JUnitDocument("AllTests")
	junitDoc.appendTestSuite(testsuite)

	junitFile = open(testSuiteName + "_test_detail.xml", "w")
	junitFile.write(junitDoc.toxml())
	junitFile.close()

	print "Summary:"
	print ansiColor.add_green_color('%i passed cases' % (len(back2BackCases)-len(failedCases)))

	if not failedCases : return True

	print ansiColor.add_red_color('%i failed cases!' % len(failedCases))
	for case, msgs in failedCases :
		print case, ":"
		for msg in msgs :
			print "\t%s"%msg
	return False
示例#4
0
def norun(command):
    print ansiColor.add_red_color('XX %s' % command)
示例#5
0
                            extra_args_for_diff_case))

    junitDoc = JUnitDocument("AllTests")
    junitDoc.appendTestSuite(testsuite)

    junitFile = open(testSuiteName + "_test_detail.xml", "w")
    junitFile.write(junitDoc.toxml())
    junitFile.close()

    print "Summary:"
    print ansiColor.add_green_color('%i passed cases' %
                                    (len(back2BackCases) - len(failedCases)))

    if not failedCases: return True

    print ansiColor.add_red_color('%i failed cases!' % len(failedCases))
    for case, msgs in failedCases:
        print case, ":"
        for msg in msgs:
            print "\t%s" % msg
    return False


def passB2BTest(datapath, failedCases, case, command, outputs,
                extra_args_for_diff):
    testcase = TestCase(case)
    phase("Test: %s Command: '%s'" % (case, command))

    if isinstance(outputs, str):
        outputs = [outputs]
示例#6
0
def norun(command) :
	print ansiColor.add_red_color('XX %s' % command)
示例#7
0
	for output in outputs :
		extension = os.path.splitext(output)[-1]
		base = prefix(datapath, case, output)
		expected = expectedName(base, extension)
		diffbase = diffBaseName(base)
		difference = diff_files(expected, output, diffbase, extra_args_for_diff)
		#diffbase = diffbase+'.wav'
		diffbase = diffbase + extension

		if not difference:
			print ansiColor.add_green_color(" Passed")
			removeIfExists(diffbase)
			removeIfExists(diffbase+'.png')
			removeIfExists(badResultName(base,extension))
		else:
			print ansiColor.add_red_color(" Failed")
			copyfile(output, badResultName(base,extension)) 
			failures.append("Output '%s':\n%s"%(base, '\n'.join(['\t- %s'%item for item in difference])))
			testcase.appendFailure("Output '%s':\n%s"%(base, '\n'.join(['\t- %s'%item for item in difference])))
		removeIfExists(output)
	if failures :
		failedCases.append((case, failures))

	return testcase

help ="""
To run the tests call this script without parameters.
	./back2back

To run just some cases you can use the "--filter substring" argument 
to run all tests cases which includes "substring" on its names, or "--filter_regex regex"