Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_detect_cycle_indirect(self):
c = MockTarget('c')
b = MockTarget('b', [c])
a = MockTarget('a', [c, b])
# no cycles yet
InternalTarget.sort_targets([a])
c.internal_dependencies = [a]
try:
InternalTarget.sort_targets([a])
self.fail("Expected a cycle to be detected")
except InternalTarget.CycleException:
# expected
pass
def test_classpath_updates(self):
# Check that exclusive groups classpaths accumulate properly.
a = MockTarget('a', exclusives={'a': '1', 'b': '1'})
b = MockTarget('b', exclusives={'a': '1', 'b': ''})
c = MockTarget('c', exclusives={'a': '2', 'b': '2'})
d = MockTarget('d')
context = Context(CheckExclusivesTest.config, options={}, run_tracker=None,
target_roots=[a, b, c, d])
context.products.require_data('exclusives_groups')
check_exclusives_task = CheckExclusives(context, signal_error=True)
check_exclusives_task.execute([a, b, c, d])
egroups = context.products.get_data('exclusives_groups')
egroups.set_base_classpath_for_group("a=1,b=1", ["a1", "b1"])
egroups.set_base_classpath_for_group("a=1,b=", ["a1"])
egroups.set_base_classpath_for_group("a=2,b=2", ["a2", "b2"])
egroups.set_base_classpath_for_group("a=,b=", ["none"])
egroups.update_compatible_classpaths(None, ["update_without_group"])
egroups.update_compatible_classpaths("a=,b=", ["update_all"])
def setupTargets(self):
a = MockTarget('a', exclusives={'a': '1', 'b': '1'})
b = MockTarget('b', exclusives={'a': '1'})
c = MockTarget('c', exclusives = {'a': '2'})
d = MockTarget('d', dependencies=[a, b])
e = MockTarget('e', dependencies=[a, c], exclusives={'c': '1'})
return a, b, c, d, e
def test_find_children_across_unused_target(self):
a = MockTarget('a')
b = MockTarget('b', [a])
c = MockTarget('c', [b])
d = MockTarget('d', [c, a])
e = MockTarget('e', [d])
def test_classpath_compatibility(self):
# test the compatibility checks for different exclusive groups.
a = MockTarget('a', exclusives={'a': '1', 'b': '1'})
b = MockTarget('b', exclusives={'a': '1', 'b': ''})
c = MockTarget('c', exclusives={'a': '2', 'b': '2'})
d = MockTarget('d')
context = Context(CheckExclusivesTest.config, options={}, run_tracker=None,
target_roots=[a, b, c, d])
context.products.require_data('exclusives_groups')
check_exclusives_task = CheckExclusives(context, signal_error=True)
check_exclusives_task.execute([a, b, c, d])
egroups = context.products.get_data('exclusives_groups')
# Expected compatibility:
# a is compatible with nothing but itself.
self.assertTrue(egroups._is_compatible(egroups.target_to_key[a], egroups.target_to_key[a]))
self.assertFalse(egroups._is_compatible(egroups.target_to_key[a], egroups.target_to_key[b]))
self.assertFalse(egroups._is_compatible(egroups.target_to_key[a], egroups.target_to_key[d]))
self.assertFalse(egroups._is_compatible(egroups.target_to_key[a], egroups.target_to_key[c]))
def setupTargets(self):
a = MockTarget('a', exclusives={'a': '1', 'b': '1'})
b = MockTarget('b', exclusives={'a': '1'})
c = MockTarget('c', exclusives = {'a': '2'})
d = MockTarget('d', dependencies=[a, b])
e = MockTarget('e', dependencies=[a, c], exclusives={'c': '1'})
return a, b, c, d, e
def setupTargets(self):
a = MockTarget('a', exclusives={'a': '1', 'b': '1'})
b = MockTarget('b', exclusives={'a': '1'})
c = MockTarget('c', exclusives = {'a': '2'})
d = MockTarget('d', dependencies=[a, b])
e = MockTarget('e', dependencies=[a, c], exclusives={'c': '1'})
return a, b, c, d, e
def setupTargets(self):
a = MockTarget('a', exclusives={'a': '1', 'b': '1'})
b = MockTarget('b', exclusives={'a': '1'})
c = MockTarget('c', exclusives = {'a': '2'})
d = MockTarget('d', dependencies=[a, b])
e = MockTarget('e', dependencies=[a, c], exclusives={'c': '1'})
return a, b, c, d, e
def test_classpath_updates(self):
# Check that exclusive groups classpaths accumulate properly.
a = MockTarget('a', exclusives={'a': '1', 'b': '1'})
b = MockTarget('b', exclusives={'a': '1', 'b': ''})
c = MockTarget('c', exclusives={'a': '2', 'b': '2'})
d = MockTarget('d')
context = Context(CheckExclusivesTest.config, options={}, run_tracker=None,
target_roots=[a, b, c, d])
context.products.require_data('exclusives_groups')
check_exclusives_task = CheckExclusives(context, signal_error=True)
check_exclusives_task.execute([a, b, c, d])
egroups = context.products.get_data('exclusives_groups')
egroups.set_base_classpath_for_group("a=1,b=1", ["a1", "b1"])
egroups.set_base_classpath_for_group("a=1,b=", ["a1"])
egroups.set_base_classpath_for_group("a=2,b=2", ["a2", "b2"])
egroups.set_base_classpath_for_group("a=,b=", ["none"])
egroups.update_compatible_classpaths(None, ["update_without_group"])
egroups.update_compatible_classpaths("a=,b=", ["update_all"])
egroups.update_compatible_classpaths("a=1,b=", ["update_a1bn"])
def test_check_exclusives(self):
a = MockTarget('a', exclusives={'a': '1', 'b': '1'})
b = MockTarget('b', exclusives={'a': '1'})
c = MockTarget('c', exclusives={'a': '2'})
d = MockTarget('d', dependencies=[a, b])
e = MockTarget('e', dependencies=[a, c], exclusives={'c': '1'})
context = Context(CheckExclusivesTest.config, options={}, run_tracker=None, target_roots=[d, e])
check_exclusives_task = CheckExclusives(context, signal_error=True)
try:
check_exclusives_task.execute([d, e])
self.fail("Expected a conflicting exclusives exception to be thrown.")
except TaskError:
pass