Example #1
0
    def GetSubsystemToTest(self, relevant_changes):
        """Get subsystems from relevant cls for current board, write to BOARD_ATTRS.

    Args:
      relevant_changes: A set of changes that are relevant to current board.

    Returns:
      A set of the subsystems. An empty set indicates that all subsystems should
      be tested.
    """
        # Go through all the relevant changes, collect subsystem info from them. If
        # there exists a change without subsystem info, we assume it affects all
        # subsystems. Then set the superset of all the subsystems to be empty, which
        # means that need to test all subsystems.
        subsystem_set = set()
        for change in relevant_changes:
            sys_lst = triage_lib.GetTestSubsystemForChange(
                self._build_root, change)
            if sys_lst:
                subsystem_set = subsystem_set.union(sys_lst)
            else:
                subsystem_set = set()
                break

        return subsystem_set
Example #2
0
 def testGetDefaultSubsystem(self):
     """Test if we can get default subsystem when subsystem is not specified."""
     change = sync_stages_unittest.MockPatch(
         commit_message='First line\nThird line\n')
     self.PatchObject(triage_lib, 'GetOptionForChange', return_value=None)
     result = triage_lib.GetTestSubsystemForChange('foo/build/root', change)
     self.assertEqual(['default'], result)
 def testGetSubsystemFromInvalidCommitMessage(self):
   """Test get subsystem from config file when commit message not have it."""
   change = sync_stages_unittest.MockPatch(
       commit_message='First line\nThird line\n')
   self.PatchObject(triage_lib, 'GetOptionForChange',
                    return_value='power light')
   result = triage_lib.GetTestSubsystemForChange('foo/build/root', change)
   self.assertEqual(['power', 'light'], result)
 def testGetSubsystemFromValidCommitMessage(self):
   """Test whether we can get subsystem from commit message."""
   change = sync_stages_unittest.MockPatch(
       commit_message='First line\nThird line\nsubsystem: network audio\n'
                      'subsystem: wifi')
   self.PatchObject(triage_lib, 'GetOptionForChange',
                    return_value='power light')
   result = triage_lib.GetTestSubsystemForChange('foo/build/root', change)
   self.assertEqual(['network', 'audio', 'wifi'], result)