forked from PixarAnimationStudios/OpenUSD
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request PixarAnimationStudios#787 from autodesk-forks/ehle…
…nl/OGSMOD-4406 * OGSMOD-4406 run all the unit test, and the filter by TestSkipList * OGSMOD-4406 adjust Ctest timeout and number of jobs. Archive Testing folder on failures and junit now works well on reports generated from xcode * OGSMOD-4406 skip test testSdfListOp on Windows, it takes too long to run on Debug. * OGSMOD-4406 check xcresultparser checksum --------- Co-authored-by: Luis Ehlen <lehlen@evernote.com>
- Loading branch information
Showing
4 changed files
with
137 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import xml.etree.ElementTree as ET | ||
import argparse | ||
import copy | ||
|
||
def remove_elements_by_name(junit_file, tests_to_skip, output_file, skipped_tests_output_file): | ||
# Parse the JUnit XML file | ||
tree = ET.parse(junit_file) | ||
root = tree.getroot() | ||
|
||
# Create a new tree for skipped tests | ||
removed_tree = ET.ElementTree(ET.Element('testsuite')) | ||
removed_root = removed_tree.getroot() | ||
|
||
# go over all the tests and put the skipped ones in on file and the rest in another | ||
has_failures = False | ||
for testcase in root.findall('.//testcase'): | ||
test_name = testcase.get('name') | ||
if test_name in tests_to_skip: | ||
print(f"skiping: {test_name}") | ||
removed_root.append(copy.deepcopy(testcase)) | ||
root.remove(testcase) | ||
elif not has_failures : | ||
test_status = testcase.get('status') | ||
# we have only 2 status: run or fail | ||
if test_status == 'fail': | ||
has_failures = True | ||
|
||
# for ios, we need to check on failures in testsuite as it has no status | ||
for testsuite in root.findall('.//testsuite'): | ||
testsuite_name = testsuite.get('name') | ||
if testsuite_name in tests_to_skip: | ||
print(f"skiping: {testsuite_name}") | ||
removed_root.append(copy.deepcopy(testsuite)) | ||
root.remove(testsuite) | ||
elif not has_failures : | ||
failures = testsuite.get('failures') | ||
if failures != '0': | ||
has_failures = True | ||
|
||
|
||
# Change output file name if fail were found in the junit file | ||
if has_failures: | ||
print(f"the junit file contains failures") | ||
output_file=output_file + '.has_failures' | ||
|
||
# Save both new files | ||
print(f"Writing non skipped test to {output_file}") | ||
print(f"Writing skipped test to {skipped_tests_output_file}") | ||
tree.write(output_file) | ||
removed_tree.write(skipped_tests_output_file) | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="Takes a junit file and split it based on a list of test to skip.") | ||
parser.add_argument("--input_file", help="Path to the JUnit XML file") | ||
parser.add_argument("--skip_file", help="Path to the TestSkipList file") | ||
parser.add_argument("--output_file", help="Output jUnit file with the non skipped tests") | ||
parser.add_argument("--skipped_output_file", help="Output jUnit file with the skipped tests") | ||
|
||
args = parser.parse_args() | ||
|
||
junit_file_path = args.input_file | ||
skip_file_path = args.skip_file | ||
output_file_path = args.output_file | ||
skipped_output_file_path = args.skipped_output_file | ||
|
||
# Step 1: Read the list of test to skip, ignoring comments | ||
with open(skip_file_path, 'r') as names_file: | ||
tests_to_skip = [line.strip().rstrip('$') for line in names_file.readlines() if not line.startswith("#")] | ||
|
||
# Step 2: Remove specified 'testcase' elements, save the modified XML, and create a new file with removed elements | ||
remove_elements_by_name(junit_file_path, tests_to_skip, output_file_path, skipped_output_file_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
80fb0b5bff1e4d6b8a021e56d3ab3097b2daa914 xcresultparser |