def test_symbol_presence(self):
        # Ensure no discrepancies between the master symbol table and what's in
        # the sandbox.
        sandbox = self.sandbox()

        all_symbols = set()
        all_symbols |= set(FUNCTIONS.keys())
        all_symbols |= set(SPECIAL_VARIABLES.keys())

        for symbol in sandbox:
            self.assertIn(symbol, all_symbols)
            all_symbols.remove(symbol)

        self.assertEqual(len(all_symbols), 0)
    def test_symbol_presence(self):
        # Ensure no discrepancies between the master symbol table and what's in
        # the sandbox.
        sandbox = self.sandbox()

        all_symbols = set()
        all_symbols |= set(FUNCTIONS.keys())
        all_symbols |= set(SPECIAL_VARIABLES.keys())

        for symbol in sandbox:
            self.assertIn(symbol, all_symbols)
            all_symbols.remove(symbol)

        self.assertEqual(len(all_symbols), 0)
    def reference(self, symbol, name_only=False):
        if name_only:
            for s in sorted(VARIABLES.keys()):
                print(s)

            for s in sorted(FUNCTIONS.keys()):
                print(s)

            for s in sorted(SPECIAL_VARIABLES.keys()):
                print(s)

            return 0

        if len(symbol):
            for s in symbol:
                if s in VARIABLES:
                    self.variable_reference(s)
                    continue
                elif s in FUNCTIONS:
                    self.function_reference(s)
                    continue
                elif s in SPECIAL_VARIABLES:
                    self.special_reference(s)
                    continue

                print('Could not find symbol: %s' % s)
                return 1

            return 0

        print('=========')
        print('VARIABLES')
        print('=========')
        print('')
        print('This section lists all the variables that may be set ')
        print('in moz.build files.')
        print('')

        for v in sorted(VARIABLES.keys()):
            self.variable_reference(v)

        print('=========')
        print('FUNCTIONS')
        print('=========')
        print('')
        print('This section lists all the functions that may be called ')
        print('in moz.build files.')
        print('')

        for f in sorted(FUNCTIONS.keys()):
            self.function_reference(f)

        print('=================')
        print('SPECIAL VARIABLES')
        print('=================')
        print('')

        for v in sorted(SPECIAL_VARIABLES.keys()):
            self.special_reference(v)

        return 0
Exemple #4
0
    def reference(self, symbol, name_only=False):
        if name_only:
            for s in sorted(VARIABLES.keys()):
                print(s)

            for s in sorted(FUNCTIONS.keys()):
                print(s)

            for s in sorted(SPECIAL_VARIABLES.keys()):
                print(s)

            return 0

        if len(symbol):
            for s in symbol:
                if s in VARIABLES:
                    self.variable_reference(s)
                    continue
                elif s in FUNCTIONS:
                    self.function_reference(s)
                    continue
                elif s in SPECIAL_VARIABLES:
                    self.special_reference(s)
                    continue

                print('Could not find symbol: %s' % s)
                return 1

            return 0

        print('=========')
        print('VARIABLES')
        print('=========')
        print('')
        print('This section lists all the variables that may be set ')
        print('in moz.build files.')
        print('')

        for v in sorted(VARIABLES.keys()):
            self.variable_reference(v)

        print('=========')
        print('FUNCTIONS')
        print('=========')
        print('')
        print('This section lists all the functions that may be called ')
        print('in moz.build files.')
        print('')

        for f in sorted(FUNCTIONS.keys()):
            self.function_reference(f)

        print('=================')
        print('SPECIAL VARIABLES')
        print('=================')
        print('')

        for v in sorted(SPECIAL_VARIABLES.keys()):
            self.special_reference(v)

        return 0