コード例 #1
0
 def test_union_multi_variables(self):
   data1 = {
     'conditions': [
       ['OS=="abc"', {
         'variables': {
           'command': ['bar'],
         },
       }],
     ],
   }
   data2 = {
     'conditions': [
       ['CHROMEOS=="1"', {
         'variables': {
           'command': ['foo'],
         },
       }],
     ],
   }
   configs1 = isolate_format.load_isolate_as_config(FAKE_DIR, data1, None)
   configs2 = isolate_format.load_isolate_as_config(FAKE_DIR, data2, None)
   configs = configs1.union(configs2)
   self.assertEqual(('CHROMEOS', 'OS'), configs.config_variables)
   flatten = dict((k, v.flatten()) for k, v in configs._by_config.iteritems())
   expected = {
       ((None, 'abc')): {'command': ['bar']},
       ('1', None): {'command': ['foo']},
   }
   self.assertEqual(expected, flatten)
コード例 #2
0
 def test_load_three_conditions(self):
   linux = {
     'conditions': [
       ['OS=="linux" and chromeos==1', {
         'variables': {
           'isolate_dependency_tracked': [
             'file_linux',
             'file_common',
           ],
         },
       }],
     ],
   }
   mac = {
     'conditions': [
       ['OS=="mac" and chromeos==0', {
         'variables': {
           'isolate_dependency_tracked': [
             'file_mac',
             'file_common',
           ],
         },
       }],
     ],
   }
   win = {
     'conditions': [
       ['OS=="win" and chromeos==0', {
         'variables': {
           'isolate_dependency_tracked': [
             'file_win',
             'file_common',
           ],
         },
       }],
     ],
   }
   expected = {
     ('linux', 1): {
       'isolate_dependency_tracked': ['file_common', 'file_linux'],
     },
     ('mac', 0): {
       'isolate_dependency_tracked': ['file_common', 'file_mac'],
     },
     ('win', 0): {
       'isolate_dependency_tracked': ['file_common', 'file_win'],
     },
   }
   # Pylint is confused about union() return type.
   # pylint: disable=E1103
   configs = isolate_format.union(
       isolate_format.union(
         isolate_format.union(
           isolate_format.Configs(None, ()),
           isolate_format.load_isolate_as_config(FAKE_DIR, linux, None)),
         isolate_format.load_isolate_as_config(FAKE_DIR, mac, None)),
       isolate_format.load_isolate_as_config(FAKE_DIR, win, None))
   self.assertEqual(expected, configs.flatten())
コード例 #3
0
 def test_merge_two_empty(self):
   # Flat stay flat. Pylint is confused about union() return type.
   # pylint: disable=E1103
   actual = isolate_format.union(
       isolate_format.union(
         isolate_format.Configs(None, ()),
         isolate_format.load_isolate_as_config(FAKE_DIR, {}, None)),
       isolate_format.load_isolate_as_config(FAKE_DIR, {}, None)).flatten()
   self.assertEqual({}, actual)
コード例 #4
0
 def test_merge_two_empty(self):
     actual = isolate_format.Configs(None, ()).union(
         isolate_format.load_isolate_as_config(FAKE_DIR, {}, None)).union(
             isolate_format.load_isolate_as_config(FAKE_DIR, {}, None))
     expected = {
         (): {
             'isolate_dir': FAKE_DIR,
         },
     }
     self.assertEqual(expected, actual.flatten())
コード例 #5
0
ファイル: isolate_format_test.py プロジェクト: ChMarina/v8_vm
 def test_merge_two_empty(self):
     # Flat stay flat. Pylint is confused about union() return type.
     # pylint: disable=E1103
     actual = isolate_format.Configs(None, ()).union(
         isolate_format.load_isolate_as_config(FAKE_DIR, {}, None)).union(
             isolate_format.load_isolate_as_config(FAKE_DIR, {}, None))
     expected = {
         (): {
             'isolate_dir': FAKE_DIR,
         },
     }
     self.assertEqual(expected, actual.flatten())
コード例 #6
0
 def test_merge_two_empty(self):
   # Flat stay flat. Pylint is confused about union() return type.
   # pylint: disable=E1103
   actual = isolate_format.Configs(None, ()).union(
       isolate_format.load_isolate_as_config(FAKE_DIR, {}, None)).union(
           isolate_format.load_isolate_as_config(FAKE_DIR, {}, None))
   expected = {
     (): {
       'isolate_dir': FAKE_DIR,
     },
   }
   self.assertEqual(expected, actual.flatten())
コード例 #7
0
 def test_convert_old_to_new_else(self):
   isolate_with_else_clauses = {
     'conditions': [
       ['OS=="mac"', {
         'variables': {'foo': 'bar'},
       }, {
         'variables': {'x': 'y'},
       }],
     ],
   }
   with self.assertRaises(isolate_format.IsolateError):
     isolate_format.load_isolate_as_config(
         FAKE_DIR, isolate_with_else_clauses, None)
コード例 #8
0
 def test_convert_old_to_new_else(self):
   isolate_with_else_clauses = {
     'conditions': [
       ['OS=="mac"', {
         'variables': {'foo': 'bar'},
       }, {
         'variables': {'x': 'y'},
       }],
     ],
   }
   with self.assertRaises(isolate_format.isolateserver.ConfigError):
     isolate_format.load_isolate_as_config(
         FAKE_DIR, isolate_with_else_clauses, None)
コード例 #9
0
ファイル: isolate_format_test.py プロジェクト: ChMarina/v8_vm
 def test_load_two_conditions(self):
     linux = {
         'conditions': [
             [
                 'OS=="linux"', {
                     'variables': {
                         'files': [
                             'file_linux',
                             'file_common',
                         ],
                     },
                 }
             ],
         ],
     }
     mac = {
         'conditions': [
             [
                 'OS=="mac"', {
                     'variables': {
                         'files': [
                             'file_mac',
                             'file_common',
                         ],
                     },
                 }
             ],
         ],
     }
     expected = {
         (None, ): {
             'isolate_dir': FAKE_DIR,
         },
         ('linux', ): {
             'files': ['file_common', 'file_linux'],
             'isolate_dir': FAKE_DIR,
         },
         ('mac', ): {
             'files': ['file_common', 'file_mac'],
             'isolate_dir': FAKE_DIR,
         },
     }
     # Pylint is confused about union() return type.
     # pylint: disable=E1103
     configs = isolate_format.Configs(None, ()).union(
         isolate_format.load_isolate_as_config(
             FAKE_DIR, linux, None)).union(
                 isolate_format.load_isolate_as_config(FAKE_DIR, mac,
                                                       None)).flatten()
     self.assertEqual(expected, configs)
コード例 #10
0
def load_isolate_as_config(args, stdin):
    # Reads isolate content from stdin .
    isolate_dir, = args
    # file_comment is "" .
    out = isolate_format.load_isolate_as_config(isolate_dir,
                                                eval(stdin.read()), "")

    # we pass output to Go as json

    def convKey(valuesOfKeys):
        return [{
            'Value': '' if k is None else k[0],
            'IsBound': not (k is None),
        } for k in valuesOfKeys]

    def convValue(v):
        r = -1 if v.read_only is None else v.read_only
        return {
            'ReadOnly': r,
            'Files': v.files,
            'Command': v.command,
            'IsolateDir': v.isolate_dir,
        }

    return {
        'ConfigVariables':
        out.config_variables,
        'ByConfig':
        list({
            'key': convKey(k),
            'value': convValue(v)
        } for k, v in out._by_config.iteritems()),
    }
コード例 #11
0
 def test_load_multi_variables(self):
   # Load an .isolate with different condition on different variables.
   data = {
     'conditions': [
       ['OS=="abc"', {
         'variables': {
           'command': ['bar'],
         },
       }],
       ['CHROMEOS=="1"', {
         'variables': {
           'command': ['foo'],
         },
       }],
     ],
   }
   configs = isolate_format.load_isolate_as_config(FAKE_DIR, data, None)
   self.assertEqual(('CHROMEOS', 'OS'), configs.config_variables)
   flatten = dict((k, v.flatten()) for k, v in configs._by_config.iteritems())
   expected = {
       ((None, 'abc')): {'command': ['bar']},
       (('1', None)): {'command': ['foo']},
       # TODO(maruel): It is a conflict.
       (('1', 'abc')): {'command': ['bar']},
   }
   self.assertEqual(expected, flatten)
コード例 #12
0
def load_isolates(items):
    """Parses each .isolate file and returns the merged results.

  It only loads what load_isolate_as_config() can process.

  Return values:
    files: dict(filename, set(OS where this filename is a dependency))
    dirs:  dict(dirame, set(OS where this dirname is a dependency))
    oses:  set(all the OSes referenced)
  """
    # pylint: disable=W0212
    configs = isolate_format.Configs(None, ())
    for item in items:
        item = os.path.abspath(item)
        logging.debug('loading %s' % item)
        if item == '-':
            content = sys.stdin.read()
        else:
            with open(item, 'r') as f:
                content = f.read()
        new_config = isolate_format.load_isolate_as_config(
            os.path.dirname(item), isolate_format.eval_content(content),
            isolate_format.extract_comment(content))
        logging.debug('has configs: ' +
                      ','.join(map(repr, new_config._by_config)))
        configs = configs.union(new_config)
    logging.debug('Total configs: ' + ','.join(map(repr, configs._by_config)))
    return configs
コード例 #13
0
def load_isolates(items):
    """Parses each .isolate file and returns the merged results.

  It only loads what load_isolate_as_config() can process.

  Return values:
    files: dict(filename, set(OS where this filename is a dependency))
    dirs:  dict(dirame, set(OS where this dirname is a dependency))
    oses:  set(all the OSes referenced)
  """
    # pylint: disable=W0212
    configs = None
    for item in items:
        item = os.path.abspath(item)
        logging.debug("loading %s" % item)
        if item == "-":
            content = sys.stdin.read()
        else:
            with open(item, "r") as f:
                content = f.read()
        new_config = load_isolate_as_config(os.path.dirname(item), eval_content(content), extract_comment(content))
        logging.debug("has configs: " + ",".join(map(repr, new_config._by_config)))
        configs = union(configs, new_config)
    logging.debug("Total configs: " + ",".join(map(repr, configs._by_config)))
    return configs
コード例 #14
0
ファイル: isolate_merge.py プロジェクト: WHS-TechOps/Aviator
def load_isolates(items):
  """Parses each .isolate file and returns the merged results.

  It only loads what load_isolate_as_config() can process.

  Return values:
    files: dict(filename, set(OS where this filename is a dependency))
    dirs:  dict(dirame, set(OS where this dirname is a dependency))
    oses:  set(all the OSes referenced)
  """
  # pylint: disable=W0212
  configs = isolate_format.Configs(None, ())
  for item in items:
    item = os.path.abspath(item)
    logging.debug('loading %s' % item)
    if item == '-':
      content = sys.stdin.read()
    else:
      with open(item, 'r') as f:
        content = f.read()
    new_config = isolate_format.load_isolate_as_config(
        os.path.dirname(item),
        isolate_format.eval_content(content),
        isolate_format.extract_comment(content))
    logging.debug('has configs: ' + ','.join(map(repr, new_config._by_config)))
    configs = configs.union(new_config)
  logging.debug('Total configs: ' + ','.join(map(repr, configs._by_config)))
  return configs
コード例 #15
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 = {
     (None,): {
       'isolate_dir': FAKE_DIR,
     },
     ('linux',): {
       'isolate_dependency_tracked': ['file_common', 'file_linux'],
       'isolate_dir': FAKE_DIR,
     },
     ('mac',): {
       'isolate_dependency_tracked': ['file_common', 'file_mac'],
       'isolate_dir': FAKE_DIR,
     },
   }
   # Pylint is confused about union() return type.
   # pylint: disable=E1103
   configs = isolate_format.Configs(None, ()).union(
       isolate_format.load_isolate_as_config(FAKE_DIR, linux, None)).union(
           isolate_format.load_isolate_as_config(FAKE_DIR, mac, None)
       ).flatten()
   self.assertEqual(expected, configs)
コード例 #16
0
 def test_load_isolate_as_config_empty(self):
   expected = {
     (): {
       'isolate_dir': FAKE_DIR,
     },
   }
   self.assertEqual(
       expected,
       isolate_format.load_isolate_as_config(FAKE_DIR, {}, None).flatten())
コード例 #17
0
 def test_load_isolate_as_config_duplicate_command(self):
   value = {
     'variables': {
       'command': ['rm', '-rf', '/'],
     },
     'conditions': [
       ['OS=="atari"', {
         'variables': {
           'command': ['echo', 'Hello World'],
         },
       }],
     ],
   }
   try:
     isolate_format.load_isolate_as_config(FAKE_DIR, value, None)
     self.fail()
   except AssertionError:
     pass
コード例 #18
0
 def test_load_with_globals(self):
   values = {
     'variables': {
       'isolate_dependency_tracked': [
         'file_common',
       ],
     },
     'conditions': [
       ['OS=="linux"', {
         'variables': {
           'isolate_dependency_tracked': [
             'file_linux',
           ],
           'read_only': 1,
         },
       }],
       ['OS=="mac" or OS=="win"', {
         'variables': {
           'isolate_dependency_tracked': [
             'file_non_linux',
           ],
           'read_only': 0,
         },
       }],
     ],
   }
   expected = {
     (None,): {
       'isolate_dependency_tracked': [
         'file_common',
       ],
       'isolate_dir': FAKE_DIR,
     },
     ('linux',): {
       'isolate_dependency_tracked': [
         'file_linux',
       ],
       'isolate_dir': FAKE_DIR,
       'read_only': 1,
     },
     ('mac',): {
       'isolate_dependency_tracked': [
         'file_non_linux',
       ],
       'isolate_dir': FAKE_DIR,
       'read_only': 0,
     },
     ('win',): {
       'isolate_dependency_tracked': [
         'file_non_linux',
       ],
       'isolate_dir': FAKE_DIR,
       'read_only': 0,
     },
   }
   actual = isolate_format.load_isolate_as_config(FAKE_DIR, values, None)
   self.assertEqual(expected, actual.flatten())
コード例 #19
0
 def test_load_isolate_as_config_duplicate_command(self):
   value = {
     'variables': {
       'command': ['rm', '-rf', '/'],
     },
     'conditions': [
       ['OS=="atari"', {
         'variables': {
           'command': ['echo', 'Hello World'],
         },
       }],
     ],
   }
   try:
     isolate_format.load_isolate_as_config(FAKE_DIR, value, None)
     self.fail()
   except AssertionError:
     pass
コード例 #20
0
 def test_load_with_globals(self):
   values = {
     'variables': {
       'files': [
         'file_common',
       ],
     },
     'conditions': [
       ['OS=="linux"', {
         'variables': {
           'files': [
             'file_linux',
           ],
           'read_only': 1,
         },
       }],
       ['OS=="mac" or OS=="win"', {
         'variables': {
           'files': [
             'file_non_linux',
           ],
           'read_only': 0,
         },
       }],
     ],
   }
   expected = {
     (None,): {
       'files': [
         'file_common',
       ],
       'isolate_dir': FAKE_DIR,
     },
     ('linux',): {
       'files': [
         'file_linux',
       ],
       'isolate_dir': FAKE_DIR,
       'read_only': 1,
     },
     ('mac',): {
       'files': [
         'file_non_linux',
       ],
       'isolate_dir': FAKE_DIR,
       'read_only': 0,
     },
     ('win',): {
       'files': [
         'file_non_linux',
       ],
       'isolate_dir': FAKE_DIR,
       'read_only': 0,
     },
   }
   actual = isolate_format.load_isolate_as_config(FAKE_DIR, values, None)
   self.assertEqual(expected, actual.flatten())
コード例 #21
0
 def test_load_isolate_as_config_empty(self):
   expected = {
     (): {
       'isolate_dir': FAKE_DIR,
     },
   }
   self.assertEqual(
       expected,
       isolate_format.load_isolate_as_config(FAKE_DIR, {}, None).flatten())
コード例 #22
0
 def test_union_multi_variables(self):
     data1 = {
         'conditions': [
             ['OS=="abc"', {
                 'variables': {
                     'command': ['bar'],
                 },
             }],
         ],
     }
     data2 = {
         'conditions': [
             ['CHROMEOS=="1"', {
                 'variables': {
                     'command': ['foo'],
                 },
             }],
         ],
     }
     configs1 = isolate_format.load_isolate_as_config(FAKE_DIR, data1, None)
     configs2 = isolate_format.load_isolate_as_config(FAKE_DIR, data2, None)
     configs = configs1.union(configs2)
     self.assertEqual(('CHROMEOS', 'OS'), configs.config_variables)
     flatten = dict(
         (k, v.flatten()) for k, v in configs._by_config.iteritems())
     expected = {
         (None, None): {
             'isolate_dir': FAKE_DIR,
         },
         (None, 'abc'): {
             'command': ['bar'],
             'isolate_dir': FAKE_DIR,
         },
         ('1', None): {
             'command': ['foo'],
             'isolate_dir': FAKE_DIR,
         },
     }
     self.assertEqual(expected, flatten)
コード例 #23
0
 def test_load_isolate_as_config_no_variable(self):
   value = {
     'variables': {
       'command': ['echo', 'You should get an Atari'],
       'files': ['a', 'b', 'touched'],
       'read_only': 1,
     },
   }
   # The key is the empty tuple, since there is no variable to bind to.
   expected = {
     (): {
       'command': ['echo', 'You should get an Atari'],
       'files': ['a', 'b', 'touched'],
       'isolate_dir': FAKE_DIR,
       'read_only': 1,
     },
   }
   self.assertEqual(
       expected, isolate_format.load_isolate_as_config(
           FAKE_DIR, value, None).flatten())
コード例 #24
0
 def test_load_isolate_as_config_no_variable(self):
   value = {
     'variables': {
       'command': ['echo', 'You should get an Atari'],
       'files': ['a', 'b', 'touched'],
       'read_only': 1,
     },
   }
   # The key is the empty tuple, since there is no variable to bind to.
   expected = {
     (): {
       'command': ['echo', 'You should get an Atari'],
       'files': ['a', 'b', 'touched'],
       'isolate_dir': FAKE_DIR,
       'read_only': 1,
     },
   }
   self.assertEqual(
       expected, isolate_format.load_isolate_as_config(
           FAKE_DIR, value, None).flatten())
コード例 #25
0
 def test_load_multi_variables(self):
     # Load an .isolate with different condition on different variables.
     data = {
         'conditions': [
             ['OS=="abc"', {
                 'variables': {
                     'command': ['bar'],
                 },
             }],
             ['CHROMEOS=="1"', {
                 'variables': {
                     'command': ['foo'],
                 },
             }],
         ],
     }
     configs = isolate_format.load_isolate_as_config(FAKE_DIR, data, None)
     self.assertEqual(('CHROMEOS', 'OS'), configs.config_variables)
     flatten = dict(
         (k, v.flatten()) for k, v in configs._by_config.iteritems())
     expected = {
         (None, None): {
             'isolate_dir': FAKE_DIR,
         },
         (None, 'abc'): {
             'command': ['bar'],
             'isolate_dir': FAKE_DIR,
         },
         ('1', None): {
             'command': ['foo'],
             'isolate_dir': FAKE_DIR,
         },
         # TODO(maruel): It is a conflict.
         ('1', 'abc'): {
             'command': ['bar'],
             'isolate_dir': FAKE_DIR,
         },
     }
     self.assertEqual(expected, flatten)
コード例 #26
0
    def test_configs_comment(self):
        configs = isolate_format.load_isolate_as_config(
            FAKE_DIR, {}, '# Yo dawg!\n# Chill out.\n').union(
                isolate_format.load_isolate_as_config(FAKE_DIR, {}, None))
        self.assertEqual('# Yo dawg!\n# Chill out.\n', configs.file_comment)

        configs = isolate_format.load_isolate_as_config(
            FAKE_DIR, {}, None).union(
                isolate_format.load_isolate_as_config(
                    FAKE_DIR, {}, '# Yo dawg!\n# Chill out.\n'))
        self.assertEqual('# Yo dawg!\n# Chill out.\n', configs.file_comment)

        # Only keep the first one.
        configs = isolate_format.load_isolate_as_config(
            FAKE_DIR, {}, '# Yo dawg!\n').union(
                isolate_format.load_isolate_as_config(FAKE_DIR, {},
                                                      '# Chill out.\n'))
        self.assertEqual('# Yo dawg!\n', configs.file_comment)
コード例 #27
0
  def test_configs_comment(self):
    # Pylint is confused with isolate_format.union() return type.
    # pylint: disable=E1103
    configs = isolate_format.load_isolate_as_config(
            FAKE_DIR, {}, '# Yo dawg!\n# Chill out.\n').union(
        isolate_format.load_isolate_as_config(FAKE_DIR, {}, None))
    self.assertEqual('# Yo dawg!\n# Chill out.\n', configs.file_comment)

    configs = isolate_format.load_isolate_as_config(FAKE_DIR, {}, None).union(
        isolate_format.load_isolate_as_config(
            FAKE_DIR, {}, '# Yo dawg!\n# Chill out.\n'))
    self.assertEqual('# Yo dawg!\n# Chill out.\n', configs.file_comment)

    # Only keep the first one.
    configs = isolate_format.load_isolate_as_config(
        FAKE_DIR, {}, '# Yo dawg!\n').union(
            isolate_format.load_isolate_as_config(
                FAKE_DIR, {}, '# Chill out.\n'))
    self.assertEqual('# Yo dawg!\n', configs.file_comment)
コード例 #28
0
  def test_configs_comment(self):
    # Pylint is confused with isolate_format.union() return type.
    # pylint: disable=E1103
    configs = isolate_format.load_isolate_as_config(
            FAKE_DIR, {}, '# Yo dawg!\n# Chill out.\n').union(
        isolate_format.load_isolate_as_config(FAKE_DIR, {}, None))
    self.assertEqual('# Yo dawg!\n# Chill out.\n', configs.file_comment)

    configs = isolate_format.load_isolate_as_config(FAKE_DIR, {}, None).union(
        isolate_format.load_isolate_as_config(
            FAKE_DIR, {}, '# Yo dawg!\n# Chill out.\n'))
    self.assertEqual('# Yo dawg!\n# Chill out.\n', configs.file_comment)

    # Only keep the first one.
    configs = isolate_format.load_isolate_as_config(
        FAKE_DIR, {}, '# Yo dawg!\n').union(
            isolate_format.load_isolate_as_config(
                FAKE_DIR, {}, '# Chill out.\n'))
    self.assertEqual('# Yo dawg!\n', configs.file_comment)
コード例 #29
0
  def test_load_with_includes_with_commands_and_variables(self):
    # This one is the pinacle of fun. Check that isolate_dir is the expected
    # value. To achieve this, put the .isolate files into subdirectories.
    dir_1 = os.path.join(self.tempdir, '1')
    dir_3 = os.path.join(self.tempdir, '3')
    dir_3_2 = os.path.join(self.tempdir, '3', '2')
    os.mkdir(dir_1)
    os.mkdir(dir_3)
    os.mkdir(dir_3_2)

    isolate1 = {
      'conditions': [
        ['OS=="amiga" or OS=="win"', {
          'variables': {
            'command': [
              'foo', 'amiga_or_win', '<(PATH)',
            ],
          },
        }],
        ['OS=="linux"', {
          'variables': {
            'command': [
              'foo', 'linux', '<(PATH)',
            ],
            'isolate_dependency_tracked': [
              '<(PATH)/file_linux',
            ],
          },
        }],
        ['OS=="mac" or OS=="win"', {
          'variables': {
            'isolate_dependency_tracked': [
              '<(PATH)/file_non_linux',
            ],
          },
        }],
      ],
    }
    isolate2 = {
      'conditions': [
        ['OS=="linux" or OS=="mac"', {
          'variables': {
            'command': [
              'foo', 'linux_or_mac', '<(PATH)',
            ],
            'isolate_dependency_tracked': [
              '<(PATH)/other/file',
            ],
          },
        }],
      ],
    }
    isolate3 = {
      'includes': [
        '../1/isolate1.isolate',
        '2/isolate2.isolate',
      ],
      'conditions': [
        ['OS=="amiga"', {
          'variables': {
            'isolate_dependency_tracked': [
              '<(PATH)/file_amiga',
            ],
          },
        }],
        ['OS=="mac"', {
          'variables': {
            'command': [
              'foo', 'mac', '<(PATH)',
            ],
            'isolate_dependency_tracked': [
              '<(PATH)/file_mac',
            ],
          },
        }],
      ],
    }
    # No need to write isolate3.
    with open(os.path.join(dir_1, 'isolate1.isolate'), 'wb') as f:
      isolate_format.pretty_print(isolate1, f)
    with open(os.path.join(dir_3_2, 'isolate2.isolate'), 'wb') as f:
      isolate_format.pretty_print(isolate2, f)

    # The 'isolate_dir' are important, they are what will be used when
    # definining the final isolate_dir to use to run the command in the
    # .isolated file.
    actual = isolate_format.load_isolate_as_config(dir_3, isolate3, None)
    expected = {
      (None,): {
        'isolate_dir': dir_1,
      },
      ('amiga',): {
        'command': ['foo', 'amiga_or_win', '<(PATH)'],
        'isolate_dependency_tracked': [
          '<(PATH)/file_amiga',
        ],
        'isolate_dir': dir_1,
      },
      ('linux',): {
        # Last included takes precedence. *command comes from isolate2*, so
        # it becomes the canonical root, so reference to file from isolate1 is
        # via '../../1'.
        'command': ['foo', 'linux_or_mac', '<(PATH)'],
        'isolate_dependency_tracked': [
          '<(PATH)/file_linux',
          '<(PATH)/other/file',
        ],
        'isolate_dir': dir_3_2,
      },
      ('mac',): {
        'command': ['foo', 'mac', '<(PATH)'],
        'isolate_dependency_tracked': [
          '<(PATH)/file_mac',
          '<(PATH)/file_non_linux',
          '<(PATH)/other/file',
        ],
        'isolate_dir': dir_3,
      },
      ('win',): {
        # command comes from isolate1.
        'command': ['foo', 'amiga_or_win', '<(PATH)'],
        'isolate_dependency_tracked': [
          '<(PATH)/file_non_linux',
        ],
        'isolate_dir': dir_1,
      },
    }
    self.assertEqual(expected, actual.flatten())
コード例 #30
0
 def test_load_three_conditions(self):
     linux = {
         'conditions': [
             [
                 'OS=="linux" and chromeos==1', {
                     'variables': {
                         'files': [
                             'file_linux',
                             'file_common',
                         ],
                     },
                 }
             ],
         ],
     }
     mac = {
         'conditions': [
             [
                 'OS=="mac" and chromeos==0', {
                     'variables': {
                         'files': [
                             'file_mac',
                             'file_common',
                         ],
                     },
                 }
             ],
         ],
     }
     win = {
         'conditions': [
             [
                 'OS=="win" and chromeos==0', {
                     'variables': {
                         'files': [
                             'file_win',
                             'file_common',
                         ],
                     },
                 }
             ],
         ],
     }
     expected = {
         (None, None): {
             'isolate_dir': FAKE_DIR,
         },
         ('linux', 1): {
             'files': ['file_common', 'file_linux'],
             'isolate_dir': FAKE_DIR,
         },
         ('mac', 0): {
             'files': ['file_common', 'file_mac'],
             'isolate_dir': FAKE_DIR,
         },
         ('win', 0): {
             'files': ['file_common', 'file_win'],
             'isolate_dir': FAKE_DIR,
         },
     }
     configs = isolate_format.Configs(None, ()).union(
         isolate_format.load_isolate_as_config(
             FAKE_DIR, linux, None)).union(
                 isolate_format.load_isolate_as_config(
                     FAKE_DIR, mac, None)).union(
                         isolate_format.load_isolate_as_config(
                             FAKE_DIR, win, None))
     self.assertEqual(expected, configs.flatten())
コード例 #31
0
  def test_load_with_includes_with_commands(self):
    # This one is messy.
    isolate1 = {
      'conditions': [
        ['OS=="linux"', {
          'variables': {
            'command': [
              'foo', 'bar',
            ],
            'isolate_dependency_tracked': [
              'file_linux',
            ],
          },
        }, {
          'variables': {
            'isolate_dependency_tracked': [
              'file_non_linux',
            ],
          },
        }],
        ['OS=="win"', {
          'variables': {
            'command': [
              'foo', 'bar',
            ],
          },
        }],
      ],
    }
    tools.write_json(
        os.path.join(self.tempdir, 'isolate1.isolate'), isolate1, True)
    isolate2 = {
      'conditions': [
        ['OS=="linux" or OS=="mac"', {
          'variables': {
            'command': [
              'zoo',
            ],
            'isolate_dependency_tracked': [
              'other/file',
            ],
          },
        }],
      ],
    }
    tools.write_json(
        os.path.join(self.tempdir, 'isolate2.isolate'), isolate2, True)
    isolate3 = {
      'includes': ['isolate1.isolate', 'isolate2.isolate'],
      'conditions': [
        ['OS=="mac"', {
          'variables': {
            'command': [
              'yo', 'dawg',
            ],
            'isolate_dependency_tracked': [
              'file_mac',
            ],
          },
        }],
      ],
    }

    actual = isolate_format.load_isolate_as_config(self.tempdir, isolate3, None)
    expected = {
      ('linux',): {
        # Last included takes precedence.
        'command': ['zoo'],
        'isolate_dependency_tracked': ['file_linux', 'other/file'],
      },
      ('mac',): {
        # Command in isolate3 takes precedence.
        'command': ['yo', 'dawg'],
        'isolate_dependency_tracked': [
          'file_mac',
          'file_non_linux',
          'other/file',
        ],
      },
      ('win',): {
        'command': ['foo', 'bar'],
        'isolate_dependency_tracked': ['file_non_linux'],
      },
    }
    self.assertEqual(expected, actual.flatten())
コード例 #32
0
 def test_load_isolate_as_config_empty(self):
   self.assertEqual({}, isolate_format.load_isolate_as_config(
       FAKE_DIR, {}, None).flatten())
コード例 #33
0
 def test_load_isolate_as_config(self):
   value = {
     'conditions': [
       ['OS=="amiga" or OS=="atari" or OS=="coleco" or OS=="dendy"', {
         'variables': {
           KEY_TRACKED: ['a'],
           KEY_UNTRACKED: ['b'],
           KEY_TOUCHED: ['touched'],
         },
       }],
       ['OS=="atari"', {
         'variables': {
           KEY_TRACKED: ['c', 'x'],
           KEY_UNTRACKED: ['d'],
           KEY_TOUCHED: ['touched_a'],
           'command': ['echo', 'Hello World'],
           'read_only': 2,
         },
       }],
       ['OS=="amiga" or OS=="coleco" or OS=="dendy"', {
         'variables': {
           KEY_TRACKED: ['e', 'x'],
           KEY_UNTRACKED: ['f'],
           KEY_TOUCHED: ['touched_e'],
           'command': ['echo', 'You should get an Atari'],
         },
       }],
       ['OS=="amiga"', {
         'variables': {
           KEY_TRACKED: ['g'],
           'read_only': 1,
         },
       }],
       ['OS=="amiga" or OS=="atari" or OS=="dendy"', {
         'variables': {
           KEY_UNTRACKED: ['h'],
         },
       }],
     ],
   }
   expected = {
     (None,): {
       'isolate_dir': FAKE_DIR,
     },
     ('amiga',): {
       KEY_TOUCHED: ['touched', 'touched_e'],
       KEY_TRACKED: ['a', 'e', 'g', 'x'],
       KEY_UNTRACKED: ['b', 'f', 'h'],
       'command': ['echo', 'You should get an Atari'],
       'isolate_dir': FAKE_DIR,
       'read_only': 1,
     },
     ('atari',): {
       KEY_TOUCHED: ['touched', 'touched_a'],
       KEY_TRACKED: ['a', 'c', 'x'],
       KEY_UNTRACKED: ['b', 'd', 'h'],
       'command': ['echo', 'Hello World'],
       'isolate_dir': FAKE_DIR,
       'read_only': 2,
     },
     ('coleco',): {
       KEY_TOUCHED: ['touched', 'touched_e'],
       KEY_TRACKED: ['a', 'e', 'x'],
       KEY_UNTRACKED: ['b', 'f'],
       'command': ['echo', 'You should get an Atari'],
       'isolate_dir': FAKE_DIR,
     },
     ('dendy',): {
       KEY_TOUCHED: ['touched', 'touched_e'],
       KEY_TRACKED: ['a', 'e', 'x'],
       KEY_UNTRACKED: ['b', 'f', 'h'],
       'command': ['echo', 'You should get an Atari'],
       'isolate_dir': FAKE_DIR,
     },
   }
   self.assertEqual(
       expected, isolate_format.load_isolate_as_config(
           FAKE_DIR, value, None).flatten())
コード例 #34
0
 def load_included_isolate(isolate_dir, _isolate_path):
   return isolate_format.load_isolate_as_config(isolate_dir, a, None)
コード例 #35
0
    def test_load_with_includes_with_commands(self):
        # This one is messy. Check that isolate_dir is the expected value. To
        # achieve this, put the .isolate files into subdirectories.
        dir_1 = os.path.join(self.tempdir, '1')
        dir_3 = os.path.join(self.tempdir, '3')
        dir_3_2 = os.path.join(self.tempdir, '3', '2')
        os.mkdir(dir_1)
        os.mkdir(dir_3)
        os.mkdir(dir_3_2)

        isolate1 = {
            'conditions': [
                [
                    'OS=="amiga" or OS=="win"', {
                        'variables': {
                            'command': [
                                'foo',
                                'amiga_or_win',
                            ],
                        },
                    }
                ],
                [
                    'OS=="linux"', {
                        'variables': {
                            'command': [
                                'foo',
                                'linux',
                            ],
                            'files': [
                                'file_linux',
                            ],
                        },
                    }
                ],
                [
                    'OS=="mac" or OS=="win"', {
                        'variables': {
                            'files': [
                                'file_non_linux',
                            ],
                        },
                    }
                ],
            ],
        }
        isolate2 = {
            'conditions': [
                [
                    'OS=="linux" or OS=="mac"', {
                        'variables': {
                            'command': [
                                'foo',
                                'linux_or_mac',
                            ],
                            'files': [
                                'other/file',
                            ],
                        },
                    }
                ],
            ],
        }
        # Do not define command in isolate3, otherwise commands in the other
        # included .isolated will be ignored.
        isolate3 = {
            'includes': [
                '../1/isolate1.isolate',
                '2/isolate2.isolate',
            ],
            'conditions': [
                [
                    'OS=="amiga"', {
                        'variables': {
                            'files': [
                                'file_amiga',
                            ],
                        },
                    }
                ],
                ['OS=="mac"', {
                    'variables': {
                        'files': [
                            'file_mac',
                        ],
                    },
                }],
            ],
        }
        # No need to write isolate3.
        with open(os.path.join(dir_1, 'isolate1.isolate'), 'wb') as f:
            isolate_format.pretty_print(isolate1, f)
        with open(os.path.join(dir_3_2, 'isolate2.isolate'), 'wb') as f:
            isolate_format.pretty_print(isolate2, f)

        # The 'isolate_dir' are important, they are what will be used when
        # defining the final isolate_dir to use to run the command in the .isolated
        # file.
        actual = isolate_format.load_isolate_as_config(dir_3, isolate3, None)
        expected = {
            (None, ): {
                # TODO(maruel): See TODO in ConfigSettings.flatten().
                # TODO(maruel): If kept, in this case dir_3 should be selected.
                'isolate_dir': dir_1,
            },
            ('amiga', ): {
                'command': ['foo', 'amiga_or_win'],
                'files': [
                    # Note that the file was rebased from isolate1. This is important,
                    # isolate1 represent the canonical root path because it is the one
                    # that defined the command.
                    '../3/file_amiga',
                ],
                'isolate_dir':
                dir_1,
            },
            ('linux', ): {
                # Last included takes precedence. *command comes from isolate2*, so
                # it becomes the canonical root, so reference to file from isolate1 is
                # via '../../1'.
                'command': ['foo', 'linux_or_mac'],
                'files': [
                    '../../1/file_linux',
                    'other/file',
                ],
                'isolate_dir': dir_3_2,
            },
            ('mac', ): {
                'command': ['foo', 'linux_or_mac'],
                'files': [
                    '../../1/file_non_linux',
                    '../file_mac',
                    'other/file',
                ],
                'isolate_dir': dir_3_2,
            },
            ('win', ): {
                # command comes from isolate1.
                'command': ['foo', 'amiga_or_win'],
                'files': [
                    # While this may be surprising, this is because the command was
                    # defined in isolate1, not isolate3.
                    'file_non_linux',
                ],
                'isolate_dir':
                dir_1,
            },
        }
        self.assertEqual(expected, actual.flatten())
コード例 #36
0
 def load_included_isolate(isolate_dir, _isolate_path):
     return isolate_format.load_isolate_as_config(isolate_dir, a, None)
コード例 #37
0
 def test_load_isolate_as_config(self):
     value = {
         'conditions': [
             [
                 'OS=="amiga" or OS=="atari" or OS=="coleco" or OS=="dendy"',
                 {
                     'variables': {
                         'files': ['a', 'b', 'touched'],
                     },
                 }
             ],
             [
                 'OS=="atari"', {
                     'variables': {
                         'files': ['c', 'd', 'touched_a', 'x'],
                         'command': ['echo', 'Hello World'],
                         'read_only': 2,
                     },
                 }
             ],
             [
                 'OS=="amiga" or OS=="coleco" or OS=="dendy"', {
                     'variables': {
                         'files': ['e', 'f', 'touched_e', 'x'],
                         'command': ['echo', 'You should get an Atari'],
                     },
                 }
             ],
             [
                 'OS=="amiga"', {
                     'variables': {
                         'files': ['g'],
                         'read_only': 1,
                     },
                 }
             ],
             [
                 'OS=="amiga" or OS=="atari" or OS=="dendy"', {
                     'variables': {
                         'files': ['h'],
                     },
                 }
             ],
         ],
     }
     expected = {
         (None, ): {
             'isolate_dir': FAKE_DIR,
         },
         ('amiga', ): {
             'files':
             ['a', 'b', 'e', 'f', 'g', 'h', 'touched', 'touched_e', 'x'],
             'command': ['echo', 'You should get an Atari'],
             'isolate_dir':
             FAKE_DIR,
             'read_only':
             1,
         },
         ('atari', ): {
             'files':
             ['a', 'b', 'c', 'd', 'h', 'touched', 'touched_a', 'x'],
             'command': ['echo', 'Hello World'],
             'isolate_dir': FAKE_DIR,
             'read_only': 2,
         },
         ('coleco', ): {
             'files': ['a', 'b', 'e', 'f', 'touched', 'touched_e', 'x'],
             'command': ['echo', 'You should get an Atari'],
             'isolate_dir': FAKE_DIR,
         },
         ('dendy', ): {
             'files':
             ['a', 'b', 'e', 'f', 'h', 'touched', 'touched_e', 'x'],
             'command': ['echo', 'You should get an Atari'],
             'isolate_dir': FAKE_DIR,
         },
     }
     self.assertEqual(
         expected,
         isolate_format.load_isolate_as_config(FAKE_DIR, value,
                                               None).flatten())
コード例 #38
0
  def test_load_with_includes_with_commands(self):
    # This one is messy. Check that isolate_dir is the expected value. To
    # achieve this, put the .isolate files into subdirectories.
    dir_1 = os.path.join(self.tempdir, '1')
    dir_3 = os.path.join(self.tempdir, '3')
    dir_3_2 = os.path.join(self.tempdir, '3', '2')
    os.mkdir(dir_1)
    os.mkdir(dir_3)
    os.mkdir(dir_3_2)

    isolate1 = {
      'conditions': [
        ['OS=="amiga" or OS=="win"', {
          'variables': {
            'command': [
              'foo', 'amiga_or_win',
            ],
          },
        }],
        ['OS=="linux"', {
          'variables': {
            'command': [
              'foo', 'linux',
            ],
            'isolate_dependency_tracked': [
              'file_linux',
            ],
          },
        }],
        ['OS=="mac" or OS=="win"', {
          'variables': {
            'isolate_dependency_tracked': [
              'file_non_linux',
            ],
          },
        }],
      ],
    }
    isolate2 = {
      'conditions': [
        ['OS=="linux" or OS=="mac"', {
          'variables': {
            'command': [
              'foo', 'linux_or_mac',
            ],
            'isolate_dependency_tracked': [
              'other/file',
            ],
          },
        }],
      ],
    }
    isolate3 = {
      'includes': [
        '../1/isolate1.isolate',
        '2/isolate2.isolate',
      ],
      'conditions': [
        ['OS=="amiga"', {
          'variables': {
            'isolate_dependency_tracked': [
              'file_amiga',
            ],
          },
        }],
        ['OS=="mac"', {
          'variables': {
            'command': [
              'foo', 'mac',
            ],
            'isolate_dependency_tracked': [
              'file_mac',
            ],
          },
        }],
      ],
    }
    # No need to write isolate3.
    with open(os.path.join(dir_1, 'isolate1.isolate'), 'wb') as f:
      isolate_format.pretty_print(isolate1, f)
    with open(os.path.join(dir_3_2, 'isolate2.isolate'), 'wb') as f:
      isolate_format.pretty_print(isolate2, f)

    # The 'isolate_dir' are important, they are what will be used when
    # definining the final isolate_dir to use to run the command in the
    # .isolated file.
    actual = isolate_format.load_isolate_as_config(dir_3, isolate3, None)
    expected = {
      (None,): {
        # TODO(maruel): See TODO in ConfigSettings.flatten().
        # TODO(maruel): If kept, in this case dir_3 should be selected.
        'isolate_dir': dir_1,
      },
      ('amiga',): {
        'command': ['foo', 'amiga_or_win'],
        'isolate_dependency_tracked': [
          # Note that the file was rebased from isolate1. This is important,
          # isolate1 represent the canonical root path because it is the one
          # that defined the command.
          '../3/file_amiga',
        ],
        'isolate_dir': dir_1,
      },
      ('linux',): {
        # Last included takes precedence. *command comes from isolate2*, so
        # it becomes the canonical root, so reference to file from isolate1 is
        # via '../../1'.
        'command': ['foo', 'linux_or_mac'],
        'isolate_dependency_tracked': [
          '../../1/file_linux',
          'other/file',
        ],
        'isolate_dir': dir_3_2,
      },
      ('mac',): {
        # command in isolate3 takes precedence over the ones included.
        'command': ['foo', 'mac'],
        'isolate_dependency_tracked': [
          '../1/file_non_linux',
          '2/other/file',
          'file_mac',
        ],
        'isolate_dir': dir_3,
      },
      ('win',): {
        # command comes from isolate1.
        'command': ['foo', 'amiga_or_win'],
        'isolate_dependency_tracked': [
          # While this may be surprising, this is because the command was
          # defined in isolate1, not isolate3.
          'file_non_linux',
        ],
        'isolate_dir': dir_1,
      },
    }
    self.assertEqual(expected, actual.flatten())
コード例 #39
0
    def test_load_with_includes(self):
        included_isolate = {
            'variables': {
                'files': [
                    'file_common',
                ],
            },
            'conditions': [
                [
                    'OS=="linux"', {
                        'variables': {
                            'files': [
                                'file_linux',
                            ],
                            'read_only': 1,
                        },
                    }
                ],
                [
                    'OS=="mac" or OS=="win"', {
                        'variables': {
                            'files': [
                                'file_non_linux',
                            ],
                            'read_only': 0,
                        },
                    }
                ],
            ],
        }
        with open(os.path.join(self.tempdir, 'included.isolate'), 'wb') as f:
            isolate_format.pretty_print(included_isolate, f)
        values = {
            'includes': ['included.isolate'],
            'variables': {
                'files': [
                    'file_less_common',
                ],
            },
            'conditions': [
                [
                    'OS=="mac"', {
                        'variables': {
                            'files': [
                                'file_mac',
                            ],
                            'read_only': 2,
                        },
                    }
                ],
            ],
        }
        actual = isolate_format.load_isolate_as_config(self.tempdir, values,
                                                       None)

        expected = {
            (None, ): {
                'files': [
                    'file_common',
                    'file_less_common',
                ],
                'isolate_dir': self.tempdir,
            },
            ('linux', ): {
                'files': [
                    'file_linux',
                ],
                'isolate_dir': self.tempdir,
                'read_only': 1,
            },
            ('mac', ): {
                'files': [
                    'file_mac',
                    'file_non_linux',
                ],
                'isolate_dir': self.tempdir,
                'read_only': 2,
            },
            ('win', ): {
                'files': [
                    'file_non_linux',
                ],
                'isolate_dir': self.tempdir,
                'read_only': 0,
            },
        }
        self.assertEqual(expected, actual.flatten())
コード例 #40
0
  def test_load_with_includes(self):
    included_isolate = {
      'variables': {
        'isolate_dependency_tracked': [
          'file_common',
        ],
      },
      'conditions': [
        ['OS=="linux"', {
          'variables': {
            'isolate_dependency_tracked': [
              'file_linux',
            ],
            'read_only': 1,
          },
        }],
        ['OS=="mac" or OS=="win"', {
          'variables': {
            'isolate_dependency_tracked': [
              'file_non_linux',
            ],
            'read_only': 0,
          },
        }],
      ],
    }
    with open(os.path.join(self.tempdir, 'included.isolate'), 'wb') as f:
      isolate_format.pretty_print(included_isolate, f)
    values = {
      'includes': ['included.isolate'],
      'variables': {
        'isolate_dependency_tracked': [
          'file_less_common',
        ],
      },
      'conditions': [
        ['OS=="mac"', {
          'variables': {
            'isolate_dependency_tracked': [
              'file_mac',
            ],
            'read_only': 2,
          },
        }],
      ],
    }
    actual = isolate_format.load_isolate_as_config(self.tempdir, values, None)

    expected = {
      (None,): {
        'isolate_dependency_tracked': [
          'file_common',
          'file_less_common',
        ],
        'isolate_dir': self.tempdir,
      },
      ('linux',): {
        'isolate_dependency_tracked': [
          'file_linux',
        ],
        'isolate_dir': self.tempdir,
        'read_only': 1,
      },
      ('mac',): {
        'isolate_dependency_tracked': [
          'file_mac',
          'file_non_linux',
        ],
        'isolate_dir': self.tempdir,
        'read_only': 2,
      },
      ('win',): {
        'isolate_dependency_tracked': [
          'file_non_linux',
        ],
        'isolate_dir': self.tempdir,
        'read_only': 0,
      },
    }
    self.assertEqual(expected, actual.flatten())
コード例 #41
0
    def test_load_with_includes_with_commands_and_variables(self):
        # This one is the pinacle of fun. Check that isolate_dir is the expected
        # value. To achieve this, put the .isolate files into subdirectories.
        dir_1 = os.path.join(self.tempdir, '1')
        dir_3 = os.path.join(self.tempdir, '3')
        dir_3_2 = os.path.join(self.tempdir, '3', '2')
        os.mkdir(dir_1)
        os.mkdir(dir_3)
        os.mkdir(dir_3_2)

        isolate1 = {
            'conditions': [
                [
                    'OS=="amiga" or OS=="win"', {
                        'variables': {
                            'command': [
                                'foo',
                                'amiga_or_win',
                                '<(PATH)',
                            ],
                        },
                    }
                ],
                [
                    'OS=="linux"', {
                        'variables': {
                            'command': [
                                'foo',
                                'linux',
                                '<(PATH)',
                            ],
                            'files': [
                                '<(PATH)/file_linux',
                            ],
                        },
                    }
                ],
                [
                    'OS=="mac" or OS=="win"', {
                        'variables': {
                            'files': [
                                '<(PATH)/file_non_linux',
                            ],
                        },
                    }
                ],
            ],
        }
        isolate2 = {
            'conditions': [
                [
                    'OS=="linux" or OS=="mac"', {
                        'variables': {
                            'command': [
                                'foo',
                                'linux_or_mac',
                                '<(PATH)',
                            ],
                            'files': [
                                '<(PATH)/other/file',
                            ],
                        },
                    }
                ],
            ],
        }
        # Do not define command in isolate3, otherwise commands in the other
        # included .isolated will be ignored.
        isolate3 = {
            'includes': [
                '../1/isolate1.isolate',
                '2/isolate2.isolate',
            ],
            'conditions': [
                [
                    'OS=="amiga"', {
                        'variables': {
                            'files': [
                                '<(PATH)/file_amiga',
                            ],
                        },
                    }
                ],
                [
                    'OS=="mac"', {
                        'variables': {
                            'files': [
                                '<(PATH)/file_mac',
                            ],
                        },
                    }
                ],
            ],
        }
        # No need to write isolate3.
        with open(os.path.join(dir_1, 'isolate1.isolate'), 'wb') as f:
            isolate_format.pretty_print(isolate1, f)
        with open(os.path.join(dir_3_2, 'isolate2.isolate'), 'wb') as f:
            isolate_format.pretty_print(isolate2, f)

        # The 'isolate_dir' are important, they are what will be used when
        # defining the final isolate_dir to use to run the command in the .isolated
        # file.
        actual = isolate_format.load_isolate_as_config(dir_3, isolate3, None)
        expected = {
            (None, ): {
                'isolate_dir': dir_1,
            },
            ('amiga', ): {
                'command': ['foo', 'amiga_or_win', '<(PATH)'],
                'files': [
                    '<(PATH)/file_amiga',
                ],
                'isolate_dir': dir_1,
            },
            ('linux', ): {
                # Last included takes precedence. *command comes from isolate2*, so
                # it becomes the canonical root, so reference to file from isolate1 is
                # via '../../1'.
                'command': ['foo', 'linux_or_mac', '<(PATH)'],
                'files': [
                    '<(PATH)/file_linux',
                    '<(PATH)/other/file',
                ],
                'isolate_dir': dir_3_2,
            },
            ('mac', ): {
                'command': ['foo', 'linux_or_mac', '<(PATH)'],
                'files': [
                    '<(PATH)/file_mac',
                    '<(PATH)/file_non_linux',
                    '<(PATH)/other/file',
                ],
                'isolate_dir':
                dir_3_2,
            },
            ('win', ): {
                # command comes from isolate1.
                'command': ['foo', 'amiga_or_win', '<(PATH)'],
                'files': [
                    '<(PATH)/file_non_linux',
                ],
                'isolate_dir': dir_1,
            },
        }
        self.assertEqual(expected, actual.flatten())
コード例 #42
0
  def test_load_with_includes(self):
    included_isolate = {
      'variables': {
        'isolate_dependency_tracked': [
          'file_common',
        ],
      },
      'conditions': [
        ['OS=="linux"', {
          'variables': {
            'isolate_dependency_tracked': [
              'file_linux',
            ],
            'read_only': 1,
          },
        }, {
          'variables': {
            'isolate_dependency_tracked': [
              'file_non_linux',
            ],
            'read_only': 0,
          },
        }],
      ],
    }
    tools.write_json(
        os.path.join(self.tempdir, 'included.isolate'), included_isolate, True)
    values = {
      'includes': ['included.isolate'],
      'variables': {
        'isolate_dependency_tracked': [
          'file_less_common',
        ],
      },
      'conditions': [
        ['OS=="mac"', {
          'variables': {
            'isolate_dependency_tracked': [
              'file_mac',
            ],
            'read_only': 2,
          },
        }],
      ],
    }
    actual = isolate_format.load_isolate_as_config(self.tempdir, values, None)

    expected = {
      ('linux',): {
        'isolate_dependency_tracked': [
          'file_common',
          'file_less_common',
          'file_linux',
        ],
        'read_only': 1,
      },
      ('mac',): {
        'isolate_dependency_tracked': [
          'file_common',
          'file_less_common',
          'file_mac',
          'file_non_linux',
        ],
        'read_only': 2,
      },
      ('win',): {
        'isolate_dependency_tracked': [
          'file_common',
          'file_less_common',
          'file_non_linux',
        ],
        'read_only': 0,
      },
    }
    self.assertEqual(expected, actual.flatten())