示例#1
0
文件: api.py 项目: techtonik/difio
def api_gen_callback(filename, contentdir, targetfile):   # FALSE NEGATIVE
    """
        Generate API definition for @filename,
        storing it in @contentdir as @targetfile (absoute path)

        @return - bool - True if content was generated
    """
    # skip symlinks when generating API
    if os.path.islink(filename):
        return None

    skip_file = False
    # skip tests when generating API
    dirs_to_skip = get_test_dirs()
    dirs_to_skip.append('doc/')
    dirs_to_skip.append('docs/')
    dirs_to_skip.append('example/')
    dirs_to_skip.append('examples/')
    dirs_to_skip.append('example_project/')
    dirs_to_skip.append('migrations/') # South migrations for Python
    dirs_to_skip.append('setup.py') # Python setup file

    for test_dir in dirs_to_skip:
        if filename.find('/' + test_dir) > -1:
            return False

    api_text = get_api_from_file(filename)
    if api_text:
        print filename
        f = open(targetfile, 'w')
        f.write(api_text.encode('UTF-8', 'replace'))
        f.close()
        return True
    else:
        return False
示例#2
0
文件: analytics.py 项目: difio/difio
def list_modified_files(cwd, old_ver, new_ver):
    """
NB: Uses Git and the tarball/ directory

        Returns the list of changed files with insert delete stats:
         js/jquery/resources/jquery.min.js         |    9 +-
         setup.py                                  |   12 +-

        Severity - INFO if only tests have changed, VERIFY otherwise
    """

    (severity, files_list) = diff_stats(utils.SCM_GIT, cwd, old_ver, new_ver, False)
    files_list = files_list.split("\n")[:-1]  # skip the last line, this is the summary

    changed_test_count = 0
    for f in files_list:
        for test_dir in utils.get_test_dirs():
            # if file name doesn't match a common test case pattern
            if f.lower().find(test_dir) > -1:
                changed_test_count += 1
                break  # break from the inner loop, this filename already matches test case

    if changed_test_count == len(files_list):
        severity = INFO  # only tests have changed
    else:
        severity = VERIFY

    if files_list:
        return (severity, "\n".join(files_list))
    else:
        return (PASS, "None")
示例#3
0
文件: analytics.py 项目: difio/difio
def test_case_count_callback(filename, contentdir, targetfile):  # FALSE NEGATIVE
    """
        Generate API definition for @filename,
        storing it in @contentdir as @targetfile (absolute path)

        @return - bool - True if content was generated
    """
    if os.path.islink(filename):
        return None

    fname = filename.lower()
    for test_dir in utils.get_test_dirs():
        if fname.startswith(test_dir) or (fname.find("/" + test_dir) > -1):
            return os.path.relpath(targetfile, contentdir)