diff options
author | 2017-09-04 12:20:56 +0200 | |
---|---|---|
committer | 2017-09-04 18:23:32 +0200 | |
commit | 9d8a5bd160b3c8c11e7198a95d4520b18ace7254 (patch) | |
tree | 5ba5c651f969cc6ac59adeff7f19a34959d9ee6f /src/test/shell/bazel/bazel_coverage_test.sh | |
parent | cdb8a63d3e01e396204c1a372cab49147886d100 (diff) |
Automated rollback of commit 8d6fc64b18c7e35b93f5c43dae1dbd2f8cae2147.
PiperOrigin-RevId: 167480127
Diffstat (limited to 'src/test/shell/bazel/bazel_coverage_test.sh')
-rwxr-xr-x | src/test/shell/bazel/bazel_coverage_test.sh | 95 |
1 files changed, 2 insertions, 93 deletions
diff --git a/src/test/shell/bazel/bazel_coverage_test.sh b/src/test/shell/bazel/bazel_coverage_test.sh index 41c996c625..c651f50580 100755 --- a/src/test/shell/bazel/bazel_coverage_test.sh +++ b/src/test/shell/bazel/bazel_coverage_test.sh @@ -144,98 +144,7 @@ EOF [ -e $coverage_file_path ] || fail "Coverage output file does not exist!" cat <<EOF > result.dat -SF:src/main/com/example/Collatz.java -FN:3,com/example/Collatz::<init> ()V -FNDA:0,com/example/Collatz::<init> ()V -FN:6,com/example/Collatz::getCollatzFinal (I)I -FNDA:1,com/example/Collatz::getCollatzFinal (I)I -BA:6,2 -BA:6,2 -BA:9,2 -BA:9,2 -DA:3,0 -DA:6,3 -DA:7,2 -DA:9,4 -DA:10,5 -DA:12,7 -end_of_record -EOF - if ! cmp result.dat $coverage_file_path; then - fail "Coverage output file is different than the expected file" - fi -} - -function test_java_test_java_import_coverage() { - - cat <<EOF > BUILD -java_test( - name = "test", - srcs = glob(["src/test/**/*.java"]), - test_class = "com.example.TestCollatz", - deps = [":collatz-import"], -) - -java_import( - name = "collatz-import", - jars = [":libcollatz-lib.jar"], -) - -java_library( - name = "collatz-lib", - srcs = glob(["src/main/**/*.java"]), -) -EOF - - mkdir -p src/main/com/example - cat <<EOF > src/main/com/example/Collatz.java -package com.example; - -public class Collatz { - - public static int getCollatzFinal(int n) { - if (n == 1) { - return 1; - } - if (n % 2 == 0) { - return getCollatzFinal(n / 2); - } else { - return getCollatzFinal(n * 3 + 1); - } - } - -} -EOF - - mkdir -p src/test/com/example - cat <<EOF > src/test/com/example/TestCollatz.java -package com.example; - -import static org.junit.Assert.assertEquals; -import org.junit.Test; - -public class TestCollatz { - - @Test - public void testGetCollatzFinal() { - assertEquals(Collatz.getCollatzFinal(1), 1); - assertEquals(Collatz.getCollatzFinal(5), 1); - assertEquals(Collatz.getCollatzFinal(10), 1); - assertEquals(Collatz.getCollatzFinal(21), 1); - } - -} -EOF - - bazel coverage //:test &>$TEST_log || fail "Coverage for //:test failed" - cat $TEST_log - ending_part=$(sed -n -e '/PASSED/,$p' $TEST_log) - - coverage_file_path=$(grep -Eo "/[/a-zA-Z0-9\.\_\-]+\.dat$" <<< "$ending_part") - [ -e $coverage_file_path ] || fail "Coverage output file not exists!" - - cat <<EOF > result.dat -SF:src/main/com/example/Collatz.java +SF:com/example/Collatz.java FN:3,com/example/Collatz::<init> ()V FNDA:0,com/example/Collatz::<init> ()V FN:6,com/example/Collatz::getCollatzFinal (I)I @@ -254,7 +163,7 @@ end_of_record EOF if ! cmp result.dat $coverage_file_path; then - fail "Coverage output file is different than the expected file" + fail "Coverage output file is different with expected" fi } |