def testCreatePairwiseDisjointSets_Multiple(self): a = gg.SourceSet(set(['common', 'intel']), set(['ia32']), set(['Chromium']), set(['linux'])) b = gg.SourceSet(set(['common', 'intel', 'chrome']), set(['ia32']), set(['Chrome']), set(['linux'])) c = gg.SourceSet(set(['common', 'intel']), set(['x64']), set(['Chromium']), set(['linux'])) d = gg.SourceSet(set(['common', 'intel', 'chrome']), set(['x64']), set(['Chrome']), set(['linux'])) e = gg.SourceSet(set(['common', 'arm']), set(['arm']), set(['Chromium']), set(['linux'])) f = gg.SourceSet(set(['common', 'arm-neon', 'chrome', 'chromeos']), set(['arm-neon']), set(['ChromeOS']), set(['linux'])) expected = [] expected.append( gg.SourceSet(set(['common']), set(['ia32', 'x64', 'arm', 'arm-neon']), set(['Chromium', 'Chrome', 'ChromeOS']), set(['linux']))) expected.append( gg.SourceSet(set(['intel']), set(['ia32', 'x64']), set(['Chromium', 'Chrome']), set(['linux']))) expected.append( gg.SourceSet(set(['arm']), set(['arm']), set(['Chromium']), set(['linux']))) expected.append( gg.SourceSet(set(['chrome']), set(['ia32', 'x64', 'arm-neon']), set(['Chrome', 'ChromeOS']), set(['linux']))) expected.append( gg.SourceSet(set(['arm-neon', 'chromeos']), set(['arm-neon']), set(['ChromeOS']), set(['linux']))) sets = gg.CreatePairwiseDisjointSets([a, b, c, d, e, f]) self.assertEqualSets(sets, expected)
def testCreatePairwiseDisjointSets_Triplet(self): a = SourceSet(set(['common', 'intel']), set([SourceListCondition('ia32', 'Chromium', 'win')])) b = SourceSet(set(['common', 'intel', 'chrome']), set([SourceListCondition('x64', 'Chrome', 'win')])) c = SourceSet(set(['common', 'arm']), set([SourceListCondition('arm', 'Chromium', 'win')])) expected = [] expected.append( SourceSet( set(['common']), set([ SourceListCondition('ia32', 'Chromium', 'win'), SourceListCondition('x64', 'Chrome', 'win'), SourceListCondition('arm', 'Chromium', 'win') ]))) expected.append( SourceSet( set(['intel']), set([ SourceListCondition('ia32', 'Chromium', 'win'), SourceListCondition('x64', 'Chrome', 'win') ]))) expected.append( SourceSet(set(['chrome']), set([SourceListCondition('x64', 'Chrome', 'win')]))) expected.append( SourceSet(set(['arm']), set([SourceListCondition('arm', 'Chromium', 'win')]))) sets = gg.CreatePairwiseDisjointSets([a, b, c]) self.assertEqualSets(expected, sets)
def testComplexSourceListConditions(self): # Create 2 sets with intersecting source 'a', but setup such that 'a' # is only valid for combinations (x86 && windows) || (x64 && linux). The # generated gyp stanza should then not allow for inclusion of the 'a' file # for combinations like x86 && linux. a = SourceSet(set(['a']), set([SourceListCondition('x86', 'c', 'win')])) b = SourceSet(set(['a']), set([SourceListCondition('x64', 'c', 'linux')])) disjoint_sets = gg.CreatePairwiseDisjointSets([a, b]) # This condition is bad because x86 && linux would pass. Admittedly a very # fragile way to test this, but evaulating gn stanzas is hard, and it at # least serves to document the motivation for the associated changes to # our generate_gyp.py bad_condition = ('(current_cpu == "x86" || current_cpu == "x64")' ' && (ffmpeg_branding == "c")' ' && (is_win || is_linux)') # Expect only a single set since the two original sets have the same source # list. self.assertEqual(1, len(disjoint_sets)) stanza = disjoint_sets[0].GenerateGnStanza() self.assertEqual(string.find(stanza, bad_condition), -1)
def testCreatePairwiseDisjointSets_Multiple(self): a = SourceSet(set(['common', 'intel']), set([SourceListCondition('ia32', 'Chromium', 'linux')])) b = SourceSet(set(['common', 'intel', 'chrome']), set([SourceListCondition('ia32', 'Chrome', 'linux')])) c = SourceSet(set(['common', 'intel']), set([SourceListCondition('x64', 'Chromium', 'linux')])) d = SourceSet(set(['common', 'intel', 'chrome']), set([SourceListCondition('x64', 'Chrome', 'linux')])) e = SourceSet(set(['common', 'arm']), set([SourceListCondition('arm', 'Chromium', 'linux')])) f = SourceSet( set(['common', 'arm-neon', 'chrome', 'chromeos']), set([SourceListCondition('arm-neon', 'ChromeOS', 'linux')])) expected = [] expected.append( SourceSet( set(['common']), set([ SourceListCondition('ia32', 'Chromium', 'linux'), SourceListCondition('ia32', 'Chrome', 'linux'), SourceListCondition('x64', 'Chromium', 'linux'), SourceListCondition('x64', 'Chrome', 'linux'), SourceListCondition('arm', 'Chromium', 'linux'), SourceListCondition('arm-neon', 'ChromeOS', 'linux') ]))) expected.append( SourceSet( set(['intel']), set([ SourceListCondition('ia32', 'Chromium', 'linux'), SourceListCondition('ia32', 'Chrome', 'linux'), SourceListCondition('x64', 'Chromium', 'linux'), SourceListCondition('x64', 'Chrome', 'linux') ]))) expected.append( SourceSet(set(['arm']), set([SourceListCondition('arm', 'Chromium', 'linux')]))) expected.append( SourceSet( set(['chrome']), set([ SourceListCondition('ia32', 'Chrome', 'linux'), SourceListCondition('x64', 'Chrome', 'linux'), SourceListCondition('arm-neon', 'ChromeOS', 'linux') ]))) expected.append( SourceSet( set(['arm-neon', 'chromeos']), set([SourceListCondition('arm-neon', 'ChromeOS', 'linux')]))) sets = gg.CreatePairwiseDisjointSets([a, b, c, d, e, f]) self.assertEqualSets(expected, sets)
def testCreatePairwiseDisjointSets_Pair(self): a = gg.SourceSet(set(['common', 'intel']), set(['ia32']), set(['Chromium']), set(['win'])) b = gg.SourceSet(set(['common', 'intel', 'chrome']), set(['ia32']), set(['Chrome']), set(['win'])) expected = [] expected.append( gg.SourceSet(set(['common', 'intel']), set(['ia32']), set(['Chromium', 'Chrome']), set(['win']))) expected.append( gg.SourceSet(set(['chrome']), set(['ia32']), set(['Chrome']), set(['win']))) sets = gg.CreatePairwiseDisjointSets([a, b]) self.assertEqualSets(sets, expected)