コード例 #1
0
def copy_release_dir(path_to_dev_releases, path_to_live_releases,
                     release_version):
    """Copy a release directory with the given release version from the dev
    site to the live site. For example,
    /cse/www2/types/dev/checker-framework/releases/2.0.0 ->
    /cse/www2/types/checker-framework/releases/2.0.0"""
    source_location = os.path.join(path_to_dev_releases, release_version)
    dest_location = os.path.join(path_to_live_releases, release_version)

    if os.path.exists(dest_location):
        delete_path(dest_location)

    if os.path.exists(dest_location):
        raise Exception("Destination location exists: " + dest_location)

    # The / at the end of the source location is necessary so that
    # rsync copies the files in the source directory to the destination directory
    # rather than a subdirectory of the destination directory.
    cmd = "rsync --omit-dir-times --recursive --links --quiet %s/ %s" % (
        source_location,
        dest_location,
    )
    execute(cmd)

    return dest_location
コード例 #2
0
def maven_sanity_check(sub_sanity_dir_name, repo_url, release_version):
    """
    Run the Maven sanity check with the local artifacts or from the repo at
    repo_url.
    """
    checker_dir = os.path.join(CHECKER_FRAMEWORK, "checker")
    maven_sanity_dir = os.path.join(SANITY_DIR, sub_sanity_dir_name)
    if os.path.isdir(maven_sanity_dir):
        delete_path(maven_sanity_dir)

    execute("mkdir -p " + maven_sanity_dir)

    maven_example_dir = os.path.join(maven_sanity_dir, "MavenExample")
    output_log = os.path.join(maven_example_dir, "output.log")

    ant_release_script = os.path.join(CHECKER_FRAMEWORK_RELEASE, "release.xml")
    get_example_dir_cmd = (
        "ant -f %s update-and-copy-maven-example -Dchecker=%s -Dversion=%s -Ddest.dir=%s"
        % (ant_release_script, checker_dir, release_version, maven_sanity_dir))

    execute(get_example_dir_cmd)
    path_to_artifacts = os.path.join(os.path.expanduser("~"), ".m2",
                                     "repository", "org", "checkerframework")
    if repo_url != "":
        print((
            "This script will now delete your Maven Checker Framework artifacts.\n"
            +
            "See README-release-process.html#Maven-Plugin dependencies.  These artifacts "
            +
            "will need to be re-downloaded the next time you need them.  This will be "
            + "done automatically by Maven next time you use the plugin."))

        if os.path.isdir(path_to_artifacts):
            delete_path(path_to_artifacts)
        maven_example_pom = os.path.join(maven_example_dir, "pom.xml")
        add_repo_information(maven_example_pom, repo_url)

    os.environ["JAVA_HOME"] = os.environ["JAVA_8_HOME"]
    execute_write_to_file("mvn compile", output_log, False, maven_example_dir)
    if repo_url != "":
        delete_path(path_to_artifacts)
コード例 #3
0
def javac_sanity_check(checker_framework_website, release_version):
    """
    Download the release of the Checker Framework from the development website
    and NullnessExampleWithWarnings.java from the GitHub repository.
    Run the Nullness Checker on NullnessExampleWithWarnings and verify the output
    Fails if the expected errors are not found in the output.
    """

    new_checkers_release_zip = os.path.join(
        checker_framework_website,
        "releases",
        release_version,
        "checker-framework-" + release_version + ".zip",
    )

    javac_sanity_dir = os.path.join(SANITY_DIR, "javac")

    if os.path.isdir(javac_sanity_dir):
        delete_path(javac_sanity_dir)
    execute("mkdir -p " + javac_sanity_dir)

    javac_sanity_zip = os.path.join(
        javac_sanity_dir, "checker-framework-%s.zip" % release_version)

    print("Attempting to download %s to %s" %
          (new_checkers_release_zip, javac_sanity_zip))
    download_binary(new_checkers_release_zip, javac_sanity_zip)

    nullness_example_url = "https://raw.githubusercontent.com/eisop/checker-framework/master/docs/examples/NullnessExampleWithWarnings.java"
    nullness_example = os.path.join(javac_sanity_dir,
                                    "NullnessExampleWithWarnings.java")

    if os.path.isfile(nullness_example):
        delete(nullness_example)

    wget_file(nullness_example_url, javac_sanity_dir)

    deploy_dir = os.path.join(javac_sanity_dir,
                              "checker-framework-" + release_version)

    if os.path.exists(deploy_dir):
        print("Deleting existing path: " + deploy_dir)
        delete_path(deploy_dir)

    with zipfile.ZipFile(javac_sanity_zip, "r") as z:
        z.extractall(javac_sanity_dir)

    ensure_user_access(deploy_dir)

    sanity_javac = os.path.join(deploy_dir, "checker", "bin", "javac")
    nullness_output = os.path.join(deploy_dir, "output.log")

    cmd = (
        sanity_javac +
        " -processor org.checkerframework.checker.nullness.NullnessChecker " +
        nullness_example + " -Anomsgtext")
    execute_write_to_file(cmd, nullness_output, False)
    check_results(
        "Javac sanity check",
        nullness_output,
        [
            "NullnessExampleWithWarnings.java:23: error: (assignment.type.incompatible)",
            "NullnessExampleWithWarnings.java:33: error: (argument.type.incompatible)",
        ],
    )

    # this is a smoke test for the built-in checker shorthand feature
    # https://checkerframework.org/manual/#shorthand-for-checkers
    nullness_shorthand_output = os.path.join(deploy_dir,
                                             "output_shorthand.log")
    cmd = (sanity_javac + " -processor NullnessChecker " + nullness_example +
           " -Anomsgtext")
    execute_write_to_file(cmd, nullness_shorthand_output, False)
    check_results(
        "Javac Shorthand Sanity Check",
        nullness_shorthand_output,
        [
            "NullnessExampleWithWarnings.java:23: error: (assignment.type.incompatible)",
            "NullnessExampleWithWarnings.java:33: error: (argument.type.incompatible)",
        ],
    )