Пример #1
0
 def get_infer_commands(self, verbose_output):
     javac_pattern = '[javac]'
     argument_start_pattern = 'Compilation arguments'
     calls = []
     javac_arguments = []
     collect = False
     for line in verbose_output:
         if javac_pattern in line:
             if argument_start_pattern in line:
                 collect = True
                 if javac_arguments != []:
                     capture = jwlib.create_infer_command(javac_arguments)
                     calls.append(capture)
                     javac_arguments = []
             if collect:
                 pos = line.index(javac_pattern) + len(javac_pattern)
                 content = line[pos:].strip()
                 if self.is_interesting(content):
                     arg = self.remove_quotes(content)
                     javac_arguments.append(arg)
     if javac_arguments != []:
         capture = jwlib.create_infer_command(javac_arguments)
         calls.append(capture)
         javac_arguments = []
     return calls
Пример #2
0
 def get_infer_commands(self, verbose_output):
     javac_pattern = '[javac]'
     argument_start_pattern = 'Compilation arguments'
     calls = []
     javac_arguments = []
     collect = False
     for line in verbose_output:
         if javac_pattern in line:
             if argument_start_pattern in line:
                 collect = True
                 if javac_arguments != []:
                     capture = jwlib.create_infer_command(javac_arguments)
                     calls.append(capture)
                     javac_arguments = []
             if collect:
                 pos = line.index(javac_pattern) + len(javac_pattern)
                 content = line[pos:].strip()
                 if self.is_interesting(content):
                     arg = self.remove_quotes(content)
                     javac_arguments.append(arg)
     if javac_arguments != []:
         capture = jwlib.create_infer_command(javac_arguments)
         calls.append(capture)
         javac_arguments = []
     return calls
Пример #3
0
 def get_infer_commands(self, verbose_output):
     argument_start_pattern = ' Compiler arguments: '
     calls = []
     seen_build_cmds = set([])
     for line in verbose_output:
         if argument_start_pattern in line:
             content = line.partition(argument_start_pattern)[2].strip()
             # if we're building both the debug and release configuration
             # and the build commands are identical up to "release/debug",
             # only do capture for one set of commands
             build_agnostic_cmd = content.replace('release', 'debug')
             if build_agnostic_cmd in seen_build_cmds:
                 continue
             seen_build_cmds.add(build_agnostic_cmd)
             javac_arguments = content.split(' ')
             java_files = []
             java_args = []
             for java_arg in javac_arguments:
                 if java_arg.endswith('.java'):
                     java_files.append(java_arg)
                 else:
                     java_args.append(java_arg)
             with tempfile.NamedTemporaryFile(
                     mode='w',
                     suffix='.txt',
                     prefix='gradle_',
                     dir=os.path.join(self.args.infer_out,
                                      config.JAVAC_FILELISTS_FILENAME),
                     delete=False) as sources:
                 sources.write('\n'.join(map(utils.encode, java_files)))
                 sources.flush()
                 java_args.append('@' + sources.name)
             capture = jwlib.create_infer_command(java_args)
             calls.append(capture)
     return calls
Пример #4
0
    def get_infer_commands(self, verbose_output):
        from inferlib import config, jwlib

        argument_start_pattern = ' Compiler arguments: '
        calls = []
        seen_build_cmds = set([])
        for line in verbose_output:
            if argument_start_pattern in line:
                content = line.partition(argument_start_pattern)[2].strip()
                # if we're building both the debug and release configuration
                # and the build commands are identical up to "release/debug",
                # only do capture for one set of commands
                build_agnostic_cmd = content.replace('release', 'debug')
                if build_agnostic_cmd in seen_build_cmds:
                    continue
                seen_build_cmds.add(build_agnostic_cmd)
                # Filter out the empty elements
                arguments = list(filter(None, content.split(' ')))
                extracted = extract_all(arguments)
                java_files = extracted['files']
                java_args = extracted['opts']

                with tempfile.NamedTemporaryFile(
                        mode='w',
                        suffix='.txt',
                        prefix='gradle_',
                        dir=os.path.join(self.args.infer_out,
                                         config.JAVAC_FILELISTS_FILENAME),
                        delete=False) as sources:
                    sources.write('\n'.join(map(normalize, java_files)))
                    sources.flush()
                    java_args.append('@' + sources.name)
                capture = jwlib.create_infer_command(java_args)
                calls.append(capture)
        return calls
Пример #5
0
 def get_infer_commands(self, verbose_output):
     argument_start_pattern = ' Compiler arguments: '
     calls = []
     seen_build_cmds = set([])
     for line in verbose_output:
         if argument_start_pattern in line:
             content = line.partition(argument_start_pattern)[2].strip()
             # if we're building both the debug and release configuration
             # and the build commands are identical up to "release/debug",
             # only do capture for one set of commands
             build_agnostic_cmd = content.replace('release', 'debug')
             if build_agnostic_cmd in seen_build_cmds:
                 continue
             seen_build_cmds.add(build_agnostic_cmd)
             javac_arguments = content.split(' ')
             java_files = []
             java_args = []
             for java_arg in javac_arguments:
                 if java_arg.endswith('.java'):
                     java_files.append(java_arg)
                 else:
                     java_args.append(java_arg)
             with tempfile.NamedTemporaryFile(
                     mode='w',
                     suffix='.txt',
                     prefix='gradle_',
                     dir=os.path.join(self.args.infer_out,
                                      config.JAVAC_FILELISTS_FILENAME),
                     delete=False) as sources:
                 sources.write('\n'.join(map(utils.encode, java_files)))
                 sources.flush()
                 java_args.append('@' + sources.name)
             capture = jwlib.create_infer_command(java_args)
             calls.append(capture)
     return calls
Пример #6
0
    def get_infer_commands(self, verbose_output):
        from inferlib import config, jwlib

        argument_start_pattern = ' Compiler arguments: '
        calls = []
        seen_build_cmds = set([])
        for line in verbose_output:
            if argument_start_pattern in line:
                content = line.partition(argument_start_pattern)[2].strip()
                # if we're building both the debug and release configuration
                # and the build commands are identical up to "release/debug",
                # only do capture for one set of commands
                build_agnostic_cmd = content.replace('release', 'debug')
                if build_agnostic_cmd in seen_build_cmds:
                    continue
                seen_build_cmds.add(build_agnostic_cmd)
                # Filter out the empty elements
                arguments = list(filter(None, content.split(' ')))
                extracted = extract_all(arguments)
                java_files = extracted['files']
                java_args = extracted['opts']

                with tempfile.NamedTemporaryFile(
                        mode='w',
                        suffix='.txt',
                        prefix='gradle_',
                        dir=os.path.join(self.args.infer_out,
                                         config.JAVAC_FILELISTS_FILENAME),
                        delete=False) as sources:
                    sources.write('\n'.join(map(normalize, java_files)))
                    sources.flush()
                    java_args.append('@' + sources.name)
                capture = jwlib.create_infer_command(java_args)
                calls.append(capture)
        return calls
Пример #7
0
    def get_infer_commands(self, verbose_output):
        file_pattern = r'\[DEBUG\] Stale source detected: ([^ ]*\.java)'
        options_pattern = '[DEBUG] Command line options:'
        source_roots_pattern = '[DEBUG] Source roots:'

        files_to_compile = []
        calls = []
        options_next = False
        source_roots_next = False
        for line in verbose_output:
            if options_next:
                #  line has format [Debug] <space separated options>
                javac_args = line.split(' ')[1:] + files_to_compile
                capture = jwlib.create_infer_command(self.args, javac_args)
                calls.append(capture)
                options_next = False
                files_to_compile = []

            elif source_roots_next:
                # line has format [Debug] <space separated directories>
                src_roots = line.split(' ')[1:]
                for src_root in src_roots:
                    for root, dirs, files in os.walk(src_root):
                        for name in files:
                            if name.endswith(".java"):
                                path = os.path.join(root, name)
                                files_to_compile.append(path)
                source_roots_next = False

            elif options_pattern in line:
                #  Next line will have javac options to run
                options_next = True

            elif source_roots_pattern in line:
                # Next line will have directory containing files to compile
                source_roots_next = True

            else:
                found = re.match(file_pattern, line)
                if found:
                    files_to_compile.append(found.group(1))

        return calls
Пример #8
0
    def get_infer_commands(self, verbose_output):
        file_pattern = r'\[DEBUG\] Stale source detected: ([^ ]*\.java)'
        options_pattern = '[DEBUG] Command line options:'
        source_roots_pattern = '[DEBUG] Source roots:'

        files_to_compile = []
        calls = []
        options_next = False
        source_roots_next = False
        for line in verbose_output:
            if options_next:
                #  line has format [Debug] <space separated options>
                javac_args = line.split(' ')[1:] + files_to_compile
                capture = jwlib.create_infer_command(self.args, javac_args)
                calls.append(capture)
                options_next = False
                files_to_compile = []

            elif source_roots_next:
                # line has format [Debug] <space separated directories>
                src_roots = line.split(' ')[1:]
                for src_root in src_roots:
                    for root, dirs, files in os.walk(src_root):
                        for name in files:
                            if name.endswith(".java"):
                                path = os.path.join(root, name)
                                files_to_compile.append(path)
                source_roots_next = False

            elif options_pattern in line:
                #  Next line will have javac options to run
                options_next = True

            elif source_roots_pattern in line:
                # Next line will have directory containing files to compile
                source_roots_next = True

            else:
                found = re.match(file_pattern, line)
                if found:
                    files_to_compile.append(found.group(1))

        return calls
Пример #9
0
    def get_infer_commands(self, verbose_output):
        from inferlib import config, jwlib

        argument_start_pattern = ' Compiler arguments: '
        calls = []
        seen_build_cmds = set([])
        for line in verbose_output.split('\n'):
            if argument_start_pattern in line:
                content = line.partition(argument_start_pattern)[2].strip()
                # if we're building both the debug and release configuration
                # and the build commands are identical up to "release/debug",
                # only do capture for one set of commands
                build_agnostic_cmd = content.replace('release', 'debug')
                if build_agnostic_cmd in seen_build_cmds:
                    continue
                seen_build_cmds.add(build_agnostic_cmd)
                arguments = content.split(' ')
                # Note: do *not* try to filter out empty strings from the arguments (as was done
                # here previously)! It will make compilation commands like
                # `javac -classpath '' -Xmaxerrs 1000` fail with "Unrecognized option 1000"
                extracted = extract_all(arguments)
                java_files = extracted['files']
                java_args = extracted['opts']

                with tempfile.NamedTemporaryFile(
                        mode='w',
                        suffix='.txt',
                        prefix='gradle_',
                        dir=os.path.join(self.args.infer_out,
                                         config.JAVAC_FILELISTS_FILENAME),
                        delete=False) as sources:
                    sources.write('\n'.join(map(normalize, java_files)))
                    sources.flush()
                    java_args.append('@' + sources.name)
                capture = jwlib.create_infer_command(java_args)
                calls.append(capture)
        return calls
Пример #10
0
    def get_infer_commands(self, verbose_output):
        from inferlib import config, jwlib

        argument_start_pattern = ' Compiler arguments: '
        calls = []
        seen_build_cmds = set([])
        for line in verbose_output.split('\n'):
            if argument_start_pattern in line:
                content = line.partition(argument_start_pattern)[2].strip()
                # if we're building both the debug and release configuration
                # and the build commands are identical up to "release/debug",
                # only do capture for one set of commands
                build_agnostic_cmd = content.replace('release', 'debug')
                if build_agnostic_cmd in seen_build_cmds:
                    continue
                seen_build_cmds.add(build_agnostic_cmd)
                arguments = content.split(' ')
                # Note: do *not* try to filter out empty strings from the arguments (as was done
                # here previously)! It will make compilation commands like
                # `javac -classpath '' -Xmaxerrs 1000` fail with "Unrecognized option 1000"
                extracted = extract_all(arguments)
                java_files = extracted['files']
                java_args = extracted['opts']

                with tempfile.NamedTemporaryFile(
                        mode='w',
                        suffix='.txt',
                        prefix='gradle_',
                        dir=os.path.join(self.args.infer_out,
                                         config.JAVAC_FILELISTS_FILENAME),
                        delete=False) as sources:
                    sources.write('\n'.join(map(normalize, java_files)))
                    sources.flush()
                    java_args.append('@' + sources.name)
                capture = jwlib.create_infer_command(java_args)
                calls.append(capture)
        return calls