Exemple #1
0
    def test_recompute_inputs_if_regexp_changes(self):
        cr = compile_rule.find_compile_rule('genfiles/a.ii')
        self.assertEqual(['a.c', 'a.h', 'includes/b.h', 'includes/c.h', 'a1'],
                         cr.input_files('genfiles/a.ii'))

        # Now change the compile rule to have a different includer.
        bad_includer = computed_inputs.ComputedIncludeInputs(
            '{{path}}.c', '#bad_include "(.*?)"', other_inputs=['a1'])
        with mock.patch.object(cr, 'input_patterns', bad_includer):
            self.assertEqual(['a.c', 'a1'], cr.input_files('genfiles/a.ii'))
Exemple #2
0
    def setUp(self):
        super(TestComputedIncludes, self).setUp()

        os.makedirs(self._abspath('includes'))

        with open(self._abspath('a.c'), 'w') as f:
            f.write('#include <stdio.h>' + "\n")
            f.write('#include "a.h"' + "\n")
            f.write('int main() { return 0; }' + "\n")

        with open(self._abspath('commented.c'), 'w') as f:
            f.write('/*' + "\n")
            f.write('#include "a.h"' + "\n")
            f.write('*/' + "\n")
            f.write('#include "includes/d.h"' + "\n")

        with open(self._abspath('a.h'), 'w') as f:
            f.write('#include "includes/b.h"' + "\n")

        with open(self._abspath('stdio.h'), 'w') as f:
            f.write('' + "\n")

        with open(self._abspath(os.path.join('includes', 'b.h')), 'w') as f:
            f.write('#include "c.h"' + "\n")

        with open(self._abspath(os.path.join('includes', 'c.h')), 'w') as f:
            f.write('#define AVOID_CIRCULAR_INCLUDE 1' + "\n")
            f.write('#include "b.h"' + "\n")
            f.write('#include "../a.h"' + "\n")

        with open(self._abspath(os.path.join('includes', 'd.h')), 'w') as f:
            f.write('#define MY_USE "hello, world"' + "\n")

        with open(self._abspath('b.c'), 'w') as f:
            f.write('#include "includes/b.h"' + "\n")

        with open(self._abspath('double_include.c'), 'w') as f:
            f.write('#include "./a.h"' + "\n")
            f.write('#include "./a.h"' + "\n")

        with open(self._abspath('yelling.loudc'), 'w') as f:
            f.write('#INCLUDE "VUVUZELA.C"' + "\n")
            f.write('#INCLUDE "GODZILLA.C"' + "\n")
            f.write('INT MAIN() { RETURN 0; }' + "\n")

        with open(self._abspath('vuvuzela.loudc'), 'w') as f:
            f.write('#INCLUDE "GODZILLA.C"' + "\n")

        with open(self._abspath('godzilla.loudc'), 'w') as f:
            f.write('#INCLUDE "VUVUZELA.C"' + "\n")
            f.write('#DEFINE LOCALE "ja-JP"' + "\n")

        with open(self._abspath('magic.c'), 'w') as f:
            f.write('#include "?.h"' + "\n")

        self.includer = computed_inputs.ComputedIncludeInputs(
            '{{path}}.c', r'^#include\s+"(.*?)"', other_inputs=['a1'])

        compile_rule.register_compile('II', 'genfiles/{{path}}.ii',
                                      self.includer, CopyCompile())

        self.full_includer = (computed_inputs.ComputedIncludeInputs(
            '{{path}}.c', r'^#include\s+"(.*?)"|^#include\s+<(.*?)>'))
        compile_rule.register_compile('FULLII', 'genfiles/{{path}}.fullii',
                                      self.full_includer, CopyCompile())

        self.genfiles_includer = ComputedIncludeInputsSubclass(
            'genfiles/{{path}}.c', r'^#include\s+"(.*?)"')

        compile_rule.register_compile('GENII', 'genfiles/{{path}}.genii',
                                      self.genfiles_includer, CopyCompile())

        self.var_dep_includer = VarDependentComputedIncludeInputs(
            'magic.c', r'^#include\s+"(.*?)"')

        compile_rule.register_compile('VARII', 'genfiles/{{path}}.varii',
                                      self.var_dep_includer, CopyCompile())

        self.no_comment_dep_includer = NoCommentComputedIncludeInputs(
            '{{path}}.c', r'^#include\s+"(.*?)"')

        compile_rule.register_compile('NCII', 'genfiles/{{path}}.ncii',
                                      self.no_comment_dep_includer,
                                      CopyCompile())

        compile_rule.register_compile('C', 'genfiles/{{path}}.c',
                                      ['{{path}}.loudc'], DowncaseCompile())