-
Couldn't load subscription status.
- Fork 0
feat: Add script to process IntegratedTests failures to geos_ats. #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6235c83
feat: Add script to process IntegratedTests failures.
CusiniM 57cde40
add comment in case of no unfiltered diffs.
CusiniM 2041f64
add indent.
CusiniM c4ec674
yapf formatting.
CusiniM 0131510
review comments + add a few statistics.
CusiniM 2a93f6e
add break line
CusiniM c0ea191
fixed small issues and tested it locally.
CusiniM 3dd8a69
format file with yapf.
CusiniM File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
110 changes: 110 additions & 0 deletions
110
geos-ats/src/geos/ats/helpers/process_tests_failures.py
This file contains hidden or 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,110 @@ | ||
| #!/usr/bin/env python3 | ||
| import sys | ||
| import os | ||
| import stat | ||
| import subprocess | ||
| import argparse | ||
| import platform | ||
| import shutil | ||
| import logging | ||
|
|
||
| logging.basicConfig( level=logging.INFO, format="%(levelname)s: %(message)s" ) | ||
|
|
||
|
|
||
| # fines all files recursively from | ||
| def findFiles( folder, extension ): | ||
| for root, folders, files in os.walk( folder ): | ||
| for filename in folders + files: | ||
| if ( extension in filename ): | ||
| yield os.path.join( root, filename ) | ||
|
|
||
|
|
||
| def parse_logs_and_filter_errors( directory, extension, exclusionStrings, numTrailingLines ): | ||
| # What strings to look for in order to flag a line/block for output | ||
| matchStrings = [ 'Error:' ] | ||
|
|
||
| filteredErrors = {} | ||
|
|
||
| # What stings to look for in order to exclude a block | ||
| for fileName in findFiles( directory, extension ): | ||
| errors = '' | ||
|
|
||
| with open( fileName ) as f: | ||
| lines = f.readlines() | ||
|
|
||
| for i in range( 0, len( lines ) ): | ||
| line = lines[ i ] | ||
| if all( matchString in line for matchString in matchStrings ): | ||
| matchBlock = [] | ||
| matchBlock.append( ' ' + lines[ i - 1 ] ) | ||
| matchBlock.append( ' ' + line ) | ||
|
|
||
| for j in range( 1, numTrailingLines + 1 ): | ||
| if i + j >= len( lines ): | ||
| matchBlock.append( | ||
| ' ***** No closing line. file truncated? Filters may not be properly applied! *****' ) | ||
| break | ||
| matchBlock.append( ' ' + lines[ i + j ] ) | ||
|
|
||
| matchBlock = '\n'.join( matchBlock ) | ||
|
|
||
| if ( '******************************************************************************' | ||
| in lines[ i + j ] ): | ||
| break | ||
|
|
||
| i += j | ||
CusiniM marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| if not any( excludeString in matchBlock for excludeString in exclusionStrings ): | ||
| errors += matchBlock | ||
|
|
||
| if errors: | ||
| filteredErrors[ fileName ] = errors | ||
|
|
||
| if filteredErrors: | ||
| for fileName, errors in filteredErrors.items(): | ||
| logging.warning( f"Found unfiltered diff in: {fileName}" ) | ||
| logging.info( f"Details of diffs: {errors}" ) | ||
| else: | ||
| logging.info( "No unfiltered differences were found." ) | ||
|
|
||
|
|
||
| def main(): | ||
|
|
||
| DEFAULT_EXCLUSION_STRINGS = [ | ||
| 'logLevel', 'NonlinearSolverParameters', 'has a child', 'different shapes', 'different types', 'differing types' | ||
| ] | ||
|
|
||
| parser = argparse.ArgumentParser( description='Process ats output to filter diffs.' ) | ||
|
|
||
| parser.add_argument( '-d', | ||
| '--directory', | ||
| type=str, | ||
| default='integratedTests', | ||
| help='directory to search recursively for files with specified extension' ) | ||
|
|
||
| parser.add_argument( '-ext', '--extension', type=str, default='.log', help='extension of files to filter' ) | ||
|
|
||
| parser.add_argument( '-tl', | ||
| '--numTrailingLines', | ||
| type=int, | ||
| default=5, | ||
| help='number of lines to include in block after match is found.' ) | ||
|
|
||
| parser.add_argument( '-e', | ||
| '--exclusionStrings', | ||
| type=str, | ||
| nargs="*", | ||
| default=[], | ||
| help='What stings to look for in order to exclude a block' ) | ||
|
|
||
| args, unknown_args = parser.parse_known_args() | ||
|
|
||
| if unknown_args: | ||
| print( "unknown arguments %s" % unknown_args ) | ||
|
|
||
| exclusionStrings = DEFAULT_EXCLUSION_LIST + args.exclusionStrings | ||
| parse_logs_and_filter_errors( args.directory, args.extension, exclusionStrings, args.numTrailingLines ) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| main() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.