From 0f1e6a2f35b4ed362a30053a6179884c72104ffe Mon Sep 17 00:00:00 2001 From: camsim99 Date: Thu, 3 Feb 2022 13:22:12 -0800 Subject: [PATCH 1/7] Add setting for finding deprecations --- shell/platform/android/test_runner/build.gradle | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/shell/platform/android/test_runner/build.gradle b/shell/platform/android/test_runner/build.gradle index bc69251a8c897..8381f301971d2 100644 --- a/shell/platform/android/test_runner/build.gradle +++ b/shell/platform/android/test_runner/build.gradle @@ -17,6 +17,11 @@ apply plugin: "com.android.library" rootProject.buildDir = project.property("build_dir") +gradle.projectsEvaluated { + tasks.withType(JavaCompile) { + options.compilerArgs << "-Xlint:deprecation" + } +} android { compileSdkVersion 31 From f45e1ebe73cfc416398c52365ddca38007f6fe28 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Thu, 3 Feb 2022 14:25:38 -0800 Subject: [PATCH 2/7] Add option for seeing warnings --- shell/platform/android/test_runner/build.gradle | 4 ++++ testing/run_tests.py | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/shell/platform/android/test_runner/build.gradle b/shell/platform/android/test_runner/build.gradle index 8381f301971d2..735125813344b 100644 --- a/shell/platform/android/test_runner/build.gradle +++ b/shell/platform/android/test_runner/build.gradle @@ -17,10 +17,14 @@ apply plugin: "com.android.library" rootProject.buildDir = project.property("build_dir") +// Shows warnings for usage of deprecated API usages if specified. +def showDeprecations = project.findProperty('showDeprecations') gradle.projectsEvaluated { + if (showDeprecations) { tasks.withType(JavaCompile) { options.compilerArgs << "-Xlint:deprecation" } + } } android { diff --git a/testing/run_tests.py b/testing/run_tests.py index 99c8137676550..64e21cf767629 100755 --- a/testing/run_tests.py +++ b/testing/run_tests.py @@ -326,7 +326,7 @@ def JavaBin(): return os.path.join(JavaHome(), 'bin', 'java.exe' if IsWindows() else 'java') -def RunJavaTests(filter, android_variant='android_debug_unopt'): +def RunJavaTests(filter, android_variant='android_debug_unopt', showDeprecations=False): """Runs the Java JUnit unit tests for the Android embedding""" test_runner_dir = os.path.join(buildroot_dir, 'flutter', 'shell', 'platform', 'android', 'test_runner') gradle_bin = os.path.join(buildroot_dir, 'gradle', 'bin', 'gradle.bat' if IsWindows() else 'gradle') @@ -336,10 +336,13 @@ def RunJavaTests(filter, android_variant='android_debug_unopt'): gradle_cache_dir = os.path.join(out_dir, android_variant, 'robolectric_tests', '.gradle') test_class = filter if filter else 'io.flutter.FlutterTestSuite' + show_deprecations = 'true' if showDeprecations else '' + command = [ gradle_bin, '-Pflutter_jar=%s' % flutter_jar, '-Pbuild_dir=%s' % build_dir, + '-PshowDeprecations=%s' % show_deprecations, 'testDebugUnitTest', '--tests=%s' % test_class, '--rerun-tasks', @@ -567,6 +570,8 @@ def main(): default=False, help='Provide the sanitizer suppressions lists to the via environment to the tests.') parser.add_argument('--adb-path', dest='adb_path', action='store', default=None, help='Provide the path of adb used for android tests. By default it looks on $PATH.') + parser.add_argument('--showDeprecations', help='Whether or not to show usage of deprecated APIs (currently supported on Android)', + action="store_true") args = parser.parse_args() @@ -613,7 +618,7 @@ def main(): if ',' in java_filter or '*' in java_filter: print('Can only filter JUnit4 tests by single entire class name, eg "io.flutter.SmokeTest". Ignoring filter=' + java_filter) java_filter = None - RunJavaTests(java_filter, args.android_variant) + RunJavaTests(java_filter, args.android_variant, args.showDeprecations) if 'android' in types: assert not IsWindows(), "Android engine files can't be compiled on Windows." From 8b102caee27eeae5a3db471e0074b5cd984cf9e4 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Thu, 3 Feb 2022 14:29:25 -0800 Subject: [PATCH 3/7] Edit warning, read me --- shell/platform/android/test/README.md | 2 +- testing/run_tests.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/platform/android/test/README.md b/shell/platform/android/test/README.md index ef203e012cefe..69dd17854312c 100644 --- a/shell/platform/android/test/README.md +++ b/shell/platform/android/test/README.md @@ -19,7 +19,7 @@ integration tests in other repos. `FlutterTestSuite.java`. This makes sure the test is actually executed at run time. 4. Write your test. -5. Build and run with `testing/run_tests.py [--type=java] [--java-filter=]`. +5. Build and run with `testing/run_tests.py [--type=java] [--java-filter=] [--showDeprecations]`. ## Q&A diff --git a/testing/run_tests.py b/testing/run_tests.py index 64e21cf767629..e08cad7cbc771 100755 --- a/testing/run_tests.py +++ b/testing/run_tests.py @@ -570,7 +570,7 @@ def main(): default=False, help='Provide the sanitizer suppressions lists to the via environment to the tests.') parser.add_argument('--adb-path', dest='adb_path', action='store', default=None, help='Provide the path of adb used for android tests. By default it looks on $PATH.') - parser.add_argument('--showDeprecations', help='Whether or not to show usage of deprecated APIs (currently supported on Android)', + parser.add_argument('--showDeprecations', help='Show warnings concerning usage of deprecated APIs when running Android tests', action="store_true") args = parser.parse_args() From 48edf28c05bb31a89f8d85ca646bfbac435578c7 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Fri, 4 Feb 2022 09:56:38 -0800 Subject: [PATCH 4/7] Match variable formatting corretly --- shell/platform/android/test/README.md | 2 +- shell/platform/android/test_runner/build.gradle | 2 +- testing/run_tests.py | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/shell/platform/android/test/README.md b/shell/platform/android/test/README.md index 69dd17854312c..2509a0e19acd5 100644 --- a/shell/platform/android/test/README.md +++ b/shell/platform/android/test/README.md @@ -19,7 +19,7 @@ integration tests in other repos. `FlutterTestSuite.java`. This makes sure the test is actually executed at run time. 4. Write your test. -5. Build and run with `testing/run_tests.py [--type=java] [--java-filter=] [--showDeprecations]`. +5. Build and run with `testing/run_tests.py [--type=java] [--java-filter=] [--show-deprecations]`. ## Q&A diff --git a/shell/platform/android/test_runner/build.gradle b/shell/platform/android/test_runner/build.gradle index 735125813344b..0a1bde2729d4d 100644 --- a/shell/platform/android/test_runner/build.gradle +++ b/shell/platform/android/test_runner/build.gradle @@ -18,7 +18,7 @@ apply plugin: "com.android.library" rootProject.buildDir = project.property("build_dir") // Shows warnings for usage of deprecated API usages if specified. -def showDeprecations = project.findProperty('showDeprecations') +def showDeprecations = project.findProperty('show-deprecations') gradle.projectsEvaluated { if (showDeprecations) { tasks.withType(JavaCompile) { diff --git a/testing/run_tests.py b/testing/run_tests.py index e08cad7cbc771..9f9c2f68b49b8 100755 --- a/testing/run_tests.py +++ b/testing/run_tests.py @@ -326,7 +326,7 @@ def JavaBin(): return os.path.join(JavaHome(), 'bin', 'java.exe' if IsWindows() else 'java') -def RunJavaTests(filter, android_variant='android_debug_unopt', showDeprecations=False): +def RunJavaTests(filter, android_variant='android_debug_unopt', show_deprecations=False): """Runs the Java JUnit unit tests for the Android embedding""" test_runner_dir = os.path.join(buildroot_dir, 'flutter', 'shell', 'platform', 'android', 'test_runner') gradle_bin = os.path.join(buildroot_dir, 'gradle', 'bin', 'gradle.bat' if IsWindows() else 'gradle') @@ -336,13 +336,13 @@ def RunJavaTests(filter, android_variant='android_debug_unopt', showDeprecations gradle_cache_dir = os.path.join(out_dir, android_variant, 'robolectric_tests', '.gradle') test_class = filter if filter else 'io.flutter.FlutterTestSuite' - show_deprecations = 'true' if showDeprecations else '' + show_deprecations = 'true' if show_deprecations else '' command = [ gradle_bin, '-Pflutter_jar=%s' % flutter_jar, '-Pbuild_dir=%s' % build_dir, - '-PshowDeprecations=%s' % show_deprecations, + '-Pshow-deprecations=%s' % show_deprecations, 'testDebugUnitTest', '--tests=%s' % test_class, '--rerun-tasks', @@ -570,7 +570,7 @@ def main(): default=False, help='Provide the sanitizer suppressions lists to the via environment to the tests.') parser.add_argument('--adb-path', dest='adb_path', action='store', default=None, help='Provide the path of adb used for android tests. By default it looks on $PATH.') - parser.add_argument('--showDeprecations', help='Show warnings concerning usage of deprecated APIs when running Android tests', + parser.add_argument('--show-deprecations', dest='show_deprecations', help='Show warnings concerning usage of deprecated APIs when running Android tests', action="store_true") args = parser.parse_args() @@ -618,7 +618,7 @@ def main(): if ',' in java_filter or '*' in java_filter: print('Can only filter JUnit4 tests by single entire class name, eg "io.flutter.SmokeTest". Ignoring filter=' + java_filter) java_filter = None - RunJavaTests(java_filter, args.android_variant, args.showDeprecations) + RunJavaTests(java_filter, args.android_variant, args.show_deprecations) if 'android' in types: assert not IsWindows(), "Android engine files can't be compiled on Windows." From 9157cfd6b9fb653011f99419381da319778788de Mon Sep 17 00:00:00 2001 From: camsim99 Date: Fri, 4 Feb 2022 15:30:17 -0800 Subject: [PATCH 5/7] Set on by default, specify Android --- shell/platform/android/test/README.md | 2 +- shell/platform/android/test_runner/build.gradle | 6 +++--- testing/run_tests.py | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/shell/platform/android/test/README.md b/shell/platform/android/test/README.md index 2509a0e19acd5..2c106b30c22ab 100644 --- a/shell/platform/android/test/README.md +++ b/shell/platform/android/test/README.md @@ -19,7 +19,7 @@ integration tests in other repos. `FlutterTestSuite.java`. This makes sure the test is actually executed at run time. 4. Write your test. -5. Build and run with `testing/run_tests.py [--type=java] [--java-filter=] [--show-deprecations]`. +5. Build and run with `testing/run_tests.py [--type=java] [--java-filter=] [--ignore-android-deprecations]`. ## Q&A diff --git a/shell/platform/android/test_runner/build.gradle b/shell/platform/android/test_runner/build.gradle index 0a1bde2729d4d..5ac5c6b4b04b1 100644 --- a/shell/platform/android/test_runner/build.gradle +++ b/shell/platform/android/test_runner/build.gradle @@ -17,10 +17,10 @@ apply plugin: "com.android.library" rootProject.buildDir = project.property("build_dir") -// Shows warnings for usage of deprecated API usages if specified. -def showDeprecations = project.findProperty('show-deprecations') +// Shows warnings for usage of deprecated API usages unless otherwise specified. +def ignoreDeprecations = project.findProperty('ignore-deprecations') gradle.projectsEvaluated { - if (showDeprecations) { + if (!ignoreDeprecations.toBoolean()) { tasks.withType(JavaCompile) { options.compilerArgs << "-Xlint:deprecation" } diff --git a/testing/run_tests.py b/testing/run_tests.py index 9f9c2f68b49b8..a9aad60cb35cb 100755 --- a/testing/run_tests.py +++ b/testing/run_tests.py @@ -326,7 +326,7 @@ def JavaBin(): return os.path.join(JavaHome(), 'bin', 'java.exe' if IsWindows() else 'java') -def RunJavaTests(filter, android_variant='android_debug_unopt', show_deprecations=False): +def RunJavaTests(filter, android_variant='android_debug_unopt', ignore_android_deprecations=False): """Runs the Java JUnit unit tests for the Android embedding""" test_runner_dir = os.path.join(buildroot_dir, 'flutter', 'shell', 'platform', 'android', 'test_runner') gradle_bin = os.path.join(buildroot_dir, 'gradle', 'bin', 'gradle.bat' if IsWindows() else 'gradle') @@ -336,13 +336,13 @@ def RunJavaTests(filter, android_variant='android_debug_unopt', show_deprecation gradle_cache_dir = os.path.join(out_dir, android_variant, 'robolectric_tests', '.gradle') test_class = filter if filter else 'io.flutter.FlutterTestSuite' - show_deprecations = 'true' if show_deprecations else '' + ignore_deprecations = 'true' if ignore_android_deprecations else '' command = [ gradle_bin, '-Pflutter_jar=%s' % flutter_jar, '-Pbuild_dir=%s' % build_dir, - '-Pshow-deprecations=%s' % show_deprecations, + '-Pignore-deprecations=%s' % ignore_deprecations, 'testDebugUnitTest', '--tests=%s' % test_class, '--rerun-tasks', @@ -570,7 +570,7 @@ def main(): default=False, help='Provide the sanitizer suppressions lists to the via environment to the tests.') parser.add_argument('--adb-path', dest='adb_path', action='store', default=None, help='Provide the path of adb used for android tests. By default it looks on $PATH.') - parser.add_argument('--show-deprecations', dest='show_deprecations', help='Show warnings concerning usage of deprecated APIs when running Android tests', + parser.add_argument('--ignore-android-deprecations', dest='ignore_android_deprecations', help='Hide warnings concerning usage of deprecated APIs when running Android tests', action="store_true") args = parser.parse_args() @@ -618,7 +618,7 @@ def main(): if ',' in java_filter or '*' in java_filter: print('Can only filter JUnit4 tests by single entire class name, eg "io.flutter.SmokeTest". Ignoring filter=' + java_filter) java_filter = None - RunJavaTests(java_filter, args.android_variant, args.show_deprecations) + RunJavaTests(java_filter, args.android_variant, args.ignore_android_deprecations) if 'android' in types: assert not IsWindows(), "Android engine files can't be compiled on Windows." From 07663ba828532ddef9a13ce155f70a8103dbe25e Mon Sep 17 00:00:00 2001 From: camsim99 Date: Fri, 4 Feb 2022 16:28:08 -0800 Subject: [PATCH 6/7] Add Gary's clarification --- testing/run_tests.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/testing/run_tests.py b/testing/run_tests.py index a9aad60cb35cb..22cacec6fe447 100755 --- a/testing/run_tests.py +++ b/testing/run_tests.py @@ -336,13 +336,12 @@ def RunJavaTests(filter, android_variant='android_debug_unopt', ignore_android_d gradle_cache_dir = os.path.join(out_dir, android_variant, 'robolectric_tests', '.gradle') test_class = filter if filter else 'io.flutter.FlutterTestSuite' - ignore_deprecations = 'true' if ignore_android_deprecations else '' command = [ gradle_bin, '-Pflutter_jar=%s' % flutter_jar, '-Pbuild_dir=%s' % build_dir, - '-Pignore-deprecations=%s' % ignore_deprecations, + '-Pignore-deprecations=%s' % ignore_android_deprecations, 'testDebugUnitTest', '--tests=%s' % test_class, '--rerun-tasks', @@ -571,7 +570,7 @@ def main(): parser.add_argument('--adb-path', dest='adb_path', action='store', default=None, help='Provide the path of adb used for android tests. By default it looks on $PATH.') parser.add_argument('--ignore-android-deprecations', dest='ignore_android_deprecations', help='Hide warnings concerning usage of deprecated APIs when running Android tests', - action="store_true") + action="store_true", default=False) args = parser.parse_args() From 2ea97b3c1341ddb8d83ae95a2d5486a9ba6967c3 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Wed, 9 Feb 2022 10:17:09 -0800 Subject: [PATCH 7/7] Remove option --- shell/platform/android/test/README.md | 2 +- shell/platform/android/test_runner/build.gradle | 9 +++------ testing/run_tests.py | 8 ++------ 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/shell/platform/android/test/README.md b/shell/platform/android/test/README.md index 2c106b30c22ab..ef203e012cefe 100644 --- a/shell/platform/android/test/README.md +++ b/shell/platform/android/test/README.md @@ -19,7 +19,7 @@ integration tests in other repos. `FlutterTestSuite.java`. This makes sure the test is actually executed at run time. 4. Write your test. -5. Build and run with `testing/run_tests.py [--type=java] [--java-filter=] [--ignore-android-deprecations]`. +5. Build and run with `testing/run_tests.py [--type=java] [--java-filter=]`. ## Q&A diff --git a/shell/platform/android/test_runner/build.gradle b/shell/platform/android/test_runner/build.gradle index 5ac5c6b4b04b1..1b727ba1b2249 100644 --- a/shell/platform/android/test_runner/build.gradle +++ b/shell/platform/android/test_runner/build.gradle @@ -17,13 +17,10 @@ apply plugin: "com.android.library" rootProject.buildDir = project.property("build_dir") -// Shows warnings for usage of deprecated API usages unless otherwise specified. -def ignoreDeprecations = project.findProperty('ignore-deprecations') +// Shows warnings for usage of deprecated API usages. gradle.projectsEvaluated { - if (!ignoreDeprecations.toBoolean()) { - tasks.withType(JavaCompile) { - options.compilerArgs << "-Xlint:deprecation" - } + tasks.withType(JavaCompile) { + options.compilerArgs << "-Xlint:deprecation" } } diff --git a/testing/run_tests.py b/testing/run_tests.py index 22cacec6fe447..99c8137676550 100755 --- a/testing/run_tests.py +++ b/testing/run_tests.py @@ -326,7 +326,7 @@ def JavaBin(): return os.path.join(JavaHome(), 'bin', 'java.exe' if IsWindows() else 'java') -def RunJavaTests(filter, android_variant='android_debug_unopt', ignore_android_deprecations=False): +def RunJavaTests(filter, android_variant='android_debug_unopt'): """Runs the Java JUnit unit tests for the Android embedding""" test_runner_dir = os.path.join(buildroot_dir, 'flutter', 'shell', 'platform', 'android', 'test_runner') gradle_bin = os.path.join(buildroot_dir, 'gradle', 'bin', 'gradle.bat' if IsWindows() else 'gradle') @@ -336,12 +336,10 @@ def RunJavaTests(filter, android_variant='android_debug_unopt', ignore_android_d gradle_cache_dir = os.path.join(out_dir, android_variant, 'robolectric_tests', '.gradle') test_class = filter if filter else 'io.flutter.FlutterTestSuite' - command = [ gradle_bin, '-Pflutter_jar=%s' % flutter_jar, '-Pbuild_dir=%s' % build_dir, - '-Pignore-deprecations=%s' % ignore_android_deprecations, 'testDebugUnitTest', '--tests=%s' % test_class, '--rerun-tasks', @@ -569,8 +567,6 @@ def main(): default=False, help='Provide the sanitizer suppressions lists to the via environment to the tests.') parser.add_argument('--adb-path', dest='adb_path', action='store', default=None, help='Provide the path of adb used for android tests. By default it looks on $PATH.') - parser.add_argument('--ignore-android-deprecations', dest='ignore_android_deprecations', help='Hide warnings concerning usage of deprecated APIs when running Android tests', - action="store_true", default=False) args = parser.parse_args() @@ -617,7 +613,7 @@ def main(): if ',' in java_filter or '*' in java_filter: print('Can only filter JUnit4 tests by single entire class name, eg "io.flutter.SmokeTest". Ignoring filter=' + java_filter) java_filter = None - RunJavaTests(java_filter, args.android_variant, args.ignore_android_deprecations) + RunJavaTests(java_filter, args.android_variant) if 'android' in types: assert not IsWindows(), "Android engine files can't be compiled on Windows."