Example #1
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 = {
     'conditions': [
       ['OS=="linux"', {
         'variables': {
           'isolate_dependency_tracked': [
             'file_linux',
           ],
         },
       }],
       ['OS=="linux" or OS=="mac" or OS=="win"', {
         'variables': {
           'isolate_dependency_tracked': [
             'file_common',
           ],
         },
       }],
       ['OS=="mac"', {
         'variables': {
           'isolate_dependency_tracked': [
             'file_mac',
           ],
         },
       }],
       ['OS=="win"', {
         'variables': {
           'isolate_dependency_tracked': [
             'file_win',
           ],
         },
       }],
     ],
   }
   actual = isolate.convert_map_to_isolate_dict(
       isolate.reduce_inputs(isolate.invert_map(values)), ('OS',))
   self.assertEqual(expected, actual)
Example #2
0
def main(args=None):
  parser = run_test_cases.OptionParserWithLogging(
      usage='%prog <options> [file1] [file2] ...')
  parser.add_option(
      '-o', '--output', help='Output to file instead of stdout')
  parser.add_option(
      '--os', default=','.join(DEFAULT_OSES),
      help='Inject the list of OSes, default: %default')

  options, args = parser.parse_args(args)

  configs = load_isolates(args, options.os.split(','))
  data = convert_map_to_isolate_dict(
      *reduce_inputs(*invert_map(configs.flatten())))
  if options.output:
    with open(options.output, 'wb') as f:
      print_all(configs.file_comment, data, f)
  else:
    print_all(configs.file_comment, data, sys.stdout)
  return 0
Example #3
0
 def test_merge_empty(self):
   actual = isolate.convert_map_to_isolate_dict(
       isolate.reduce_inputs(isolate.invert_map({})), ('dummy1', 'dummy2'))
   self.assertEqual({'conditions': []}, actual)
Example #4
0
 def test_invert_map(self):
   value = {
     ('amiga',): {
       'command': ['echo', 'You should get an Atari'],
       KEY_TOUCHED: ['touched', 'touched_e'],
       KEY_TRACKED: ['a', 'e', 'g', 'x'],
       KEY_UNTRACKED: ['b', 'f', 'h'],
       'read_only': False,
     },
     ('atari',): {
       'command': ['echo', 'Hello World'],
       KEY_TOUCHED: ['touched', 'touched_a'],
       KEY_TRACKED: ['a', 'c', 'x'],
       KEY_UNTRACKED: ['b', 'd', 'h'],
       'read_only': True,
     },
     ('coleco',): {
       'command': ['echo', 'You should get an Atari'],
       KEY_TOUCHED: ['touched', 'touched_e'],
       KEY_TRACKED: ['a', 'e', 'x'],
       KEY_UNTRACKED: ['b', 'f'],
     },
     ('dendy',): {
       'command': ['echo', 'You should get an Atari'],
       KEY_TOUCHED: ['touched', 'touched_e'],
       KEY_TRACKED: ['a', 'e', 'x'],
       KEY_UNTRACKED: ['b', 'f', 'h'],
     },
   }
   amiga, atari, coleco, dendy = (
       set([(os,)]) for os in ('amiga', 'atari', 'coleco', 'dendy'))
   expected_values = {
     'command': {
       ('echo', 'Hello World'): atari,
       ('echo', 'You should get an Atari'): amiga | coleco | dendy,
     },
     KEY_TRACKED: {
       'a': amiga | atari | coleco | dendy,
       'c': atari,
       'e': amiga | coleco | dendy,
       'g': amiga,
       'x': amiga | atari | coleco | dendy,
     },
     KEY_UNTRACKED: {
       'b': amiga | atari | coleco | dendy,
       'd': atari,
       'f': amiga | coleco | dendy,
       'h': amiga | atari | dendy,
     },
     KEY_TOUCHED: {
       'touched': amiga | atari | coleco | dendy,
       'touched_a': atari,
       'touched_e': amiga | coleco | dendy,
     },
     'read_only': {
       False: amiga,
       True: atari,
     },
   }
   actual_values = isolate.invert_map(value)
   self.assertEqual(expected_values, actual_values)
Example #5
0
 def test_merge_empty(self):
   actual = isolate.convert_map_to_isolate_dict(
       *isolate.reduce_inputs(*isolate.invert_map({})))
   self.assertEquals({}, actual)
Example #6
0
 def test_invert_map(self):
   value = {
     'amiga': {
       'command': ['echo', 'You should get an Atari'],
       KEY_TOUCHED: ['touched', 'touched_e'],
       KEY_TRACKED: ['a', 'e', 'g', 'x'],
       KEY_UNTRACKED: ['b', 'f', 'h'],
       'read_only': False,
     },
     'atari': {
       'command': ['echo', 'Hello World'],
       KEY_TOUCHED: ['touched', 'touched_a'],
       KEY_TRACKED: ['a', 'c', 'x'],
       KEY_UNTRACKED: ['b', 'd', 'h'],
       'read_only': True,
     },
     'coleco': {
       'command': ['echo', 'You should get an Atari'],
       KEY_TOUCHED: ['touched', 'touched_e'],
       KEY_TRACKED: ['a', 'e', 'x'],
       KEY_UNTRACKED: ['b', 'f'],
     },
     'dendy': {
       'command': ['echo', 'You should get an Atari'],
       KEY_TOUCHED: ['touched', 'touched_e'],
       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']),
     },
     KEY_TOUCHED: {
       'touched': set(['amiga', 'atari', 'coleco', 'dendy']),
       'touched_a': set(['atari']),
       'touched_e': set(['amiga', 'coleco', 'dendy']),
     },
     'read_only': {
       None: set(['coleco', 'dendy']),
       False: set(['amiga']),
       True: set(['atari']),
     },
   }
   expected_oses = set(['amiga', 'atari', 'coleco', 'dendy'])
   actual_values, actual_oses = isolate.invert_map(value)
   self.assertEquals(expected_values, actual_values)
   self.assertEquals(expected_oses, actual_oses)