sys.path.insert(0, ROOT_DIR)
import isolate_format
-import run_isolated
-# Create shortcuts.
-from isolate_format import KEY_TOUCHED, KEY_TRACKED, KEY_UNTRACKED
+from utils import file_path
# Access to a protected member XXX of a client class
'conditions': [
['OS=="amiga" or OS=="atari" or OS=="coleco" or OS=="dendy"', {
'variables': {
- KEY_TRACKED: ['a'],
- KEY_UNTRACKED: ['b'],
- KEY_TOUCHED: ['touched'],
+ 'files': ['a', 'b', 'touched'],
},
}],
['OS=="atari"', {
'variables': {
- KEY_TRACKED: ['c', 'x'],
- KEY_UNTRACKED: ['d'],
- KEY_TOUCHED: ['touched_a'],
+ 'files': ['c', 'd', 'touched_a', 'x'],
'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'],
+ 'files': ['e', 'f', 'touched_e', 'x'],
'command': ['echo', 'You should get an Atari'],
},
}],
['OS=="amiga"', {
'variables': {
- KEY_TRACKED: ['g'],
+ 'files': ['g'],
'read_only': 1,
},
}],
['OS=="amiga" or OS=="atari" or OS=="dendy"', {
'variables': {
- KEY_UNTRACKED: ['h'],
+ 'files': ['h'],
},
}],
],
'isolate_dir': FAKE_DIR,
},
('amiga',): {
- KEY_TOUCHED: ['touched', 'touched_e'],
- KEY_TRACKED: ['a', 'e', 'g', 'x'],
- KEY_UNTRACKED: ['b', 'f', 'h'],
+ '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',): {
- KEY_TOUCHED: ['touched', 'touched_a'],
- KEY_TRACKED: ['a', 'c', 'x'],
- KEY_UNTRACKED: ['b', 'd', 'h'],
+ 'files': ['a', 'b', 'c', 'd', 'h', 'touched', 'touched_a', 'x'],
'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'],
+ 'files': ['a', 'b', 'e', 'f', 'touched', 'touched_e', 'x'],
'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'],
+ 'files': ['a', 'b', 'e', 'f', 'h', 'touched', 'touched_e', 'x'],
'command': ['echo', 'You should get an Atari'],
'isolate_dir': FAKE_DIR,
},
value = {
'variables': {
'command': ['echo', 'You should get an Atari'],
- KEY_TRACKED: ['a'],
- KEY_UNTRACKED: ['b'],
- KEY_TOUCHED: ['touched'],
+ 'files': ['a', 'b', 'touched'],
'read_only': 1,
},
}
# The key is the empty tuple, since there is no variable to bind to.
expected = {
(): {
- KEY_TRACKED: ['a'],
- KEY_UNTRACKED: ['b'],
- KEY_TOUCHED: ['touched'],
'command': ['echo', 'You should get an Atari'],
+ 'files': ['a', 'b', 'touched'],
'isolate_dir': FAKE_DIR,
'read_only': 1,
},
expected, isolate_format.load_isolate_as_config(
FAKE_DIR, value, None).flatten())
- 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': 0,
- },
- ('atari',): {
- 'command': ['echo', 'Hello World'],
- KEY_TOUCHED: ['touched', 'touched_a'],
- KEY_TRACKED: ['a', 'c', 'x'],
- KEY_UNTRACKED: ['b', 'd', 'h'],
- 'read_only': 1,
- },
- ('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': {
- 0: amiga,
- 1: atari,
- },
- }
- actual_values = isolate_format.invert_map(value)
- self.assertEqual(expected_values, actual_values)
-
- def test_reduce_inputs(self):
- amiga, atari, coleco, dendy = (
- set([(os,)]) for os in ('amiga', 'atari', 'coleco', 'dendy'))
- 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': {
- 0: amiga,
- 1: atari,
- },
- }
- 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': {
- 0: amiga,
- 1: atari,
- },
- }
- actual_values = isolate_format.reduce_inputs(values)
- self.assertEqual(expected_values, actual_values)
-
- def test_reduce_inputs_merge_subfolders_and_files(self):
- linux, mac, win = (set([(os,)]) for os in ('linux', 'mac', 'win'))
- values = {
- KEY_TRACKED: {
- 'folder/tracked_file': win,
- 'folder_helper/tracked_file': win,
- },
- KEY_UNTRACKED: {
- 'folder/': linux | mac | win,
- 'folder/subfolder/': win,
- 'folder/untracked_file': linux | mac | win,
- 'folder_helper/': linux,
- },
- KEY_TOUCHED: {
- 'folder/touched_file': win,
- 'folder/helper_folder/deep_file': win,
- 'folder_helper/touched_file1': mac | win,
- 'folder_helper/touched_file2': linux,
- },
- }
- expected_values = {
- 'command': {},
- KEY_TRACKED: {
- 'folder_helper/tracked_file': win,
- },
- KEY_UNTRACKED: {
- 'folder/': linux | mac | win,
- 'folder_helper/': linux,
- },
- KEY_TOUCHED: {
- 'folder_helper/touched_file1': mac | win,
- },
- 'read_only': {},
- }
- actual_values = isolate_format.reduce_inputs(values)
- self.assertEqual(expected_values, actual_values)
-
- def test_reduce_inputs_take_strongest_dependency(self):
- amiga, atari, coleco, dendy = (
- set([(os,)]) for os in ('amiga', 'atari', 'coleco', 'dendy'))
- values = {
- 'command': {
- ('echo', 'Hello World'): atari,
- ('echo', 'You should get an Atari'): amiga | coleco | dendy,
- },
- KEY_TRACKED: {
- 'a': amiga | atari | coleco | dendy,
- 'b': amiga | atari | coleco,
- },
- KEY_UNTRACKED: {
- 'c': amiga | atari | coleco | dendy,
- 'd': amiga | coleco | dendy,
- },
- KEY_TOUCHED: {
- 'a': amiga | atari | coleco | dendy,
- 'b': atari | coleco | dendy,
- 'c': amiga | atari | coleco | dendy,
- 'd': 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,
- 'b': amiga | atari | coleco,
- },
- KEY_UNTRACKED: {
- 'c': amiga | atari | coleco | dendy,
- 'd': amiga | coleco | dendy,
- },
- KEY_TOUCHED: {
- 'b': dendy,
- 'd': atari,
- },
- 'read_only': {},
- }
- actual_values = isolate_format.reduce_inputs(values)
- self.assertEqual(expected_values, actual_values)
-
- def test_convert_map_to_isolate_dict(self):
- amiga = ('amiga',)
- atari = ('atari',)
- coleco = ('coleco',)
- dendy = ('dendy',)
- 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': {
- 0: (amiga,),
- 1: (atari,),
- },
- }
- expected_conditions = [
- ['OS=="amiga"', {
- 'variables': {
- KEY_TRACKED: ['g'],
- 'read_only': 0,
- },
- }],
- ['OS=="amiga" or OS=="atari" or OS=="coleco" or OS=="dendy"', {
- 'variables': {
- KEY_TRACKED: ['a', 'x'],
- KEY_UNTRACKED: ['b'],
- KEY_TOUCHED: ['touched'],
- },
- }],
- ['OS=="amiga" or OS=="atari" or OS=="dendy"', {
- 'variables': {
- KEY_UNTRACKED: ['h'],
- },
- }],
- ['OS=="amiga" or OS=="coleco" or OS=="dendy"', {
- 'variables': {
- 'command': ['echo', 'You should get an Atari'],
- KEY_TRACKED: ['e'],
- KEY_UNTRACKED: ['f'],
- KEY_TOUCHED: ['touched_e'],
- },
- }],
- ['OS=="atari"', {
- 'variables': {
- 'command': ['echo', 'Hello World'],
- KEY_TRACKED: ['c'],
- KEY_UNTRACKED: ['d'],
- KEY_TOUCHED: ['touched_a'],
- 'read_only': 1,
- },
- }],
- ]
- actual = isolate_format.convert_map_to_isolate_dict(values, ('OS',))
- self.assertEqual(expected_conditions, sorted(actual.pop('conditions')))
- self.assertFalse(actual)
-
def test_merge_two_empty(self):
# Flat stay flat. Pylint is confused about union() return type.
# pylint: disable=E1103
}
self.assertEqual(expected, actual.flatten())
- def test_merge_empty(self):
- actual = isolate_format.convert_map_to_isolate_dict(
- isolate_format.reduce_inputs(isolate_format.invert_map({})),
- ('dummy1', 'dummy2'))
- self.assertEqual({'conditions': []}, actual)
-
def test_load_two_conditions(self):
linux = {
'conditions': [
['OS=="linux"', {
'variables': {
- 'isolate_dependency_tracked': [
+ 'files': [
'file_linux',
'file_common',
],
'conditions': [
['OS=="mac"', {
'variables': {
- 'isolate_dependency_tracked': [
+ 'files': [
'file_mac',
'file_common',
],
'isolate_dir': FAKE_DIR,
},
('linux',): {
- 'isolate_dependency_tracked': ['file_common', 'file_linux'],
+ 'files': ['file_common', 'file_linux'],
'isolate_dir': FAKE_DIR,
},
('mac',): {
- 'isolate_dependency_tracked': ['file_common', 'file_mac'],
+ 'files': ['file_common', 'file_mac'],
'isolate_dir': FAKE_DIR,
},
}
'conditions': [
['OS=="linux" and chromeos==1', {
'variables': {
- 'isolate_dependency_tracked': [
+ 'files': [
'file_linux',
'file_common',
],
'conditions': [
['OS=="mac" and chromeos==0', {
'variables': {
- 'isolate_dependency_tracked': [
+ 'files': [
'file_mac',
'file_common',
],
'conditions': [
['OS=="win" and chromeos==0', {
'variables': {
- 'isolate_dependency_tracked': [
+ 'files': [
'file_win',
'file_common',
],
'isolate_dir': FAKE_DIR,
},
('linux', 1): {
- 'isolate_dependency_tracked': ['file_common', 'file_linux'],
+ 'files': ['file_common', 'file_linux'],
'isolate_dir': FAKE_DIR,
},
('mac', 0): {
- 'isolate_dependency_tracked': ['file_common', 'file_mac'],
+ 'files': ['file_common', 'file_mac'],
'isolate_dir': FAKE_DIR,
},
('win', 0): {
- 'isolate_dependency_tracked': ['file_common', 'file_win'],
+ 'files': ['file_common', 'file_win'],
'isolate_dir': FAKE_DIR,
},
}
}
self.assertEqual(expected, flatten)
- def test_make_isolate_multi_variables(self):
- config = isolate_format.Configs(None, ('CHROMEOS', 'OS'))
- config._by_config[(('0', 'linux'))] = isolate_format.ConfigSettings(
- {'command': ['bar']}, FAKE_DIR)
- config._by_config[(('1', 'linux'))] = isolate_format.ConfigSettings(
- {'command': ['foo']}, FAKE_DIR)
- expected = {
- 'conditions': [
- ['CHROMEOS=="0" and OS=="linux"', {
- 'variables': {
- 'command': ['bar'],
- },
- }],
- ['CHROMEOS=="1" and OS=="linux"', {
- 'variables': {
- 'command': ['foo'],
- },
- }],
- ],
- }
- self.assertEqual(expected, config.make_isolate_file())
-
- def test_make_isolate_multi_variables_missing(self):
- config = isolate_format.Configs(None, ('CHROMEOS', 'OS'))
- config._by_config[((None, 'abc'))] = isolate_format.ConfigSettings(
- {'command': ['bar']}, FAKE_DIR)
- config._by_config[(('1', None))] = isolate_format.ConfigSettings(
- {'command': ['foo']}, FAKE_DIR)
- expected = {
- 'conditions': [
- ['CHROMEOS=="1"', {
- 'variables': {
- 'command': ['foo'],
- },
- }],
- ['OS=="abc"', {
- 'variables': {
- 'command': ['bar'],
- },
- }],
- ],
- }
- self.assertEqual(expected, config.make_isolate_file())
-
- def test_make_isolate_4_variables(self):
- # Test multiple combinations of bound and free variables.
- config = isolate_format.Configs(None, ('BRAND', 'CHROMEOS', 'LIB', 'OS'))
- config._by_config = {
- (None, 0, 's', 'linux'): isolate_format.ConfigSettings(
- {'command': ['bar']}, FAKE_DIR),
- (None, None, 's', 'mac'): isolate_format.ConfigSettings(
- {'command': ['foo']}, FAKE_DIR),
- (None, None, 's', 'win'): isolate_format.ConfigSettings(
- {'command': ['ziz']}, FAKE_DIR),
- ('Chrome', 0, 's', 'win'): isolate_format.ConfigSettings(
- {'command': ['baz']}, FAKE_DIR),
- }
- expected = {
- 'conditions': [
- ['BRAND=="Chrome" and CHROMEOS==0 and LIB=="s" and OS=="win"', {
- 'variables': {
- 'command': ['baz'],
- },
- }],
- ['CHROMEOS==0 and LIB=="s" and OS=="linux"', {
- 'variables': {
- 'command': ['bar'],
- },
- }],
- ['LIB=="s" and OS=="mac"', {
- 'variables': {
- 'command': ['foo'],
- },
- }],
- ['LIB=="s" and OS=="win"', {
- 'variables': {
- 'command': ['ziz'],
- },
- }],
- ],
- }
- self.assertEqual(expected, config.make_isolate_file())
-
def test_ConfigSettings_union(self):
lhs_values = {}
- rhs_values = {KEY_UNTRACKED: ['data/', 'test/data/']}
+ rhs_values = {'files': ['data/', 'test/data/']}
lhs = isolate_format.ConfigSettings(lhs_values, '/src/net/third_party/nss')
rhs = isolate_format.ConfigSettings(rhs_values, '/src/base')
out = lhs.union(rhs)
expected = {
- KEY_UNTRACKED: ['data/', 'test/data/'],
+ 'files': ['data/', 'test/data/'],
'isolate_dir': '/src/base',
}
self.assertEqual(expected, out.flatten())
- 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_format.convert_map_to_isolate_dict(
- isolate_format.reduce_inputs(isolate_format.invert_map(values)),
- ('OS',))
- self.assertEqual(expected, actual)
-
- def test_merge_three_conditions_read_only(self):
- values = {
- ('linux',): {
- 'isolate_dependency_tracked': ['file_common', 'file_linux'],
- 'read_only': 1,
- },
- ('mac',): {
- 'isolate_dependency_tracked': ['file_common', 'file_mac'],
- 'read_only': 0,
- },
- ('win',): {
- 'isolate_dependency_tracked': ['file_common', 'file_win'],
- 'read_only': 2,
- },
- ('amiga',): {
- 'read_only': 1,
- }
- }
- expected = {
- 'conditions': [
- ['OS=="amiga" or OS=="linux"', {
- 'variables': {
- 'read_only': 1,
- },
- }],
- ['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',
- ],
- 'read_only': 0,
- },
- }],
- ['OS=="win"', {
- 'variables': {
- 'isolate_dependency_tracked': [
- 'file_win',
- ],
- 'read_only': 2,
- },
- }],
- ],
- }
- actual = isolate_format.convert_map_to_isolate_dict(
- isolate_format.reduce_inputs(isolate_format.invert_map(values)),
- ('OS',))
- self.assertEqual(expected, actual)
-
def test_configs_comment(self):
# Pylint is confused with isolate_format.union() return type.
# pylint: disable=E1103
def test_pretty_print_mid_size(self):
value = {
'variables': {
- KEY_TOUCHED: [
+ 'files': [
'file1',
'file2',
],
'conditions': [
['OS==\"foo\"', {
'variables': {
- KEY_UNTRACKED: [
- 'dir1',
- 'dir2',
- ],
- KEY_TRACKED: [
- 'file4',
+ 'files': [
+ 'dir1/',
+ 'dir2/',
'file3',
+ 'file4',
],
'command': ['python', '-c', 'print "H\\i\'"'],
'read_only': 2,
expected = (
"{\n"
" 'variables': {\n"
- " 'isolate_dependency_touched': [\n"
+ " 'files': [\n"
" 'file1',\n"
" 'file2',\n"
" ],\n"
" '-c',\n"
" 'print \"H\\i\'\"',\n"
" ],\n"
- " 'read_only': 2,\n"
- " 'isolate_dependency_tracked': [\n"
- " 'file4',\n"
+ " 'files': [\n"
+ " 'dir1/',\n"
+ " 'dir2/',\n"
" 'file3',\n"
+ " 'file4',\n"
" ],\n"
- " 'isolate_dependency_untracked': [\n"
- " 'dir1',\n"
- " 'dir2',\n"
- " ],\n"
+ " 'read_only': 2,\n"
" },\n"
" }],\n"
" ['OS==\"bar\"', {\n"
def test_load_with_globals(self):
values = {
'variables': {
- 'isolate_dependency_tracked': [
+ 'files': [
'file_common',
],
},
'conditions': [
['OS=="linux"', {
'variables': {
- 'isolate_dependency_tracked': [
+ 'files': [
'file_linux',
],
'read_only': 1,
}],
['OS=="mac" or OS=="win"', {
'variables': {
- 'isolate_dependency_tracked': [
+ 'files': [
'file_non_linux',
],
'read_only': 0,
}
expected = {
(None,): {
- 'isolate_dependency_tracked': [
+ 'files': [
'file_common',
],
'isolate_dir': FAKE_DIR,
},
('linux',): {
- 'isolate_dependency_tracked': [
+ 'files': [
'file_linux',
],
'isolate_dir': FAKE_DIR,
'read_only': 1,
},
('mac',): {
- 'isolate_dependency_tracked': [
+ 'files': [
'file_non_linux',
],
'isolate_dir': FAKE_DIR,
'read_only': 0,
},
('win',): {
- 'isolate_dependency_tracked': [
+ 'files': [
'file_non_linux',
],
'isolate_dir': FAKE_DIR,
actual = isolate_format.load_isolate_as_config(FAKE_DIR, values, None)
self.assertEqual(expected, actual.flatten())
- def test_configs_with_globals(self):
- c = isolate_format.Configs(None, ('x', 'y'))
- c.set_config(
- (1, 1), isolate_format.ConfigSettings({KEY_TRACKED: ['1,1']}, FAKE_DIR))
- c.set_config(
- (2, 2), isolate_format.ConfigSettings({KEY_TRACKED: ['2,2']}, FAKE_DIR))
- c.set_config(
- (1, None),
- isolate_format.ConfigSettings({KEY_TRACKED: ['1,y']}, FAKE_DIR))
- c.set_config(
- (None, 2),
- isolate_format.ConfigSettings({KEY_TRACKED: ['x,2']}, FAKE_DIR))
- c.set_config(
- (None, None),
- isolate_format.ConfigSettings({KEY_TRACKED: ['x,y']}, FAKE_DIR))
- expected = {
- (None, None): {
- KEY_TRACKED: ['x,y'],
- 'isolate_dir': FAKE_DIR,
- },
- (None, 2): {
- KEY_TRACKED: ['x,2'],
- 'isolate_dir': FAKE_DIR,
- },
- (1, None): {
- KEY_TRACKED: ['1,y'],
- 'isolate_dir': FAKE_DIR,
- },
- (1, 1): {
- KEY_TRACKED: ['1,1'],
- 'isolate_dir': FAKE_DIR,
- },
- (2, 2): {
- KEY_TRACKED: ['2,2'],
- 'isolate_dir': FAKE_DIR,
- },
- }
- self.assertEqual(expected, c.flatten())
-
- s = c.get_config((1, 1))
- expected = {
- KEY_TRACKED: ['1,1', '1,y', 'x,y'],
- 'isolate_dir': FAKE_DIR,
- }
- self.assertEqual(expected, s.flatten())
-
- s = c.get_config((1, None))
- expected = {
- KEY_TRACKED: ['1,y', 'x,y'],
- 'isolate_dir': FAKE_DIR,
- }
- self.assertEqual(expected, s.flatten())
-
- s = c.get_config((None, None))
- expected = {
- KEY_TRACKED: ['x,y'],
- 'isolate_dir': FAKE_DIR,
- }
- self.assertEqual(expected, s.flatten())
-
- expected = {
- 'conditions': [
- ['x==1', {'variables': {KEY_TRACKED: ['1,y']}}],
- ['x==1 and y==1', {'variables': {KEY_TRACKED: ['1,1']}}],
- ['x==2 and y==2', {'variables': {KEY_TRACKED: ['2,2']}}],
- ['y==2', {'variables': {KEY_TRACKED: ['x,2']}}],
- ],
- 'variables': {KEY_TRACKED: ['x,y']},
- }
- self.assertEqual(expected, c.make_isolate_file())
-
class IsolateFormatTmpDirTest(unittest.TestCase):
def setUp(self):
def tearDown(self):
try:
- run_isolated.rmtree(self.tempdir)
+ file_path.rmtree(self.tempdir)
finally:
super(IsolateFormatTmpDirTest, self).tearDown()
def test_load_with_includes(self):
included_isolate = {
'variables': {
- 'isolate_dependency_tracked': [
+ 'files': [
'file_common',
],
},
'conditions': [
['OS=="linux"', {
'variables': {
- 'isolate_dependency_tracked': [
+ 'files': [
'file_linux',
],
'read_only': 1,
}],
['OS=="mac" or OS=="win"', {
'variables': {
- 'isolate_dependency_tracked': [
+ 'files': [
'file_non_linux',
],
'read_only': 0,
values = {
'includes': ['included.isolate'],
'variables': {
- 'isolate_dependency_tracked': [
+ 'files': [
'file_less_common',
],
},
'conditions': [
['OS=="mac"', {
'variables': {
- 'isolate_dependency_tracked': [
+ 'files': [
'file_mac',
],
'read_only': 2,
expected = {
(None,): {
- 'isolate_dependency_tracked': [
+ 'files': [
'file_common',
'file_less_common',
],
'isolate_dir': self.tempdir,
},
('linux',): {
- 'isolate_dependency_tracked': [
+ 'files': [
'file_linux',
],
'isolate_dir': self.tempdir,
'read_only': 1,
},
('mac',): {
- 'isolate_dependency_tracked': [
+ 'files': [
'file_mac',
'file_non_linux',
],
'read_only': 2,
},
('win',): {
- 'isolate_dependency_tracked': [
+ 'files': [
'file_non_linux',
],
'isolate_dir': self.tempdir,
'command': [
'foo', 'linux',
],
- 'isolate_dependency_tracked': [
+ 'files': [
'file_linux',
],
},
}],
['OS=="mac" or OS=="win"', {
'variables': {
- 'isolate_dependency_tracked': [
+ 'files': [
'file_non_linux',
],
},
'command': [
'foo', 'linux_or_mac',
],
- 'isolate_dependency_tracked': [
+ 'files': [
'other/file',
],
},
'conditions': [
['OS=="amiga"', {
'variables': {
- 'isolate_dependency_tracked': [
+ 'files': [
'file_amiga',
],
},
'command': [
'foo', 'mac',
],
- 'isolate_dependency_tracked': [
+ 'files': [
'file_mac',
],
},
},
('amiga',): {
'command': ['foo', 'amiga_or_win'],
- 'isolate_dependency_tracked': [
+ '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.
# it becomes the canonical root, so reference to file from isolate1 is
# via '../../1'.
'command': ['foo', 'linux_or_mac'],
- 'isolate_dependency_tracked': [
+ 'files': [
'../../1/file_linux',
'other/file',
],
('mac',): {
# command in isolate3 takes precedence over the ones included.
'command': ['foo', 'mac'],
- 'isolate_dependency_tracked': [
+ 'files': [
'../1/file_non_linux',
'2/other/file',
'file_mac',
('win',): {
# command comes from isolate1.
'command': ['foo', 'amiga_or_win'],
- 'isolate_dependency_tracked': [
+ 'files': [
# While this may be surprising, this is because the command was
# defined in isolate1, not isolate3.
'file_non_linux',
'command': [
'foo', 'linux', '<(PATH)',
],
- 'isolate_dependency_tracked': [
+ 'files': [
'<(PATH)/file_linux',
],
},
}],
['OS=="mac" or OS=="win"', {
'variables': {
- 'isolate_dependency_tracked': [
+ 'files': [
'<(PATH)/file_non_linux',
],
},
'command': [
'foo', 'linux_or_mac', '<(PATH)',
],
- 'isolate_dependency_tracked': [
+ 'files': [
'<(PATH)/other/file',
],
},
'conditions': [
['OS=="amiga"', {
'variables': {
- 'isolate_dependency_tracked': [
+ 'files': [
'<(PATH)/file_amiga',
],
},
'command': [
'foo', 'mac', '<(PATH)',
],
- 'isolate_dependency_tracked': [
+ 'files': [
'<(PATH)/file_mac',
],
},
},
('amiga',): {
'command': ['foo', 'amiga_or_win', '<(PATH)'],
- 'isolate_dependency_tracked': [
+ 'files': [
'<(PATH)/file_amiga',
],
'isolate_dir': dir_1,
# it becomes the canonical root, so reference to file from isolate1 is
# via '../../1'.
'command': ['foo', 'linux_or_mac', '<(PATH)'],
- 'isolate_dependency_tracked': [
+ 'files': [
'<(PATH)/file_linux',
'<(PATH)/other/file',
],
},
('mac',): {
'command': ['foo', 'mac', '<(PATH)'],
- 'isolate_dependency_tracked': [
+ 'files': [
'<(PATH)/file_mac',
'<(PATH)/file_non_linux',
'<(PATH)/other/file',
('win',): {
# command comes from isolate1.
'command': ['foo', 'amiga_or_win', '<(PATH)'],
- 'isolate_dependency_tracked': [
+ 'files': [
'<(PATH)/file_non_linux',
],
'isolate_dir': dir_1,