コード例 #1
0
ファイル: test_junitxml.py プロジェクト: strawlab/ros
 def testReadMultisuite(self):
     result = junitxml.read(self.mockresults["multisuite"].filename, "fooname")
     self.assert_(result is not None)
     self.assertEquals(3.0, result.time)
     self.assertEquals(3, result.num_tests)
     self.assertEquals(1, result.num_errors)
     self.assertEquals(1, result.num_failures)
コード例 #2
0
ファイル: clean_junit_xml.py プロジェクト: Nishida-Lab/RCR
def clean_results(test_results_dir, output_dir, filter):
    """
    Read results from test_results_dir and write them into output_dir.
    """
    for d in os.listdir(test_results_dir):
        if filter and d in filter:
            continue
        print("looking at", d)
        test_dir = os.path.join(test_results_dir, d)
        if not os.path.isdir(test_dir):
            continue
        base_test_name = os.path.basename(test_dir)
        # for each test result that a package generated, read it, then
        # rewrite it to our output directory. This will invoke our
        # cleaning rules on the XML that protect the result from Hudson
        # issues.
        for file in os.listdir(test_dir):
            if file.endswith('.xml'):
                test_name = base_test_name + '.' + file[:-4]
            file = os.path.join(test_dir, file)
            try:
                result = junitxml.read(file, test_name)
                output_path = os.path.join(output_dir, "%s.xml"%test_name)
                with open(output_path, 'w') as f:
                    print("re-writing", output_path)
                    f.write(result.xml().encode('utf-8'))
            except Exception as e:
                sys.stderr.write("ignoring [%s]: %s\n"%(file, e))
コード例 #3
0
ファイル: test_junitxml.py プロジェクト: strawlab/ros
 def testReadNoSuites(self):
     result = junitxml.read(self.mockresults["empty"].filename, "fooname")
     self.assert_(result is not None)
     self.assertEquals(0.0, result.time)
     self.assertEquals(0, result.num_tests)
     self.assertEquals(0, result.num_errors)
     self.assertEquals(0, result.num_failures)
コード例 #4
0
ファイル: test_junitxml.py プロジェクト: strawlab/ros
 def testReadFail(self):
     result = junitxml.read(self.mockresults["fail1"].filename, "fooname")
     self.assert_(result is not None)
     self.assertEquals(1.0, result.time)
     self.assertEquals(1, result.num_tests)
     self.assertEquals(0, result.num_errors)
     self.assertEquals(1, result.num_failures)
コード例 #5
0
ファイル: test_junitxml.py プロジェクト: is0392hr/catkin_ws3
 def testReadFail(self):
     result = junitxml.read(self.mockresults['fail1'].filename, 'fooname')
     self.assert_(result is not None)
     self.assertEquals(1.0, result.time)
     self.assertEquals(1, result.num_tests)
     self.assertEquals(0, result.num_errors)
     self.assertEquals(1, result.num_failures)
コード例 #6
0
ファイル: test_junitxml.py プロジェクト: is0392hr/catkin_ws3
 def testReadMultisuite(self):
     result = junitxml.read(self.mockresults['multisuite'].filename, 'fooname')
     self.assert_(result is not None)
     self.assertEquals(3.0, result.time)
     self.assertEquals(3, result.num_tests)
     self.assertEquals(1, result.num_errors)
     self.assertEquals(1, result.num_failures)
コード例 #7
0
 def testReadError(self):
     result = junitxml.read(self.mockresults["err1"].filename, "fooname")
     self.assert_(result is not None)
     self.assertEquals(1.0, result.time)
     self.assertEquals(1, result.num_tests)
     self.assertEquals(1, result.num_errors)
     self.assertEquals(0, result.num_failures)
コード例 #8
0
ファイル: test_junitxml.py プロジェクト: is0392hr/catkin_ws3
 def testReadNoSuites(self):
     result = junitxml.read(self.mockresults['empty'].filename, 'fooname')
     self.assert_(result is not None)
     self.assertEquals(0.0, result.time)
     self.assertEquals(0, result.num_tests)
     self.assertEquals(0, result.num_errors)
     self.assertEquals(0, result.num_failures)
コード例 #9
0
def clean_results(test_results_dir, output_dir, filter):
    """
    Read results from test_results_dir and write them into output_dir.
    """
    for d in os.listdir(test_results_dir):
        if filter and d in filter:
            continue
        print("looking at", d)
        test_dir = os.path.join(test_results_dir, d)
        if not os.path.isdir(test_dir):
            continue
        base_test_name = os.path.basename(test_dir)
        # for each test result that a package generated, read it, then
        # rewrite it to our output directory. This will invoke our
        # cleaning rules on the XML that protect the result from Hudson
        # issues.
        for file in os.listdir(test_dir):
            if file.endswith('.xml'):
                test_name = base_test_name + '.' + file[:-4]
            file = os.path.join(test_dir, file)
            try:
                result = junitxml.read(file, test_name)
                output_path = os.path.join(output_dir, "%s.xml"%test_name)
                with open(output_path, 'w') as f:
                    print("re-writing", output_path)
                    f.write(result.xml().encode('utf-8'))
            except Exception as e:
                sys.stderr.write("ignoring [%s]: %s\n"%(file, e))
コード例 #10
0
ファイル: test_junitxml.py プロジェクト: safdark/ros
 def testReadMulticase(self):
     result = junitxml.read(self.mockresults["multicase"].filename, "fooname")
     self.assert_(result is not None)
     self.assertEquals(3.0, result.time)
     self.assertEquals(3, result.num_tests)
     self.assertEquals(1, result.num_errors)
     self.assertEquals(1, result.num_failures)
コード例 #11
0
ファイル: test_junitxml.py プロジェクト: safdark/ros
 def testReadEmptySuite(self):
     result = junitxml.read(self.mockresults["emptysuite"].filename, "fooname")
     self.assert_(result is not None)
     self.assertEquals(0.0, result.time)
     self.assertEquals(0, result.num_tests)
     self.assertEquals(0, result.num_errors)
     self.assertEquals(0, result.num_failures)
コード例 #12
0
def clean_and_copy_test_results(input_dir,
                                output_dir,
                                errors=None,
                                prefix='dummy'):
    """
    Takes all the xml-formatted Ant JUnit XML test outputs in input_dir and 
    aggregates them into output_dir. In this process, it strips any characters 
    that tend to cause Hudson/Jenkins trouble.
    """

    if os.path.exists(output_dir):
        print "deleting old test results directory", output_dir
        shutil.rmtree(output_dir)
    print "creating new test results directory", output_dir
    os.makedirs(output_dir)

    print "Copy all test results to " + output_dir
    for d in os.listdir(input_dir):
        test_dir = os.path.join(input_dir, d)
        if not os.path.isdir(test_dir):
            continue
        base_test_name = os.path.basename(test_dir)
        # for each test result that a package generated, read it, then
        # rewrite it to our output directory. This will invoke our
        # cleaning rules on the XML that protect the result from Hudson
        # issues.
        for file in os.listdir(test_dir):
            if file.endswith('.xml'):
                test_name = base_test_name + '.' + file[:-4]
            file = os.path.join(test_dir, file)
            try:
                result = junitxml.read(file, test_name)
                output_path = os.path.join(output_dir, "%s.xml" % test_name)
                with open(output_path, 'w') as f:
                    print "re-writing", output_path
                    f.write(result.xml().encode('utf-8'))
            except Exception as e:
                print "ignoring [%s]: %s\n" % (file, e)
                sys.stderr.write("ignoring [%s]: %s\n" % (file, e))

    # create dummy test if no rostest result exists in workspace_test_results_dir
    generate_dummy_test = False
    for root, dirnames, filenames in os.walk(output_dir):
        if len(filenames) == 0:
            generate_dummy_test = True
    if generate_dummy_test:
        print "No test results, so I'll create a dummy test result xml file, with errors %s" % errors
        with open(os.path.join(output_dir, 'dummy.xml'), 'w') as f:
            if errors:
                f.write(
                    '<?xml version="1.0" encoding="UTF-8"?><testsuite tests="1" failures="0" time="1" errors="1" name="%s test"> <testcase name="%s rapport" classname="Results" /><testcase classname="%s_class" name="%sFailure"><error type="%sException">%s</error></testcase></testsuite>'
                    % (prefix, prefix, prefix, prefix, prefix, errors))
            else:
                f.write(
                    '<?xml version="1.0" encoding="UTF-8"?><testsuite tests="1" failures="0" time="1" errors="0" name="dummy test"> <testcase name="dummy rapport" classname="Results" /></testsuite>'
                )
コード例 #13
0
ファイル: common.py プロジェクト: ct2034/jenkins_setup
def clean_and_copy_test_results(input_dir, output_dir, errors=None, prefix='dummy'):
    """
    Takes all the xml-formatted Ant JUnit XML test outputs in input_dir and 
    aggregates them into output_dir. In this process, it strips any characters 
    that tend to cause Hudson/Jenkins trouble.
    """
    
    if os.path.exists(output_dir):
        print "deleting old test results directory", output_dir
        shutil.rmtree(output_dir)
    print "creating new test results directory", output_dir
    os.makedirs(output_dir)

    print "Copy all test results to " + output_dir
    for d in os.listdir(input_dir):
        test_dir = os.path.join(input_dir, d)
        if not os.path.isdir(test_dir):
            continue
        base_test_name = os.path.basename(test_dir)
        # for each test result that a package generated, read it, then
        # rewrite it to our output directory. This will invoke our
        # cleaning rules on the XML that protect the result from Hudson
        # issues.
        for file in os.listdir(test_dir):
            if file.endswith('.xml'):
                test_name = base_test_name + '.' + file[:-4]
            file = os.path.join(test_dir, file)
            try:
                result = junitxml.read(file, test_name)
                output_path = os.path.join(output_dir, "%s.xml"%test_name)
                with open(output_path, 'w') as f:
                    print "re-writing", output_path
                    f.write(result.xml().encode('utf-8'))
            except Exception as e:
                print "ignoring [%s]: %s\n"%(file, e)
                sys.stderr.write("ignoring [%s]: %s\n"%(file, e))

    # create dummy test if no rostest result exists in workspace_test_results_dir
    generate_dummy_test = False
    for root, dirnames, filenames in os.walk(output_dir):
        if len(filenames) == 0:
            generate_dummy_test = True
    if generate_dummy_test:
        print "No test results, so I'll create a dummy test result xml file, with errors %s" % errors
        with open(os.path.join(output_dir, 'dummy.xml'), 'w') as f:
            if errors:
                f.write('<?xml version="1.0" encoding="UTF-8"?><testsuite tests="1" failures="0" time="1" errors="1" name="%s test"> <testcase name="%s rapport" classname="Results" /><testcase classname="%s_class" name="%sFailure"><error type="%sException">%s</error></testcase></testsuite>' % (prefix, prefix, prefix, prefix, prefix, errors))
            else:
                f.write('<?xml version="1.0" encoding="UTF-8"?><testsuite tests="1" failures="0" time="1" errors="0" name="dummy test"> <testcase name="dummy rapport" classname="Results" /></testsuite>')