Skip to content

Commit

Permalink
Add simple output regression test scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
stkent committed Jan 6, 2019
1 parent 2120817 commit 2bf5ffb
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ jdk:
language: groovy
branches:
only:
- master
- master
script:
- ./gradlew plugin:check
- ./testJavaKotlinExample.sh
- ./testAndroidExample.sh
1 change: 1 addition & 0 deletions test-resources/android-gnag.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><html><link rel="stylesheet" href="github-markdown.css"><article class="markdown-body"><h2>Android Lint Violations</h2><b>Violation: </b>GradleCompatible<br /><b>Location: </b><code>app/build.gradle:50</code><br /><b>Notes: </b>When using a <code>compileSdkVersion</code> android-O revision 2 or higher, the support library version should be 26.0.0-beta1 or higher (was 25.3.1)<br /><br /><b>Violation: </b>GradleCompatible<br /><b>Location: </b><code>app/build.gradle:50</code><br /><b>Notes: </b>This support library should not use a different version (25) than the <code>compileSdkVersion</code> (28)<br /><br /><b>Violation: </b>GradleDependency<br /><b>Location: </b><code>app/build.gradle:50</code><br /><b>Notes: </b>A newer version of com.android.support:appcompat-v7 than 25.3.1 is available: 28.0.0<br /><br /><b>Violation: </b>GoogleAppIndexingWarning<br /><b>Location: </b><code>app/src/main/AndroidManifest.xml:5</code><br /><b>Notes: </b>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.<br /><b>Related: </b><a target="_blank" href="https://g.co/AppIndexing/AndroidStudio">https://g.co/AppIndexing/AndroidStudio</a><br /><br /><b>Violation: </b>AllowBackup<br /><b>Location: </b><code>app/src/main/AndroidManifest.xml:5</code><br /><b>Notes: </b>On SDK version 23 and up, your app data will be automatically backed up and restored on app install. Consider adding the attribute <code>android:fullBackupContent</code> to specify an <code>@xml</code> resource which configures which files to backup. More info: <a href="https://developer.android.com/training/backup/autosyncapi.html">https://developer.android.com/training/backup/autosyncapi.html</a><br /><b>Related: </b><a target="_blank" href="http://developer.android.com/reference/android/R.attr.html#allowBackup">http://developer.android.com/reference/android/R.attr.html#allowBackup</a><br /><br /><h2>detekt Violations</h2><b>Violation: </b>EmptyCatchBlock<br /><b>Location: </b><code>app/src/main/kotlin/com/gnag/example/MainKotlinActivity.kt:38</code><br /><b>Notes: </b>This empty block of code can be removed.<br /><br /><b>Violation: </b>TooGenericExceptionCaught<br /><b>Location: </b><code>app/src/main/kotlin/com/gnag/example/MainKotlinActivity.kt:38</code><br /><b>Notes: </b>Caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled.<br /><br /><b>Violation: </b>EmptyFinallyBlock<br /><b>Location: </b><code>app/src/main/kotlin/com/gnag/example/MainKotlinActivity.kt:40</code><br /><b>Notes: </b>This empty block of code can be removed.<br /><br /><h2>ktlint Violations</h2><b>Violation: </b>no-semi<br /><b>Location: </b><code>app/src/main/kotlin/com/gnag/example/MainKotlinActivity.kt:16</code><br /><b>Notes: </b>Unnecessary semicolon (cannot be auto-corrected)<br /><br /><b>Violation: </b>no-semi<br /><b>Location: </b><code>app/src/main/kotlin/com/gnag/example/MainKotlinActivity.kt:18</code><br /><b>Notes: </b>Unnecessary semicolon (cannot be auto-corrected)<br /><br /><b>Violation: </b>no-semi<br /><b>Location: </b><code>app/src/main/kotlin/com/gnag/example/MainKotlinActivity.kt:19</code><br /><b>Notes: </b>Unnecessary semicolon (cannot be auto-corrected)<br /><br /><b>Violation: </b>no-semi<br /><b>Location: </b><code>app/src/main/kotlin/com/gnag/example/MainKotlinActivity.kt:20</code><br /><b>Notes: </b>Unnecessary semicolon (cannot be auto-corrected)<br /><br /><b>Violation: </b>no-blank-line-before-rbrace<br /><b>Location: </b><code>app/src/main/kotlin/com/gnag/example/MainKotlinActivity.kt:39</code><br /><b>Notes: </b>Unexpected blank line(s) before "}" (cannot be auto-corrected)<br /><br /><b>Violation: </b>no-blank-line-before-rbrace<br /><b>Location: </b><code>app/src/main/kotlin/com/gnag/example/MainKotlinActivity.kt:41</code><br /><b>Notes: </b>Unexpected blank line(s) before "}" (cannot be auto-corrected)<br /><br /><b>Violation: </b>no-blank-line-before-rbrace<br /><b>Location: </b><code>app/src/main/kotlin/com/gnag/example/MainKotlinActivity.kt:43</code><br /><b>Notes: </b>Unexpected blank line(s) before "}" (cannot be auto-corrected)<br /><br /><b>Violation: </b>no-blank-line-before-rbrace<br /><b>Location: </b><code>app/src/main/kotlin/com/gnag/example/MainKotlinActivity.kt:45</code><br /><b>Notes: </b>Unexpected blank line(s) before "}" (cannot be auto-corrected)<br /><br /><h2>Findbugs Violations</h2><b>Violation: </b>FI_USELESS<br /><b>Location: </b><code>app/src/main/java/com/gnag/example/MainActivity.java:49</code><br /><b>Notes: </b>Finalizer does nothing but call superclass finalizer<br /><br /><h2>Checkstyle Violations</h2><b>Violation: </b>EmptyBlockCheck<br /><b>Location: </b><code>app/src/main/java/com/gnag/example/MainActivity.java:40</code><br /><b>Notes: </b>Empty finally block.<br /><br /><b>Violation: </b>AvoidStarImportCheck<br /><b>Location: </b><code>app/src/test/java/com/gnag/example/ExampleUnitTest.java:20</code><br /><b>Notes: </b>Using the '.*' form of import should be avoided - org.junit.Assert.*.<br /><br /><b>Violation: </b>MethodNameCheck<br /><b>Location: </b><code>app/src/test/java/com/gnag/example/ExampleUnitTest.java:27</code><br /><b>Notes: </b>Name 'addition_isCorrect' must match pattern '^[a-z][a-zA-Z0-9]*$'.<br /><br /><b>Violation: </b>MagicNumberCheck<br /><b>Location: </b><code>app/src/test/java/com/gnag/example/ExampleUnitTest.java:28</code><br /><b>Notes: </b>'4' is a magic number.<br /><br /></article></html>
1 change: 1 addition & 0 deletions test-resources/java-kotlin-gnag.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><html><link rel="stylesheet" href="github-markdown.css"><article class="markdown-body"><h2>detekt Violations</h2><b>Violation: </b>EmptyCatchBlock<br /><b>Location: </b><code>src/main/java/com/btkelly/gnag/example/KotlinFileInJavaSourceSet.kt:39</code><br /><b>Notes: </b>This empty block of code can be removed.<br /><br /><b>Violation: </b>TooGenericExceptionCaught<br /><b>Location: </b><code>src/main/java/com/btkelly/gnag/example/KotlinFileInJavaSourceSet.kt:39</code><br /><b>Notes: </b>Caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled.<br /><br /><b>Violation: </b>EmptyFinallyBlock<br /><b>Location: </b><code>src/main/java/com/btkelly/gnag/example/KotlinFileInJavaSourceSet.kt:41</code><br /><b>Notes: </b>This empty block of code can be removed.<br /><br /><b>Violation: </b>TooGenericExceptionCaught<br /><b>Location: </b><code>src/main/kotlin/com/btkelly/gnag/example/KotlinFileInKotlinSourceSet.kt:39</code><br /><b>Notes: </b>Caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled.<br /><br /><b>Violation: </b>EmptyCatchBlock<br /><b>Location: </b><code>src/main/kotlin/com/btkelly/gnag/example/KotlinFileInKotlinSourceSet.kt:39</code><br /><b>Notes: </b>This empty block of code can be removed.<br /><br /><b>Violation: </b>EmptyFinallyBlock<br /><b>Location: </b><code>src/main/kotlin/com/btkelly/gnag/example/KotlinFileInKotlinSourceSet.kt:41</code><br /><b>Notes: </b>This empty block of code can be removed.<br /><br /><h2>ktlint Violations</h2><b>Violation: </b>no-blank-line-before-rbrace<br /><b>Location: </b><code>src/main/java/com/btkelly/gnag/example/KotlinFileInJavaSourceSet.kt:40</code><br /><b>Notes: </b>Unexpected blank line(s) before "}" (cannot be auto-corrected)<br /><br /><b>Violation: </b>no-blank-line-before-rbrace<br /><b>Location: </b><code>src/main/java/com/btkelly/gnag/example/KotlinFileInJavaSourceSet.kt:42</code><br /><b>Notes: </b>Unexpected blank line(s) before "}" (cannot be auto-corrected)<br /><br /><b>Violation: </b>no-blank-line-before-rbrace<br /><b>Location: </b><code>src/main/java/com/btkelly/gnag/example/KotlinFileInJavaSourceSet.kt:46</code><br /><b>Notes: </b>Unexpected blank line(s) before "}" (cannot be auto-corrected)<br /><br /><b>Violation: </b>no-blank-line-before-rbrace<br /><b>Location: </b><code>src/main/kotlin/com/btkelly/gnag/example/KotlinFileInKotlinSourceSet.kt:40</code><br /><b>Notes: </b>Unexpected blank line(s) before "}" (cannot be auto-corrected)<br /><br /><b>Violation: </b>no-blank-line-before-rbrace<br /><b>Location: </b><code>src/main/kotlin/com/btkelly/gnag/example/KotlinFileInKotlinSourceSet.kt:42</code><br /><b>Notes: </b>Unexpected blank line(s) before "}" (cannot be auto-corrected)<br /><br /><b>Violation: </b>no-blank-line-before-rbrace<br /><b>Location: </b><code>src/main/kotlin/com/btkelly/gnag/example/KotlinFileInKotlinSourceSet.kt:46</code><br /><b>Notes: </b>Unexpected blank line(s) before "}" (cannot be auto-corrected)<br /><br /><h2>Findbugs Violations</h2><b>Violation: </b>FI_USELESS<br /><b>Location: </b><code>src/main/java/com/btkelly/gnag/example/JavaFileInJavaSourceSet.java:44</code><br /><b>Notes: </b>Finalizer does nothing but call superclass finalizer<br /><br /><h2>Checkstyle Violations</h2><b>Violation: </b>EmptyBlockCheck<br /><b>Location: </b><code>src/main/java/com/btkelly/gnag/example/JavaFileInJavaSourceSet.java:36</code><br /><b>Notes: </b>Empty finally block.<br /><br /></article></html>
31 changes: 31 additions & 0 deletions testAndroidExample.sh
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions testJavaKotlinExample.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2bf5ffb

Please sign in to comment.