Example #1
0
    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 = set()
        expected.add(
            SourceSet(
                set(['common']),
                set([
                    SourceListCondition('ia32', 'Chromium', 'win'),
                    SourceListCondition('x64', 'Chrome', 'win'),
                    SourceListCondition('arm', 'Chromium', 'win')
                ])))
        expected.add(
            SourceSet(
                set(['intel']),
                set([
                    SourceListCondition('ia32', 'Chromium', 'win'),
                    SourceListCondition('x64', 'Chrome', 'win')
                ])))
        expected.add(
            SourceSet(set(['chrome']),
                      set([SourceListCondition('x64', 'Chrome', 'win')])))
        expected.add(
            SourceSet(set(['arm']),
                      set([SourceListCondition('arm', 'Chromium', 'win')])))

        source_sets = gg.CreatePairwiseDisjointSets([a, b, c])
        self.assertEqualSets(expected, set(source_sets))
Example #2
0
    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 gn 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_gn.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)
Example #3
0
    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 = set()
        expected.add(
            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.add(
            SourceSet(
                set(['intel']),
                set([
                    SourceListCondition('ia32', 'Chromium', 'linux'),
                    SourceListCondition('ia32', 'Chrome', 'linux'),
                    SourceListCondition('x64', 'Chromium', 'linux'),
                    SourceListCondition('x64', 'Chrome', 'linux')
                ])))
        expected.add(
            SourceSet(set(['arm']),
                      set([SourceListCondition('arm', 'Chromium', 'linux')])))
        expected.add(
            SourceSet(
                set(['chrome']),
                set([
                    SourceListCondition('ia32', 'Chrome', 'linux'),
                    SourceListCondition('x64', 'Chrome', 'linux'),
                    SourceListCondition('arm-neon', 'ChromeOS', 'linux')
                ])))
        expected.add(
            SourceSet(
                set(['arm-neon', 'chromeos']),
                set([SourceListCondition('arm-neon', 'ChromeOS', 'linux')])))

        source_sets = gg.CreatePairwiseDisjointSets([a, b, c, d, e, f])
        self.assertEqualSets(expected, set(source_sets))