示例#1
0
 def test_merge_two_empty(self):
     # Flat stay flat. Pylint is confused about union() return type.
     # pylint: disable=E1103
     actual = merge_isolate.union(
         merge_isolate.union(merge_isolate.Configs([]),
                             merge_isolate.load_gyp({})),
         merge_isolate.load_gyp({})).flatten()
     self.assertEquals({}, actual)
示例#2
0
 def test_load_three_conditions(self):
   linux = {
     'conditions': [
       ['OS=="linux"', {
         'variables': {
           'isolate_dependency_tracked': [
             'file_linux',
             'file_common',
           ],
         },
       }],
     ],
   }
   mac = {
     'conditions': [
       ['OS=="mac"', {
         'variables': {
           'isolate_dependency_tracked': [
             'file_mac',
             'file_common',
           ],
         },
       }],
     ],
   }
   win = {
     'conditions': [
       ['OS=="win"', {
         'variables': {
           'isolate_dependency_tracked': [
             'file_win',
             'file_common',
           ],
         },
       }],
     ],
   }
   expected = {
     'linux': {
       'isolate_dependency_tracked': ['file_common', 'file_linux'],
     },
     'mac': {
       'isolate_dependency_tracked': ['file_common', 'file_mac'],
     },
     'win': {
       'isolate_dependency_tracked': ['file_common', 'file_win'],
     },
   }
   # Pylint is confused about union() return type.
   # pylint: disable=E1103
   configs = merge_isolate.union(
       merge_isolate.union(
         merge_isolate.union(
           merge_isolate.Configs([], None),
           merge_isolate.load_gyp(linux, None, [])),
         merge_isolate.load_gyp(mac, None, [])),
       merge_isolate.load_gyp(win, None, [])).flatten()
   self.assertEquals(expected, configs)
示例#3
0
 def test_merge_two_empty(self):
   # Flat stay flat. Pylint is confused about union() return type.
   # pylint: disable=E1103
   actual = merge_isolate.union(
       merge_isolate.union(
         merge_isolate.Configs([], None),
         merge_isolate.load_gyp({}, None, [])),
       merge_isolate.load_gyp({}, None, [])).flatten()
   self.assertEquals({}, actual)
示例#4
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
示例#5
0
  def test_configs_comment(self):
    # Pylint is confused with merge_isolate.union() return type.
    # pylint: disable=E1103
    configs = merge_isolate.union(
        merge_isolate.load_gyp({}, '# Yo dawg!\n# Chill out.\n', []),
        merge_isolate.load_gyp({}, None, []))
    self.assertEquals('# Yo dawg!\n# Chill out.\n', configs.file_comment)

    configs = merge_isolate.union(
        merge_isolate.load_gyp({}, None, []),
        merge_isolate.load_gyp({}, '# Yo dawg!\n# Chill out.\n', []))
    self.assertEquals('# Yo dawg!\n# Chill out.\n', configs.file_comment)

    # Only keep the first one.
    configs = merge_isolate.union(
        merge_isolate.load_gyp({}, '# Yo dawg!\n', []),
        merge_isolate.load_gyp({}, '# Chill out.\n', []))
    self.assertEquals('# Yo dawg!\n', configs.file_comment)
示例#6
0
    def test_configs_comment(self):
        # Pylint is confused with merge_isolate.union() return type.
        # pylint: disable=E1103
        configs = merge_isolate.union(
            merge_isolate.load_gyp({}, '# Yo dawg!\n# Chill out.\n', []),
            merge_isolate.load_gyp({}, None, []))
        self.assertEquals('# Yo dawg!\n# Chill out.\n', configs.file_comment)

        configs = merge_isolate.union(
            merge_isolate.load_gyp({}, None, []),
            merge_isolate.load_gyp({}, '# Yo dawg!\n# Chill out.\n', []))
        self.assertEquals('# Yo dawg!\n# Chill out.\n', configs.file_comment)

        # Only keep the first one.
        configs = merge_isolate.union(
            merge_isolate.load_gyp({}, '# Yo dawg!\n', []),
            merge_isolate.load_gyp({}, '# Chill out.\n', []))
        self.assertEquals('# Yo dawg!\n', configs.file_comment)
示例#7
0
 def test_load_two_conditions(self):
     linux = {
         'conditions': [
             [
                 'OS=="linux"', {
                     'variables': {
                         'isolate_dependency_tracked': [
                             'file_linux',
                             'file_common',
                         ],
                     },
                 }
             ],
         ],
     }
     mac = {
         'conditions': [
             [
                 'OS=="mac"', {
                     'variables': {
                         'isolate_dependency_tracked': [
                             'file_mac',
                             'file_common',
                         ],
                     },
                 }
             ],
         ],
     }
     expected = {
         'linux': {
             'isolate_dependency_tracked': ['file_common', 'file_linux'],
         },
         'mac': {
             'isolate_dependency_tracked': ['file_common', 'file_mac'],
         },
     }
     # Pylint is confused about union() return type.
     # pylint: disable=E1103
     configs = merge_isolate.union(
         merge_isolate.union(merge_isolate.Configs([]),
                             merge_isolate.load_gyp(linux)),
         merge_isolate.load_gyp(mac)).flatten()
     self.assertEquals(expected, configs)
示例#8
0
 def test_union(self):
   value1 = {
     'a': set(['A']),
     'b': ['B', 'C'],
     'c': 'C',
   }
   value2 = {
     'a': set(['B', 'C']),
     'b': [],
     'd': set(),
   }
   expected = {
     'a': set(['A', 'B', 'C']),
     'b': ['B', 'C'],
     'c': 'C',
     'd': set(),
   }
   self.assertEquals(expected, merge_isolate.union(value1, value2))
示例#9
0
 def test_union(self):
     value1 = {
         'a': set(['A']),
         'b': ['B', 'C'],
         'c': 'C',
     }
     value2 = {
         'a': set(['B', 'C']),
         'b': [],
         'd': set(),
     }
     expected = {
         'a': set(['A', 'B', 'C']),
         'b': ['B', 'C'],
         'c': 'C',
         'd': set(),
     }
     self.assertEquals(expected, merge_isolate.union(value1, value2))