def testCompareNonWildcard(self): """Tests that non-wildcard comparisons work as expected.""" e = data_types.WebTestExpectation('test', ['tag1'], 'Failure') self.assertTrue(e._CompareNonWildcard('test')) self.assertTrue(e._CompareNonWildcard('virtual/some-identifier/test')) self.assertFalse(e._CompareNonWildcard('tes')) self.assertFalse( e._CompareNonWildcard('/virtual/some-identifier/test')) self.assertFalse(e._CompareNonWildcard('virtual/some/malformed/test'))
def testAlwaysNeededExpectationSlowExpectation(self): """Tests that special logic is used for Slow-only expectations.""" expectation = data_types.WebTestExpectation('foo', ['debug'], 'Slow') stats = data_types.WebTestBuildStats() # The fact that this failed should be ignored. stats.AddFailedBuild('build_id') self.assertFalse(stats.AlwaysNeededExpectation(expectation)) stats.AddSlowBuild('build_id') self.assertTrue(stats.AlwaysNeededExpectation(expectation))
def testNeverNeededExpectationNoSlowExpectation(self): """Tests that no special logic is used for non-Slow expectations.""" expectation = data_types.WebTestExpectation('foo', ['debug'], 'Failure') stats = data_types.WebTestBuildStats() stats.AddPassedBuild() self.assertTrue(stats.NeverNeededExpectation(expectation)) # Slowness should not be considered in this case. stats.AddSlowBuild('build_id') self.assertTrue(stats.NeverNeededExpectation(expectation)) stats.AddFailedBuild('build_id') self.assertFalse(stats.NeverNeededExpectation(expectation))
def testAlwaysNeededExpectationMixedSlowExpectations(self): """Tests that special logic is used for mixed Slow expectations.""" expectation = data_types.WebTestExpectation('foo', ['debug'], ['Slow', 'Failure']) stats = data_types.WebTestBuildStats() # This should return true if either all builds failed OR all builds were # slow. stats.AddPassedBuild() # Passed build, not slow. self.assertFalse(stats.AlwaysNeededExpectation(expectation)) stats.AddSlowBuild('build_id') # Passed build, slow. self.assertTrue(stats.AlwaysNeededExpectation(expectation)) stats = data_types.WebTestBuildStats() stats.AddFailedBuild('build_id') # Failed build, not slow. self.assertTrue(stats.AlwaysNeededExpectation(expectation)) stats.AddSlowBuild('build_id') # Failed build, slow. self.assertTrue(stats.AlwaysNeededExpectation(expectation))
def testNeverNeededExpectationMixedSlowExpectation(self): """Tests that special logic is used for mixed Slow expectations.""" expectation = data_types.WebTestExpectation('foo', ['debug'], ['Slow', 'Failure']) stats = data_types.WebTestBuildStats() # This should only return true if there are no slow builds AND there # are no failed builds. stats.AddPassedBuild() # Passed build, not slow. self.assertTrue(stats.NeverNeededExpectation(expectation)) stats.AddSlowBuild('build_id') # Passed build, slow. self.assertFalse(stats.NeverNeededExpectation(expectation)) stats = data_types.WebTestBuildStats() stats.AddFailedBuild('build_id') # Failed build, not slow. self.assertFalse(stats.NeverNeededExpectation(expectation)) stats.AddSlowBuild('build_id') # Failed build, slow. self.assertFalse(stats.NeverNeededExpectation(expectation))