Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 077cf576 authored by Makoto Onuki's avatar Makoto Onuki Committed by Android (Google) Code Review
Browse files

Merge "Add test for "ravenhelper mm"" into main

parents 329e7358 81f54835
Loading
Loading
Loading
Loading
+3 −13
Original line number Diff line number Diff line
@@ -15,9 +15,9 @@

#
# Use "ravehleper mm" to create a shell script which:
# - Reads read a list of methods from STDIN
# - Reads a list of methods from STDIN
#   Which basically looks like a list of 'com.android.ravenwoodtest.tests.Test1#testA'
# - Add @DisabledOnRavenwood to them
# - Adds @DisabledOnRavenwood to them
#
# Example usage:
#
@@ -54,16 +54,6 @@ OUT_SCRIPT="${OUT_SCRIPT:-/tmp/add-annotations.sh}"

rm -f "$OUT_SCRIPT"


with_flag() {
    local flag="$1"
    shift

    for arg in "$@"; do
        echo "$flag $arg"
    done
}

run() {
    echo "Running: $*"
    "$@"
@@ -72,7 +62,7 @@ run() {
run ${RAVENHELPER_CMD:-ravenhelper mm} \
    --output-script $OUT_SCRIPT \
    --text "$annotation" \
    $(with_flag --src $source_dirs)
    "${source_dirs[@]}"


if ! [[ -f $OUT_SCRIPT ]] ; then
+31 −0
Original line number Diff line number Diff line
@@ -222,6 +222,36 @@ genrule {
    ],
}

// Generate "MM" script for tiny-framework.
// The output contains files in the fullpaths, so we use the next
// build rule to remove the unnecessary prefixes.
genrule {
    name: "hoststubgen-test-tiny-framework-mm-output-orig",
    tools: ["ravenhelper"],
    cmd: "$(location ravenhelper) mm " +
        "--output-script $(out) " +
        "$(locations tiny-framework/src/**/*.java) " +
        "< $(location mm-method-list.txt) ",
    srcs: [
        "tiny-framework/src/**/*.java",
        "mm-method-list.txt",
    ],
    out: [
        "mm-output-orig.sed.txt",
    ],
}

genrule {
    name: "hoststubgen-test-tiny-framework-mm-output-normalized",
    cmd: "sed -e 's!^apply .*/test-tiny-framework/!apply \"!' $(in) > $(out)",
    srcs: [
        ":hoststubgen-test-tiny-framework-mm-output-orig",
    ],
    out: [
        "mm-output.sed.txt",
    ],
}

// Compare the dump of the jar files to the golden output.
python_test_host {
    name: "tiny-framework-dump-test",
@@ -231,6 +261,7 @@ python_test_host {
    data: [
        "golden-output/*.txt",
        ":hoststubgen-test-tiny-framework-pta-output-normalized",
        ":hoststubgen-test-tiny-framework-mm-output-normalized",
    ],
    java_data: [
        "hoststubgen-test-tiny-framework-orig-dump",
+42 −0
Original line number Diff line number Diff line
#!/bin/bash

set -e # Finish when any command fails.

function apply() {
    local file="$1"

    # The script is given via stdin. Write it to file.
    local sed="/tmp/pta-script.sed.tmp"
    cat > "$sed"

    echo "Running: sed -i -f \"$sed\" \"$file\""

    if ! sed -i -f "$sed" "$file" ; then
        echo 'Failed!' 1>&2
        return 1
    fi
}

#==============================================================================

apply "tiny-framework/src/com/android/hoststubgen/test/tinyframework/TinyFrameworkAnnotations.java" <<'__END_OF_SCRIPT__'

# Method addOne
46i\
    @android.platform.test.annotations.DisabledOnRavenwood

# Method addTwo
56i\
    @android.platform.test.annotations.DisabledOnRavenwood
__END_OF_SCRIPT__

#==============================================================================

apply "tiny-framework/src/com/android/hoststubgen/test/tinyframework/TinyFrameworkForTextPolicy.java" <<'__END_OF_SCRIPT__'

# Method toBeRemoved
35i\
    @android.platform.test.annotations.DisabledOnRavenwood
__END_OF_SCRIPT__

echo "All files updated successfully!"
+3 −0
Original line number Diff line number Diff line
com.android.hoststubgen.test.tinyframework.TinyFrameworkAnnotations#addOne
com.android.hoststubgen.test.tinyframework.TinyFrameworkAnnotations#addTwo
com.android.hoststubgen.test.tinyframework.TinyFrameworkForTextPolicy#toBeRemoved
 No newline at end of file
+4 −0
Original line number Diff line number Diff line
@@ -41,6 +41,10 @@ class MapOptions(
    override fun parseOption(option: String, args: ArgIterator): Boolean {
        fun nextArg(): String = args.nextArgRequired(option)

        if (!option.startsWith("-")) {
            sourceFilesOrDirectories.add(option.ensureFileExists())
            return true
        }
        when (option) {
            // TODO: Write help
            "-h", "--help" -> TODO("Help is not implemented yet")