Skip to content

Commit

Permalink
Implemented Trilinos specific driver (#600)
Browse files Browse the repository at this point in the history
Trilinos specific driver `trilinos_cdash_analyze_and_report_random_failures.py` based on
`example_cdash_analyze_and_report_random_failures.py` that contains the Trilinos specific
implementations of `VersionInfoStrategy` and `ExtractBuildNameStrategy`.
  • Loading branch information
achauphan committed Feb 13, 2024
1 parent 9e0983c commit 3f66ccb
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python

import sys
import argparse
import re as regex

import CDashAnalyzeReportRandomFailures as CDARRF


def main():

cdashAnalyzeAndReportRandomFailures = \
CDARRF.CDashAnalyzeReportRandomFailuresDriver(
TrilinosVersionInfoStrategy(),
ExtractBuildNameStrategy())

cdashAnalyzeAndReportRandomFailures.runDriver()

class TrilinosVersionInfoStrategy:

def getTopicTargetSha1s(self, buildData):
pattern = r"Parent [12]:\n\s+(\w+)"
matchedList = regex.findall(pattern, buildData)

if len(matchedList) != 2: return None
return tuple(matchedList)

def checkTargetTopicRandomFailure(self, targetTopicPair, knownTargetTopicPairs):
return targetTopicPair in knownTargetTopicPairs

class TrilinosExtractBuildNameStrategy:

def getCoreBuildName(self, fullBuildName):
coreBuildName = fullBuildName.rsplit('-',1)[0]
return coreBuildName



if __name__ == '__main__':
sys.exit(main())
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

import unittest

from FindCISupportDir import *
from trilinos_cdash_analyze_and_report_random_failures import *


class TestTrilinosVersionInfoStrategy(unittest.TestCase):

def setUp(self):
self.strategy = TrilinosVersionInfoStrategy()

def test_getTargetTopicSha1s_with_valid_versionData(self):
versionData = "Parent 1:\n target\nParent 2:\n topic"

expected = ('target','topic')
result = self.strategy.getTopicTargetSha1s(versionData)

self.assertEqual(result, expected)

def test_checkTargetTopicRandomFailure_true(self):
targetTopicPair = ('target', 'topic')
knownTargetTopicPairs = {('target','topic')}

result = self.strategy.checkTargetTopicRandomFailure(targetTopicPair, knownTargetTopicPairs)

self.assertTrue(result)

def test_checkTargetTopicRandomFailure_false(self):
targetTopicPair = ('some','other')
knownTargetTopicPairs = {('target','topic')}

result = self.strategy.checkTargetTopicRandomFailure(targetTopicPair, knownTargetTopicPairs)

self.assertFalse(result)


class TrilinosExtractBuildName(unittest.TestCase):

def setUp(self):
self.strategy = TrilinosExtractBuildNameStrategy()

def test_getCoreBuildName(self):
fullBuildName = "PR-number-test-core_build-name-number"

expected = "PR-number-test-core_build-name"
result = self.strategy.getCoreBuildName(fullBuildName)

self.assertEqual(result, expected)


if __name__ == '__main__':
unittest.main()

0 comments on commit 3f66ccb

Please sign in to comment.