Ejemplo n.º 1
0
def CMDmerge(args):
  """Reads and merges the data from the trace back into the original .isolate.

  Ignores --outdir.
  """
  parser = OptionParserIsolate(command='merge', require_result=False)
  options, _ = parser.parse_args(args)
  complete_state = load_complete_state(options, NO_INFO)
  value = read(complete_state)

  # Now take that data and union it into the original .isolate file.
  with open(complete_state.saved_state.isolate_file, 'r') as f:
    prev_content = f.read()
  prev_config = merge_isolate.load_gyp(
      merge_isolate.eval_content(prev_content),
      merge_isolate.extract_comment(prev_content),
      merge_isolate.DEFAULT_OSES)
  new_config = merge_isolate.load_gyp(
      value,
      '',
      merge_isolate.DEFAULT_OSES)
  config = merge_isolate.union(prev_config, new_config)
  # pylint: disable=E1103
  data = merge_isolate.convert_map_to_gyp(
      *merge_isolate.reduce_inputs(*merge_isolate.invert_map(config.flatten())))
  print 'Updating %s' % complete_state.saved_state.isolate_file
  with open(complete_state.saved_state.isolate_file, 'wb') as f:
    merge_isolate.print_all(config.file_comment, data, f)

  return 0
Ejemplo n.º 2
0
 def test_invert_map(self):
     value = {
         'amiga': {
             'command': ['echo', 'You should get an Atari'],
             KEY_TRACKED: ['a', 'e', 'g', 'x'],
             KEY_UNTRACKED: ['b', 'f', 'h'],
             'read_only': False,
         },
         'atari': {
             'command': ['echo', 'Hello World'],
             KEY_TRACKED: ['a', 'c', 'x'],
             KEY_UNTRACKED: ['b', 'd', 'h'],
             'read_only': True,
         },
         'coleco': {
             'command': ['echo', 'You should get an Atari'],
             KEY_TRACKED: ['a', 'e', 'x'],
             KEY_UNTRACKED: ['b', 'f'],
         },
         'dendy': {
             'command': ['echo', 'You should get an Atari'],
             KEY_TRACKED: ['a', 'e', 'x'],
             KEY_UNTRACKED: ['b', 'f', 'h'],
         },
     }
     expected_values = {
         'command': {
             ('echo', 'Hello World'):
             set(['atari']),
             ('echo', 'You should get an Atari'):
             set(['amiga', 'coleco', 'dendy']),
         },
         KEY_TRACKED: {
             'a': set(['amiga', 'atari', 'coleco', 'dendy']),
             'c': set(['atari']),
             'e': set(['amiga', 'coleco', 'dendy']),
             'g': set(['amiga']),
             'x': set(['amiga', 'atari', 'coleco', 'dendy']),
         },
         KEY_UNTRACKED: {
             'b': set(['amiga', 'atari', 'coleco', 'dendy']),
             'd': set(['atari']),
             'f': set(['amiga', 'coleco', 'dendy']),
             'h': set(['amiga', 'atari', 'dendy']),
         },
         'read_only': {
             None: set(['coleco', 'dendy']),
             False: set(['amiga']),
             True: set(['atari']),
         },
     }
     expected_oses = set(['amiga', 'atari', 'coleco', 'dendy'])
     actual_values, actual_oses = merge_isolate.invert_map(value)
     self.assertEquals(expected_values, actual_values)
     self.assertEquals(expected_oses, actual_oses)
Ejemplo n.º 3
0
 def test_invert_map(self):
   value = {
     'amiga': {
       'command': ['echo', 'You should get an Atari'],
       KEY_TRACKED: ['a', 'e', 'g', 'x'],
       KEY_UNTRACKED: ['b', 'f', 'h'],
       'read_only': False,
     },
     'atari': {
       'command': ['echo', 'Hello World'],
       KEY_TRACKED: ['a', 'c', 'x'],
       KEY_UNTRACKED: ['b', 'd', 'h'],
       'read_only': True,
     },
     'coleco': {
       'command': ['echo', 'You should get an Atari'],
       KEY_TRACKED: ['a', 'e', 'x'],
       KEY_UNTRACKED: ['b', 'f'],
     },
     'dendy': {
       'command': ['echo', 'You should get an Atari'],
       KEY_TRACKED: ['a', 'e', 'x'],
       KEY_UNTRACKED: ['b', 'f', 'h'],
     },
   }
   expected_values = {
     'command': {
       ('echo', 'Hello World'): set(['atari']),
       ('echo', 'You should get an Atari'): set(['amiga', 'coleco', 'dendy']),
     },
     KEY_TRACKED: {
       'a': set(['amiga', 'atari', 'coleco', 'dendy']),
       'c': set(['atari']),
       'e': set(['amiga', 'coleco', 'dendy']),
       'g': set(['amiga']),
       'x': set(['amiga', 'atari', 'coleco', 'dendy']),
     },
     KEY_UNTRACKED: {
       'b': set(['amiga', 'atari', 'coleco', 'dendy']),
       'd': set(['atari']),
       'f': set(['amiga', 'coleco', 'dendy']),
       'h': set(['amiga', 'atari', 'dendy']),
     },
     'read_only': {
       None: set(['coleco', 'dendy']),
       False: set(['amiga']),
       True: set(['atari']),
     },
   }
   expected_oses = set(['amiga', 'atari', 'coleco', 'dendy'])
   actual_values, actual_oses = merge_isolate.invert_map(value)
   self.assertEquals(expected_values, actual_values)
   self.assertEquals(expected_oses, actual_oses)
Ejemplo n.º 4
0
 def test_merge_three_conditions(self):
     values = {
         'linux': {
             'isolate_dependency_tracked': ['file_common', 'file_linux'],
         },
         'mac': {
             'isolate_dependency_tracked': ['file_common', 'file_mac'],
         },
         'win': {
             'isolate_dependency_tracked': ['file_common', 'file_win'],
         },
     }
     expected = {
         'variables': {
             'isolate_dependency_tracked': [
                 'file_common',
             ],
         },
         'conditions': [
             [
                 'OS=="linux"', {
                     'variables': {
                         'isolate_dependency_tracked': [
                             'file_linux',
                         ],
                     },
                 }
             ],
             [
                 'OS=="mac"', {
                     'variables': {
                         'isolate_dependency_tracked': [
                             'file_mac',
                         ],
                     },
                 }
             ],
             [
                 'OS=="win"', {
                     'variables': {
                         'isolate_dependency_tracked': [
                             'file_win',
                         ],
                     },
                 }
             ],
         ],
     }
     actual = merge_isolate.convert_map_to_gyp(*merge_isolate.reduce_inputs(
         *merge_isolate.invert_map(values)))
     self.assertEquals(expected, actual)
Ejemplo n.º 5
0
 def test_merge_three_conditions(self):
   values = {
     'linux': {
       'isolate_dependency_tracked': ['file_common', 'file_linux'],
     },
     'mac': {
       'isolate_dependency_tracked': ['file_common', 'file_mac'],
     },
     'win': {
       'isolate_dependency_tracked': ['file_common', 'file_win'],
     },
   }
   expected = {
     'variables': {
       'isolate_dependency_tracked': [
         'file_common',
       ],
     },
     'conditions': [
       ['OS=="linux"', {
         'variables': {
           'isolate_dependency_tracked': [
             'file_linux',
           ],
         },
       }],
       ['OS=="mac"', {
         'variables': {
           'isolate_dependency_tracked': [
             'file_mac',
           ],
         },
       }],
       ['OS=="win"', {
         'variables': {
           'isolate_dependency_tracked': [
             'file_win',
           ],
         },
       }],
     ],
   }
   actual = merge_isolate.convert_map_to_gyp(*merge_isolate.reduce_inputs(
     *merge_isolate.invert_map(values)))
   self.assertEquals(expected, actual)
Ejemplo n.º 6
0
 def test_merge_empty(self):
   actual = merge_isolate.convert_map_to_gyp(*merge_isolate.reduce_inputs(
       *merge_isolate.invert_map({})))
   self.assertEquals({}, actual)
Ejemplo n.º 7
0
 def test_merge_empty(self):
     actual = merge_isolate.convert_map_to_gyp(*merge_isolate.reduce_inputs(
         *merge_isolate.invert_map({})))
     self.assertEquals({}, actual)