Skip to content
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

Add validation for platform strings to exclude_parser.py #5651

Merged
merged 4 commits into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions scripts/disabled_tests/exclude_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,21 @@
from common.models import Scheme, JdkInfo
from common.utils import to_shallow_dict, DEFAULT_TARGET

class ErrorTrackingHandler(logging.Handler):
def __init__(self):
super().__init__()
self.error_logged = False

def emit(self, record):
if record.levelno >= logging.ERROR:
self.error_logged = True

logging.basicConfig(
format="%(levelname)s - %(message)s"
)
LOG = logging.getLogger()
ERROR_TRACKER = ErrorTrackingHandler()
LOG.addHandler(ERROR_TRACKER)

OS_EXCEPTIONS = {
"macosx": "mac",
Expand All @@ -26,7 +37,6 @@
"x86": "x86-32",
}


class ExclusionFileProcessingException(Exception):
pass

Expand Down Expand Up @@ -112,7 +122,7 @@ class TestExclusionSplitLine(TestExclusionRawLine):

@classmethod
def from_raw_line(cls, test_excl: TestExclusionRawLine):
split_line = test_excl.raw_line.split(maxsplit=2)
split_line = test_excl.raw_line.split()
if len(split_line) != 3:
raise TestExclusionProcessingException(
f'Not exactly 3 elements when splitting {test_excl.raw_line}', test_excl)
Expand Down Expand Up @@ -185,7 +195,6 @@ def transform_platform(os_arch_platform: str) -> str:

return f"{arch_name}_{os_name}"


def resolve_platforms(split: TestExclusionSplitLine) -> List[str]:
revolved_platforms = []
list_of_unresolved_platform_names = [s.strip() for s in split.raw_platform.split(",") if s.strip()]
Expand Down Expand Up @@ -250,11 +259,10 @@ def main():
if args.verbose:
LOG.setLevel(logging.DEBUG)

# if the dir containing the exclude ProblemList*.txt is not passed, the attempt to use openjdk/excludes/ dir instead
if args.exclude_dir:
LOG.debug("Taking file list from directory")
exclude_files = [os.path.join(args.exclude_dir, file_name)
for file_name in os.listdir(args.exclude_dir)]
exclude_files = [os.path.join(args.exclude_dir, f) for f in os.listdir(args.exclude_dir) if os.path.isfile(os.path.join(args.exclude_dir, f))]
LOG.debug(exclude_files)
else:
LOG.debug("Taking file list from stdin")
exclude_files = [line.rstrip() for line in sys.stdin.readlines()] # remove the \n from each lines
Expand Down Expand Up @@ -283,7 +291,9 @@ def main():
fp=fp,
indent=2,
)

if ERROR_TRACKER.error_logged:
LOG.debug(f"Error found. Exiting with code 1")
sys.exit(1)

if __name__ == '__main__':
main()