From 2bf5ffb317c8148079375d69e7329b9e70c4993e Mon Sep 17 00:00:00 2001 From: Stuart Kent Date: Sun, 6 Jan 2019 12:46:31 -0500 Subject: [PATCH] Add simple output regression test scripts --- .travis.yml | 6 +++++- test-resources/android-gnag.html | 1 + test-resources/java-kotlin-gnag.html | 1 + testAndroidExample.sh | 31 ++++++++++++++++++++++++++++ testJavaKotlinExample.sh | 25 ++++++++++++++++++++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 test-resources/android-gnag.html create mode 100644 test-resources/java-kotlin-gnag.html create mode 100755 testAndroidExample.sh create mode 100755 testJavaKotlinExample.sh diff --git a/.travis.yml b/.travis.yml index 49cdc48..cc072dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,4 +9,8 @@ jdk: language: groovy branches: only: - - master \ No newline at end of file + - master +script: + - ./gradlew plugin:check + - ./testJavaKotlinExample.sh + - ./testAndroidExample.sh diff --git a/test-resources/android-gnag.html b/test-resources/android-gnag.html new file mode 100644 index 0000000..16a9165 --- /dev/null +++ b/test-resources/android-gnag.html @@ -0,0 +1 @@ +

Android Lint Violations

Violation: GradleCompatible
Location: app/build.gradle:50
Notes: When using a compileSdkVersion android-O revision 2 or higher, the support library version should be 26.0.0-beta1 or higher (was 25.3.1)

Violation: GradleCompatible
Location: app/build.gradle:50
Notes: This support library should not use a different version (25) than the compileSdkVersion (28)

Violation: GradleDependency
Location: app/build.gradle:50
Notes: A newer version of com.android.support:appcompat-v7 than 25.3.1 is available: 28.0.0

Violation: GoogleAppIndexingWarning
Location: app/src/main/AndroidManifest.xml:5
Notes: App is not indexable by Google Search; consider adding at least one Activity with an ACTION-VIEW intent filter. See issue explanation for more details.
Related: https://g.co/AppIndexing/AndroidStudio

Violation: AllowBackup
Location: app/src/main/AndroidManifest.xml:5
Notes: On SDK version 23 and up, your app data will be automatically backed up and restored on app install. Consider adding the attribute android:fullBackupContent to specify an @xml resource which configures which files to backup. More info: https://developer.android.com/training/backup/autosyncapi.html
Related: http://developer.android.com/reference/android/R.attr.html#allowBackup

detekt Violations

Violation: EmptyCatchBlock
Location: app/src/main/kotlin/com/gnag/example/MainKotlinActivity.kt:38
Notes: This empty block of code can be removed.

Violation: TooGenericExceptionCaught
Location: app/src/main/kotlin/com/gnag/example/MainKotlinActivity.kt:38
Notes: Caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled.

Violation: EmptyFinallyBlock
Location: app/src/main/kotlin/com/gnag/example/MainKotlinActivity.kt:40
Notes: This empty block of code can be removed.

ktlint Violations

Violation: no-semi
Location: app/src/main/kotlin/com/gnag/example/MainKotlinActivity.kt:16
Notes: Unnecessary semicolon (cannot be auto-corrected)

Violation: no-semi
Location: app/src/main/kotlin/com/gnag/example/MainKotlinActivity.kt:18
Notes: Unnecessary semicolon (cannot be auto-corrected)

Violation: no-semi
Location: app/src/main/kotlin/com/gnag/example/MainKotlinActivity.kt:19
Notes: Unnecessary semicolon (cannot be auto-corrected)

Violation: no-semi
Location: app/src/main/kotlin/com/gnag/example/MainKotlinActivity.kt:20
Notes: Unnecessary semicolon (cannot be auto-corrected)

Violation: no-blank-line-before-rbrace
Location: app/src/main/kotlin/com/gnag/example/MainKotlinActivity.kt:39
Notes: Unexpected blank line(s) before "}" (cannot be auto-corrected)

Violation: no-blank-line-before-rbrace
Location: app/src/main/kotlin/com/gnag/example/MainKotlinActivity.kt:41
Notes: Unexpected blank line(s) before "}" (cannot be auto-corrected)

Violation: no-blank-line-before-rbrace
Location: app/src/main/kotlin/com/gnag/example/MainKotlinActivity.kt:43
Notes: Unexpected blank line(s) before "}" (cannot be auto-corrected)

Violation: no-blank-line-before-rbrace
Location: app/src/main/kotlin/com/gnag/example/MainKotlinActivity.kt:45
Notes: Unexpected blank line(s) before "}" (cannot be auto-corrected)

Findbugs Violations

Violation: FI_USELESS
Location: app/src/main/java/com/gnag/example/MainActivity.java:49
Notes: Finalizer does nothing but call superclass finalizer

Checkstyle Violations

Violation: EmptyBlockCheck
Location: app/src/main/java/com/gnag/example/MainActivity.java:40
Notes: Empty finally block.

Violation: AvoidStarImportCheck
Location: app/src/test/java/com/gnag/example/ExampleUnitTest.java:20
Notes: Using the '.*' form of import should be avoided - org.junit.Assert.*.

Violation: MethodNameCheck
Location: app/src/test/java/com/gnag/example/ExampleUnitTest.java:27
Notes: Name 'addition_isCorrect' must match pattern '^[a-z][a-zA-Z0-9]*$'.

Violation: MagicNumberCheck
Location: app/src/test/java/com/gnag/example/ExampleUnitTest.java:28
Notes: '4' is a magic number.

\ No newline at end of file diff --git a/test-resources/java-kotlin-gnag.html b/test-resources/java-kotlin-gnag.html new file mode 100644 index 0000000..ee8a084 --- /dev/null +++ b/test-resources/java-kotlin-gnag.html @@ -0,0 +1 @@ +

detekt Violations

Violation: EmptyCatchBlock
Location: src/main/java/com/btkelly/gnag/example/KotlinFileInJavaSourceSet.kt:39
Notes: This empty block of code can be removed.

Violation: TooGenericExceptionCaught
Location: src/main/java/com/btkelly/gnag/example/KotlinFileInJavaSourceSet.kt:39
Notes: Caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled.

Violation: EmptyFinallyBlock
Location: src/main/java/com/btkelly/gnag/example/KotlinFileInJavaSourceSet.kt:41
Notes: This empty block of code can be removed.

Violation: TooGenericExceptionCaught
Location: src/main/kotlin/com/btkelly/gnag/example/KotlinFileInKotlinSourceSet.kt:39
Notes: Caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled.

Violation: EmptyCatchBlock
Location: src/main/kotlin/com/btkelly/gnag/example/KotlinFileInKotlinSourceSet.kt:39
Notes: This empty block of code can be removed.

Violation: EmptyFinallyBlock
Location: src/main/kotlin/com/btkelly/gnag/example/KotlinFileInKotlinSourceSet.kt:41
Notes: This empty block of code can be removed.

ktlint Violations

Violation: no-blank-line-before-rbrace
Location: src/main/java/com/btkelly/gnag/example/KotlinFileInJavaSourceSet.kt:40
Notes: Unexpected blank line(s) before "}" (cannot be auto-corrected)

Violation: no-blank-line-before-rbrace
Location: src/main/java/com/btkelly/gnag/example/KotlinFileInJavaSourceSet.kt:42
Notes: Unexpected blank line(s) before "}" (cannot be auto-corrected)

Violation: no-blank-line-before-rbrace
Location: src/main/java/com/btkelly/gnag/example/KotlinFileInJavaSourceSet.kt:46
Notes: Unexpected blank line(s) before "}" (cannot be auto-corrected)

Violation: no-blank-line-before-rbrace
Location: src/main/kotlin/com/btkelly/gnag/example/KotlinFileInKotlinSourceSet.kt:40
Notes: Unexpected blank line(s) before "}" (cannot be auto-corrected)

Violation: no-blank-line-before-rbrace
Location: src/main/kotlin/com/btkelly/gnag/example/KotlinFileInKotlinSourceSet.kt:42
Notes: Unexpected blank line(s) before "}" (cannot be auto-corrected)

Violation: no-blank-line-before-rbrace
Location: src/main/kotlin/com/btkelly/gnag/example/KotlinFileInKotlinSourceSet.kt:46
Notes: Unexpected blank line(s) before "}" (cannot be auto-corrected)

Findbugs Violations

Violation: FI_USELESS
Location: src/main/java/com/btkelly/gnag/example/JavaFileInJavaSourceSet.java:44
Notes: Finalizer does nothing but call superclass finalizer

Checkstyle Violations

Violation: EmptyBlockCheck
Location: src/main/java/com/btkelly/gnag/example/JavaFileInJavaSourceSet.java:36
Notes: Empty finally block.

\ No newline at end of file diff --git a/testAndroidExample.sh b/testAndroidExample.sh new file mode 100755 index 0000000..f157d81 --- /dev/null +++ b/testAndroidExample.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +echo "Deleting any existing report..." + +{ + pushd example-android/ + ./gradlew app:clean + popd +} &> /dev/null + +echo "Generating a new report..." + +./buildAndRunAndroidExample.sh &> /dev/null + +echo "Comparing new report to canonical report..." + +ls +ls example-android +ls example-android/app +ls example-android/app/build +ls example-android/app/build/outputs +ls example-android/app/build/outputs/gnag +diff test-resources/android-gnag.html example-android/app/build/outputs/gnag/gnag.html + +if [ $? -eq 0 ]; then + echo "New report matched canonical report; test passed!" + exit 0 +else + echo "New report did not match canonical report; test failed!" + exit 1 +fi diff --git a/testJavaKotlinExample.sh b/testJavaKotlinExample.sh new file mode 100755 index 0000000..cf41c21 --- /dev/null +++ b/testJavaKotlinExample.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +echo "Deleting any existing report..." + +{ + pushd example-java-kotlin/ + ./gradlew clean + popd +} &> /dev/null + +echo "Generating a new report..." + +./buildAndRunJavaKotlinExample.sh &> /dev/null + +echo "Comparing new report to canonical report..." + +diff test-resources/java-kotlin-gnag.html example-java-kotlin/build/outputs/gnag/gnag.html + +if [ $? -eq 0 ]; then + echo "New report matched canonical report; test passed!" + exit 0 +else + echo "New report did not match canonical report; test failed!" + exit 1 +fi